Fix port issue as buildin. Setup reassigns the default vars
This commit is contained in:
@@ -28,11 +28,18 @@
|
|||||||
- Final address: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] | default(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
|
- With port: {{ hostvars[groups['swarm_master'][0]]['ansible_host'] | default(groups['swarm_master'][0]) }}:2377
|
||||||
|
|
||||||
|
- name: Debug master hostvars
|
||||||
|
debug:
|
||||||
|
msg: |
|
||||||
|
advertise_addr: {{ ansible_eth1.ipv4.address }}
|
||||||
|
ansible_eth0: {{ ansible_eth0.ipv4.address }}
|
||||||
|
|
||||||
- name: Init a new swarm with default parameters
|
- name: Init a new swarm with default parameters
|
||||||
community.docker.docker_swarm:
|
community.docker.docker_swarm:
|
||||||
state: present
|
state: present
|
||||||
advertise_addr: "{{ ansible_eth1.ipv4.address }}"
|
advertise_addr: "{{ ansible_eth1.ipv4.address }}"
|
||||||
listen_addr: "{{ ansible_eth1.ipv4.address }}"
|
# listen_addr: "{{ ansible_eth1.ipv4.address }}"
|
||||||
|
# data_path_addr: "{{ ansible_eth1.ipv4.address }}"
|
||||||
|
|
||||||
- name: print listen addr
|
- name: print listen addr
|
||||||
debug:
|
debug:
|
||||||
|
|||||||
@@ -43,11 +43,22 @@
|
|||||||
|
|
||||||
# Join token (first 10 chars): {{ worker_token[:10] }}...
|
# Join token (first 10 chars): {{ worker_token[:10] }}...
|
||||||
|
|
||||||
|
- name: Debug IPs
|
||||||
|
debug:
|
||||||
|
msg: |
|
||||||
|
Current hostname: {{ inventory_hostname }}
|
||||||
|
ansible_eth1 full: {{ ansible_eth1 }}
|
||||||
|
ansible_eth1 ipv4: {{ ansible_eth1.ipv4 }}
|
||||||
|
ansible_eth1 ipv4 address: {{ ansible_eth1.ipv4.address }}
|
||||||
|
advertise_addr: {{ ansible_eth1.ipv4.address }}
|
||||||
|
ansible_eth0: {{ ansible_eth0.ipv4.address }}
|
||||||
- name: Gather master facts
|
- name: Gather master facts
|
||||||
ansible.builtin.setup:
|
ansible.builtin.setup:
|
||||||
delegate_to: "{{ groups['swarm_master'][0] }}"
|
delegate_to: "{{ groups['swarm_master'][0] }}"
|
||||||
run_once: true
|
run_once: true
|
||||||
register: master_facts
|
register: master_facts
|
||||||
|
- name: Regather node facts
|
||||||
|
ansible.builtin.setup:
|
||||||
|
|
||||||
# - name: Debug master hostvars
|
# - name: Debug master hostvars
|
||||||
# debug:
|
# debug:
|
||||||
@@ -59,6 +70,13 @@
|
|||||||
# Master ansible_default_ipv4: {{ master_facts.ansible_facts }}
|
# Master ansible_default_ipv4: {{ master_facts.ansible_facts }}
|
||||||
# remote_addrs: {{ master_facts.ansible_facts ['ansible_eth1']['ipv4']['address'] }}
|
# remote_addrs: {{ master_facts.ansible_facts ['ansible_eth1']['ipv4']['address'] }}
|
||||||
# advertise_addr: {{ ansible_eth1.ipv4.address }}
|
# advertise_addr: {{ ansible_eth1.ipv4.address }}
|
||||||
|
|
||||||
|
- name: Debug IPs
|
||||||
|
debug:
|
||||||
|
msg: |
|
||||||
|
remote_addrs: {{ master_facts.ansible_facts['ansible_eth1']['ipv4']['address'] }}:2377
|
||||||
|
advertise_addr: {{ ansible_eth1.ipv4.address }}
|
||||||
|
ansible_eth0: {{ ansible_eth0.ipv4.address }}
|
||||||
|
|
||||||
- name: Add nodes
|
- name: Add nodes
|
||||||
community.docker.docker_swarm:
|
community.docker.docker_swarm:
|
||||||
@@ -67,5 +85,6 @@
|
|||||||
remote_addrs:
|
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 }}"
|
advertise_addr: "{{ ansible_eth1.ipv4.address }}"
|
||||||
listen_addr: "{{ ansible_eth1.ipv4.address }}:2377"
|
# listen_addr: "{{ ansible_eth1.ipv4.address }}" # You already added this
|
||||||
|
# data_path_addr: "{{ ansible_eth1.ipv4.address }}"
|
||||||
|
|
||||||
@@ -121,6 +121,8 @@ services:
|
|||||||
- "traefik.http.routers.whoami.middlewares=whoami-stripprefix"
|
- "traefik.http.routers.whoami.middlewares=whoami-stripprefix"
|
||||||
# Expose the whoami port number to Traefik
|
# Expose the whoami port number to Traefik
|
||||||
- "traefik.http.services.whoami.loadbalancer.server.port=80"
|
- "traefik.http.services.whoami.loadbalancer.server.port=80"
|
||||||
|
mode: replicated
|
||||||
|
replicas: 1
|
||||||
|
|
||||||
# Define the overlay network for Swarm
|
# Define the overlay network for Swarm
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
Reference in New Issue
Block a user