diff --git a/defaults/main.yml b/defaults/main.yml index 362de63..f98fbe1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,8 +4,10 @@ docker_install: True docker_swarm: False docker_swarm_manager: False docker_swarm_manager_availability: 'drain' +docker_swarm_manager_advertise_address: '{{ ansible_default_ipv4.address }}' docker_swarm_node: False docker_swarm_node_availability: 'active' +docker_swarm_node_advertise_address: '{{ ansible_default_ipv4.address }}' docker_swarm_worker_hostname: '{{ ansible_fqdn }}' docker_swarm_allowed_hosts: - '0.0.0.0/0' diff --git a/tasks/swarm_mgr.yml b/tasks/swarm_mgr.yml index 48b456f..349cba1 100644 --- a/tasks/swarm_mgr.yml +++ b/tasks/swarm_mgr.yml @@ -10,6 +10,7 @@ - name: Initialize the cluster docker_swarm: state: present + advertise_addr: '{{ +docker_swarm_manager_advertise_address }}' when: - docker_swarm_manager | bool - docker_swarm_manager_main_node | bool @@ -34,7 +35,7 @@ - name: Add some manager nodes to the docker swarm cluster docker_swarm: state: join - advertise_addr: '{{ ansible_default_ipv4.address }}' + advertise_addr: '{{ docker_swarm_node_advertise_address }}' join_token: '{{ docker_swarm_mgr_token }}' remote_addrs: [ '{{ docker_swarm_manager_main_node_hostname }}:2377' ]