73640a4190
Incorporating the abandoned work from PRs #35288 and #45552. Also adding in the version checking from `docker_container.py`, which should be abstracted out to `docker_common.py`.
61 lines
1.6 KiB
YAML
61 lines
1.6 KiB
YAML
---
|
|
- block:
|
|
- name: Make sure we're not already using Docker swarm
|
|
docker_swarm:
|
|
state: absent
|
|
force: true
|
|
|
|
- name: Test parameters with state=join
|
|
docker_swarm:
|
|
state: join
|
|
ignore_errors: yes
|
|
register: output
|
|
|
|
- name: assert failure when called with state=join and no advertise_addr,remote_addrs,join_token
|
|
assert:
|
|
that:
|
|
- 'output.failed'
|
|
- 'output.msg == "state is join but all of the following are missing: advertise_addr, remote_addrs, join_token"'
|
|
|
|
- name: Test parameters with state=remove
|
|
docker_swarm:
|
|
state: remove
|
|
ignore_errors: yes
|
|
register: output
|
|
|
|
- name: assert failure when called with state=remove and no node_id
|
|
assert:
|
|
that:
|
|
- 'output.failed'
|
|
- 'output.msg == "state is remove but all of the following are missing: node_id"'
|
|
|
|
- name: Create a Swarm cluster
|
|
docker_swarm:
|
|
state: present
|
|
register: output
|
|
|
|
- name: assert changed when create a new swarm cluster
|
|
assert:
|
|
that:
|
|
- 'output.changed'
|
|
- 'output.actions[0] | regex_search("New Swarm cluster created: ")'
|
|
- 'output.swarm_facts.JoinTokens.Manager'
|
|
- 'output.swarm_facts.JoinTokens.Worker'
|
|
|
|
- name: Remove a Swarm cluster
|
|
docker_swarm:
|
|
state: absent
|
|
force: true
|
|
register: output
|
|
|
|
- name: assert changed when remove a swarm cluster
|
|
assert:
|
|
that:
|
|
- 'output.changed'
|
|
- 'output.actions[0] == "Node has left the swarm cluster"'
|
|
|
|
always:
|
|
- name: Cleanup
|
|
docker_swarm:
|
|
state: absent
|
|
force: true
|