community.docker.docker_swarm – Ansible dynamic inventory plugin for Docker swarm nodes.¶
Note
This plugin is part of the community.docker collection (version 1.5.0).
To install it use: ansible-galaxy collection install community.docker
.
To use it in a playbook, specify: community.docker.docker_swarm
.
Synopsis¶
Reads inventories from the Docker swarm API.
Uses a YAML configuration file docker_swarm.[yml|yaml].
The plugin returns following groups of swarm nodes: all - all hosts; workers - all worker nodes; managers - all manager nodes; leader - the swarm leader node; nonleaders - all nodes except the swarm leader.
Requirements¶
The below requirements are needed on the local controller node that executes this inventory.
python >= 2.7
Docker SDK for Python >= 1.10.0
Parameters¶
Examples¶
# Minimal example using local docker
plugin: community.docker.docker_swarm
docker_host: unix://var/run/docker.sock
# Minimal example using remote docker
plugin: community.docker.docker_swarm
docker_host: tcp://my-docker-host:2375
# Example using remote docker with unverified TLS
plugin: community.docker.docker_swarm
docker_host: tcp://my-docker-host:2376
tls: yes
# Example using remote docker with verified TLS and client certificate verification
plugin: community.docker.docker_swarm
docker_host: tcp://my-docker-host:2376
validate_certs: yes
ca_cert: /somewhere/ca.pem
client_key: /somewhere/key.pem
client_cert: /somewhere/cert.pem
# Example using constructed features to create groups and set ansible_host
plugin: community.docker.docker_swarm
docker_host: tcp://my-docker-host:2375
strict: False
keyed_groups:
# add e.g. x86_64 hosts to an arch_x86_64 group
- prefix: arch
key: 'Description.Platform.Architecture'
# add e.g. linux hosts to an os_linux group
- prefix: os
key: 'Description.Platform.OS'
# create a group per node label
# e.g. a node labeled w/ "production" ends up in group "label_production"
# hint: labels containing special characters will be converted to safe names
- key: 'Spec.Labels'
prefix: label
Authors¶
Stefan Heitmüller (@morph027) <stefan.heitmueller@gmx.com>