Add support for labels

This commit is contained in:
Andrea Dell'Amico 2020-09-17 19:19:17 +02:00
parent a5cf11698f
commit cea4a8a709
2 changed files with 21 additions and 0 deletions

View File

@ -34,3 +34,10 @@ docker_log_to_journal: True
docker_daemon_debug: False
docker_prometheus_metrics: True
docker_prometheus_host: 127.0.0.1
# merge, replace
docker_label_state_mode: merge
docker_node_labels: []
#docker_node_labels:
# - { key: 'key_name', value: 'label_value' }

View File

@ -41,3 +41,17 @@
when: docker_swarm_node | bool
delegate_to: '{{ docker_swarm_manager_main_node_hostname }}'
tags: [ 'docker', 'docker_swarm', 'docker_swarm_worker_nodes', 'docker_swarm_worker_nodes_availability' ]
- name: Manage labels
block:
- name: Manage the swarm nodes labels
docker_node:
hostname: '{{ ansible_hostname }}'
labels:
'{{ item.key }}': '{{ item.value }}'
labels_state: '{{ docker_label_state_mode }}'
with_items: '{{ docker_node_labels }}'
when: docker_swarm_node | bool
delegate_to: '{{ docker_swarm_manager_main_node_hostname }}'
tags: [ 'docker', 'docker_swarm', 'docker_swarm_worker_nodes', 'docker_nodes_labels' ]