Skip to content

Commit 3bb8a49

Browse files
thekomaatosatto
authored andcommitted
Docker joins with FQDN so we should find the nodes by FQDN
1 parent 600b991 commit 3bb8a49

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tasks/setup-swarm-labels.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
command: >-
55
docker inspect
66
--format {% raw %}'{{ range $key, $value := .Spec.Labels }}{{ printf "%s\n" $key }}{{ end }}'{% endraw %}
7-
{{ ansible_hostname }}
7+
{{ ansible_fqdn|lower }}
88
register: docker_swarm_labels
99
changed_when: false
1010
delegate_to: "{{ groups['docker_swarm_manager'][0] }}"
@@ -13,7 +13,7 @@
1313
- swarm_labels
1414

1515
- name: Remove labels from swarm node.
16-
command: docker node update --label-rm {{ item }} {{ ansible_hostname }}
16+
command: docker node update --label-rm {{ item }} {{ ansible_fqdn|lower }}
1717
with_items: "{{ docker_swarm_labels.stdout_lines }}"
1818
when: item not in swarm_labels
1919
delegate_to: "{{ groups['docker_swarm_manager'][0] }}"
@@ -22,7 +22,7 @@
2222
- swarm_labels
2323

2424
- name: Assign labels to swarm nodes if any.
25-
command: docker node update --label-add {{ item }}=true {{ ansible_hostname }}
25+
command: docker node update --label-add {{ item }}=true {{ ansible_fqdn|lower }}
2626
when: item not in docker_swarm_labels.stdout_lines
2727
with_items:
2828
- "{{ swarm_labels | default([]) }}"

0 commit comments

Comments
 (0)