From a55f12a3508b7537da9f661bdc7938ee02e16dcc Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 25 May 2021 18:24:09 +0200 Subject: [PATCH] 'delegate_to' the IP address. Works when using private IPs. --- defaults/main.yml | 1 + tasks/swarm_mgr.yml | 4 ++-- tasks/swarm_node.yml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 608328f..bcbb8cf 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -12,6 +12,7 @@ docker_swarm_allowed_hosts: # Set this to one of the manager hostnames to be able to initialize the cluster docker_swarm_manager_main_node_hostname: localhost +docker_swarm_manager_main_node_address: 127.0.0.1 # Set this on one of the masters docker_swarm_manager_main_node: False diff --git a/tasks/swarm_mgr.yml b/tasks/swarm_mgr.yml index 9bcb0f4..48b456f 100644 --- a/tasks/swarm_mgr.yml +++ b/tasks/swarm_mgr.yml @@ -27,7 +27,7 @@ cacheable: True when: docker_swarm_manager - delegate_to: '{{ docker_swarm_manager_main_node_hostname }}' + delegate_to: '{{ docker_swarm_manager_main_node_address }}' tags: [ 'docker', 'docker_swarm' ] - block: @@ -46,7 +46,7 @@ - block: - name: Set the swarm manager nodes availability. Default 'drain' docker_node: - hostname: '{{ ansible_hostname }}' + hostname: '{{ ansible_fqdn }}' availability: '{{ docker_swarm_manager_availability }}' when: docker_swarm_manager | bool diff --git a/tasks/swarm_node.yml b/tasks/swarm_node.yml index e115e78..511931a 100644 --- a/tasks/swarm_node.yml +++ b/tasks/swarm_node.yml @@ -39,7 +39,7 @@ availability: '{{ docker_swarm_node_availability }}' when: docker_swarm_node | bool - delegate_to: '{{ docker_swarm_manager_main_node_hostname }}' + delegate_to: '{{ docker_swarm_manager_main_node_address }}' tags: [ 'docker', 'docker_swarm', 'docker_swarm_worker_nodes', 'docker_swarm_worker_nodes_availability' ] - name: Manage labels @@ -54,5 +54,5 @@ with_items: '{{ docker_node_labels }}' when: docker_swarm_node | bool - delegate_to: '{{ docker_swarm_manager_main_node_hostname }}' + delegate_to: '{{ docker_swarm_manager_main_node_address }}' tags: [ 'docker', 'docker_swarm', 'docker_swarm_worker_nodes', 'docker_nodes_labels' ]