routing working
This commit is contained in:
@@ -20,27 +20,28 @@
|
||||
set_fact:
|
||||
worker_token: "{{ worker_token_file.content | b64decode | trim }}"
|
||||
|
||||
- name: Debug all relevant variables
|
||||
debug:
|
||||
msg: |
|
||||
=== SWARM JOIN DEBUG INFO ===
|
||||
Current host: {{ inventory_hostname }}
|
||||
Current host IP: {{ ansible_host }}
|
||||
# - name: Debug all relevant variables
|
||||
# debug:
|
||||
# msg: |
|
||||
# === SWARM JOIN DEBUG INFO ===
|
||||
# Current host: {{ inventory_hostname }}
|
||||
# Current host IP: {{ ansible_host }}
|
||||
# ansible_eth1={{ ansible_eth1.ipv4.address }}
|
||||
|
||||
Master group hosts: {{ groups['swarm_master'] }}
|
||||
First master: {{ groups['swarm_master'][0] }}
|
||||
|
||||
Master hostvars:
|
||||
- ansible_host: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] }}
|
||||
- inventory_hostname: {{ hostvars[groups['swarm_master'][0]]['inventory_hostname'] }}
|
||||
|
||||
Remote address calculation:
|
||||
- Raw master ansible_host: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] }}
|
||||
- Fallback to hostname: {{ groups['swarm_master'][0] }}
|
||||
- Final address: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] | default(groups['swarm_master'][0]) }}
|
||||
- With port: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] | default(groups['swarm_master'][0]) }}:2377
|
||||
|
||||
Join token (first 10 chars): {{ worker_token[:10] }}...
|
||||
# Master group hosts: {{ groups['swarm_master'] }}
|
||||
# First master: {{ groups['swarm_master'][0] }}
|
||||
|
||||
# Master hostvars:
|
||||
# - ansible_host: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] }}
|
||||
# - inventory_hostname: {{ hostvars[groups['swarm_master'][0]]['inventory_hostname'] }}
|
||||
|
||||
# Remote address calculation:
|
||||
# - Raw master ansible_host: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] }}
|
||||
# - Fallback to hostname: {{ groups['swarm_master'][0] }}
|
||||
# - Final address: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] | default(groups['swarm_master'][0]) }}
|
||||
# - With port: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] | default(groups['swarm_master'][0]) }}:2377
|
||||
|
||||
# Join token (first 10 chars): {{ worker_token[:10] }}...
|
||||
|
||||
- name: Gather master facts
|
||||
ansible.builtin.setup:
|
||||
@@ -48,21 +49,23 @@
|
||||
run_once: true
|
||||
register: master_facts
|
||||
|
||||
- name: Debug master hostvars
|
||||
debug:
|
||||
msg: |
|
||||
Master hostvars keys: {{ hostvars[groups['swarm_master'][0]].keys() | list }}
|
||||
Master ansible_eth1: {{ hostvars[groups['swarm_master'][0]].ansible_eth1 | default('Not available') }}
|
||||
Master node: {{ groups['swarm_master'][0] }}
|
||||
Master ansible_default_ipv4: {{ hostvars[groups['swarm_master'][0]] }}
|
||||
Master ansible_default_ipv4: {{ master_facts.ansible_facts }}
|
||||
FINAL IP: {{ master_facts.ansible_facts ['ansible_eth1']['ipv4']['address'] }}
|
||||
# - name: Debug master hostvars
|
||||
# debug:
|
||||
# msg: |
|
||||
# Master hostvars keys: {{ hostvars[groups['swarm_master'][0]].keys() | list }}
|
||||
# Master ansible_eth1: {{ hostvars[groups['swarm_master'][0]].ansible_eth1 | default('Not available') }}
|
||||
# Master node: {{ groups['swarm_master'][0] }}
|
||||
# Master ansible_default_ipv4: {{ hostvars[groups['swarm_master'][0]] }}
|
||||
# Master ansible_default_ipv4: {{ master_facts.ansible_facts }}
|
||||
# remote_addrs: {{ master_facts.ansible_facts ['ansible_eth1']['ipv4']['address'] }}
|
||||
# advertise_addr: {{ ansible_eth1.ipv4.address }}
|
||||
|
||||
- name: Add nodes
|
||||
community.docker.docker_swarm:
|
||||
state: join
|
||||
join_token: "{{ worker_token }}"
|
||||
remote_addrs:
|
||||
- "{{ master_facts.ansible_facts ['ansible_eth1']['ipv4']['address'] }}:2377"
|
||||
- "{{ master_facts.ansible_facts['ansible_eth1']['ipv4']['address'] }}:2377"
|
||||
advertise_addr: "{{ ansible_eth1.ipv4.address }}"
|
||||
listen_addr: "{{ ansible_eth1.ipv4.address }}:2377"
|
||||
|
||||
Reference in New Issue
Block a user