looking for an ansible script to install docker packages on the centos8 server with no internet access.
I have tried the below on my test server(which has internet access) but the actual server doesn’t have access to the internet and looking out for options.
---
- hosts: localhost
becomes: true
tasks:
- name: Install yum utils
yum:
name: yum-utils
state: latest
- name: Add Docker repo
get_url:
url: https://download.docker.com/linux/centos/docker-ce.repo
dest: /etc/yum.repos.d/docer-ce.repo
become: yes
2
Answers
You could provide the RPM from the ansible controller as part of your playbook then install it using the yum module.
If only the target server isn’t connected to internet, you can get the file from the controller and push it to the target:
In the above:
changed_when: false
.change
if the file has to be created or was modified if it differs on target from the fetched reference.*run_once: true
ensures the file is fetched only once whatever the number of target hosts in your play loop. The copy task will run for each target and push the file with the same contentIf both the controller and target are not connected to internet, you will have to get the repo file on the controller somehow before copying (and maintain it over time)