ansible / ansible.builtin / v2.8.20 / module / docker_stack docker stack module | "added in version" 2.8 of ansible.builtin" Authors: Dario Zanzico (@dariko) preview | supported by communityansible.builtin.docker_stack (v2.8.20) — module
pip
Install with pip install ansible==2.8.20
Manage docker stacks using the 'docker stack' command on the target node (see examples).
- name: Deploy stack from a compose file docker_stack: state: present name: mystack compose: - /opt/docker-compose.yml
- name: Deploy stack from base compose file and override the web service docker_stack: state: present name: mystack compose: - /opt/docker-compose.yml - version: '3' services: web: image: nginx:latest environment: ENVVAR: envvar
- name: Remove stack docker_stack: name: mystack state: absent
name: description: - Stack name required: true type: str prune: default: false description: - If true will add the C(--prune) option to the C(docker stack deploy) command. This will have docker remove the services not present in the current stack definition. type: bool state: choices: - present - absent default: present description: - Service state. type: str compose: default: [] description: - List of compose definitions. Any element may be a string referring to the path of the compose file on the target host or the YAML contents of a compose file nested as dictionary. type: list resolve_image: choices: - always - changed - never description: - If set will add the C(--resolve-image) option to the C(docker stack deploy) command. This will have docker query the registry to resolve image digest and supported platforms. If not set, docker use "always" by default. type: str absent_retries: default: 0 description: - If C(>0) and I(state) is C(absent) the module will retry up to I(absent_retries) times to delete the stack until all the resources have been effectively deleted. If the last try still reports the stack as not completely removed the module will fail. type: int with_registry_auth: default: false description: - If true will add the C(--with-registry-auth) option to the C(docker stack deploy) command. This will have docker send registry authentication details to Swarm agents. type: bool absent_retries_interval: default: 1 description: - Interval in seconds between consecutive I(absent_retries). type: int
stack_spec_diff: description: 'dictionary containing the differences between the ''Spec'' field of the stack services before and after applying the new stack definition. ' returned: on change sample: '"stack_spec_diff": {''test_stack_test_service'': {u''TaskTemplate'': {u''ContainerSpec'': {delete: [u''Env'']}}}} ' type: dict