playbooks: added configure docker network playbook first version

per default docker uses IP 172.17.0.0/16 which conflicts with the
test network at NetModule. Hence, we reconfigure it to
192.168.5.1/24

Signed-off-by: Marc Mattmüller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmüller 2023-06-06 16:27:21 +02:00
parent ef3fd030ba
commit 3027f8e284
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
- name: Configure Docker Network Adapter
hosts: linux
gather_facts: false
become: yes
tasks:
- name: Bring docker network down and remove routes
ansible.builtin.shell: |
systemctl stop docker
systemctl stop docker.socket
iptables -t nat -F POSTROUTING
ip link set dev docker0 down
ip addr del <ip addr of docker0>/<netmaks> dev docker0
become: yes
- name: Configure docker network
ansible.builtin.shell: |
echo "{ \"bip\": \"192.168.5.1/24\" }" > /etc/docker/daemon.json
ip addr add 192.168.5.1/24 dev docker0
ip link set dev docker0 up
become: yes
- name: Verify docker IP address
register: verifyIp
ansible.builtin.shell: |
ip addr show docker0
- name: Display IP verification output
debug:
msg: "{{verifyIp.stdout_lines}}"
- name: Bring docker up again
register: bringUp
ansible.builtin.shell: |
systemctl start docker
iptables -t nat -L -n
ip route
become: yes
- name: Display Bring-up output
debug:
msg: "{{bringUp.stdout_lines}}"