You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm focussing a confilict with docker installation. The bridge ip is in conflict with an existing network.
I'm currently using following playbook for testing with ubuntu 20 server. In my playbook I'm using the last octet of the IP address ansible_default_ipv4.address and append it to docker_bridge_network to prevent duplicate IPs.
Whats missing in this playbook is the management of an already existing /etc/docker/daemon.json file, because the daemon.json entry { "bip": "{{ bip_ipaddr }}" } must be present before docker installation. Otherwise the docker daemon is starting with the conflicting default ip address.
What do you think?
Will it be better to manually define the bridge ips for all nodes. Or stick to the last octeet and accept the restriction of max 253 nodes in cluster
Should I open a pull request?
kr
Josef
Defined in group_vars:
# Bridge Network IPv4 used as "bip" in /docker/daemon.json# The default value if not defined is 172.17.0.0/16 docker_bridge_network: 172.140.0.0/24
Included tasks to install docker on ubuntu 20 focal:
# Install docker## Parameters:# docker_bridge_network (optional) - ipv4/cidr e.g. 172.140.0.0/24########################################################################### Initialization - prepare docker bridge network##########################################################################
- name: Calculate Docker Bridge IP (bip_addr)block:
- name: Ensure valid IP/CIDR specified in docker_bridge_networkassert:
msg: | 'docker_bridge_network' must contain a valid ipv4/cidr network address! e.g. docker_bridge_network: 172.140.0.0/24that:
- docker_bridge_network | ipaddr(False)
- name: Prepare calculation argumentsset_fact:
ip_last_octett: "{{ ansible_default_ipv4.address.split('.')[3].split('/') | first }}"bip_parts: "{{ docker_bridge_network.split('.') }}"
- name: Calculate docker bridge ipset_fact:
bip_ipaddr: "{{ bip_parts[0] ~ '.' ~ bip_parts[1] ~ '.' ~ bip_parts[2] ~ '.' ~ ip_last_octett ~ '/' ~ bip_parts[3].split('/')[1] }}"
- name: Check that bridge ip is a valid IP/CIDR addrassert:
msg: | ERROR: 'bip_ipaddr' is not a valid ipv4/cidr address!that:
- bip_ipaddr | ipaddr(False)
- debug:
msg: "Docker Bridge Address: {{ bip_ipaddr }}"when:
- docker_bridge_network is defined
- name: Setup /etc/docker/daemon.json file if neededblock:
- name: Define filename for docker daemon initializationset_fact:
daemon_filename: "/etc/docker/daemon.json"
- name: Ensure docker directory existsfile:
path: /etc/dockerstate: directorybecome: true
- name: Check that sudoers file existsstat:
path: "{{ daemon_filename }}"register: res_daemon_filenamebecome: true
- name: Set flag daemon_file_missingset_fact:
daemon_file_missing: "{{ not (res_daemon_filename.stat.isreg | default(false)) | bool }}"
- name: Setup bridge ip for docker daemoncopy:
dest: "{{ daemon_filename }}"content: | { "bip": "{{ bip_ipaddr }}" }when:
- daemon_file_missingbecome: truewhen:
- docker_bridge_network is defined########################################################################### Install docker-ce repository##########################################################################
- name: Add Docker GPG keyapt_key:
url: https://download.docker.com/linux/ubuntu/gpgstate: present# //TODO: Add focal repository when available
- name: Install docker and requirementsapt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
- docker.io
- docker-composestate: presentupdate_cache: truebecome: true
- name: Enable and start service dockerservice:
name: dockerenabled: truestate: startedbecome: true########################################################################### Verify docker installation##########################################################################
- name: Verify installationshell:
cmd: "{{ item }}"become: trueloop:
- docker version
- docker info
- docker network ls
- ip link
- bridge link
- docker run --rm hello-world
- docker run --rm alpine cat /etc/resolv.conf
- docker run --rm alpine ping -c1 8.8.8.8changed_when: false
The text was updated successfully, but these errors were encountered:
Hello,
I'm focussing a confilict with docker installation. The bridge ip is in conflict with an existing network.
I'm currently using following playbook for testing with ubuntu 20 server. In my playbook I'm using the last octet of the IP address
ansible_default_ipv4.address
and append it todocker_bridge_network
to prevent duplicate IPs.Whats missing in this playbook is the management of an already existing
/etc/docker/daemon.json
file, because thedaemon.json
entry{ "bip": "{{ bip_ipaddr }}" }
must be present before docker installation. Otherwise the docker daemon is starting with the conflicting default ip address.What do you think?
Will it be better to manually define the bridge ips for all nodes. Or stick to the last octeet and accept the restriction of max 253 nodes in cluster
Should I open a pull request?
kr
Josef
Defined in group_vars:
Included tasks to install docker on ubuntu 20 focal:
The text was updated successfully, but these errors were encountered: