@ -4,6 +4,7 @@
docker_swarm:
docker_swarm:
state : absent
state : absent
force : true
force : true
diff : no
- name : Test parameters with state=join
- name : Test parameters with state=join
docker_swarm:
docker_swarm:
@ -34,18 +35,21 @@
state : present
state : present
advertise_addr : "{{ansible_default_ipv4.address}}"
advertise_addr : "{{ansible_default_ipv4.address}}"
check_mode : yes
check_mode : yes
diff : yes
register : output_1
register : output_1
- name : Create a Swarm cluster
- name : Create a Swarm cluster
docker_swarm:
docker_swarm:
state : present
state : present
advertise_addr : "{{ansible_default_ipv4.address}}"
advertise_addr : "{{ansible_default_ipv4.address}}"
diff : yes
register : output_2
register : output_2
- name : Create a Swarm cluster (idempotent)
- name : Create a Swarm cluster (idempotent)
docker_swarm:
docker_swarm:
state : present
state : present
advertise_addr : "{{ansible_default_ipv4.address}}"
advertise_addr : "{{ansible_default_ipv4.address}}"
diff : yes
register : output_3
register : output_3
- name : Create a Swarm cluster (idempotent, check mode)
- name : Create a Swarm cluster (idempotent, check mode)
@ -53,36 +57,48 @@
state : present
state : present
advertise_addr : "{{ansible_default_ipv4.address}}"
advertise_addr : "{{ansible_default_ipv4.address}}"
check_mode : yes
check_mode : yes
diff : yes
register : output_4
register : output_4
- name : assert changed when create a new swarm cluster
- name : assert changed when create a new swarm cluster
assert:
assert:
that:
that:
- 'output_1 is changed'
- 'output_1 is changed'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2 is changed'
- 'output_2.actions[0] | regex_search("New Swarm cluster created: ")'
- 'output_2.actions[0] | regex_search("New Swarm cluster created: ")'
- 'output_2.swarm_facts.JoinTokens.Manager'
- 'output_2.swarm_facts.JoinTokens.Manager'
- 'output_2.swarm_facts.JoinTokens.Worker'
- 'output_2.swarm_facts.JoinTokens.Worker'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3 is not changed'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4 is not changed'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
- name : Remove a Swarm cluster (check mode)
- name : Remove a Swarm cluster (check mode)
docker_swarm:
docker_swarm:
state : absent
state : absent
force : true
force : true
check_mode : yes
check_mode : yes
diff : yes
register : output_1
register : output_1
- name : Remove a Swarm cluster
- name : Remove a Swarm cluster
docker_swarm:
docker_swarm:
state : absent
state : absent
force : true
force : true
diff : yes
register : output_2
register : output_2
- name : Remove a Swarm cluster (idempotent)
- name : Remove a Swarm cluster (idempotent)
docker_swarm:
docker_swarm:
state : absent
state : absent
force : true
force : true
diff : yes
register : output_3
register : output_3
- name : Remove a Swarm cluster (idempotent, check mode)
- name : Remove a Swarm cluster (idempotent, check mode)
@ -90,19 +106,29 @@
state : absent
state : absent
force : true
force : true
check_mode : yes
check_mode : yes
diff : yes
register : output_4
register : output_4
- name : assert changed when remove a swarm cluster
- name : assert changed when remove a swarm cluster
assert:
assert:
that:
that:
- 'output_1 is changed'
- 'output_1 is changed'
- 'output_1.diff.before is defined'
- 'output_1.diff.after is defined'
- 'output_2 is changed'
- 'output_2 is changed'
- 'output_2.actions[0] == "Node has left the swarm cluster"'
- 'output_2.actions[0] == "Node has left the swarm cluster"'
- 'output_2.diff.before is defined'
- 'output_2.diff.after is defined'
- 'output_3 is not changed'
- 'output_3 is not changed'
- 'output_3.diff.before is defined'
- 'output_3.diff.after is defined'
- 'output_4 is not changed'
- 'output_4 is not changed'
- 'output_4.diff.before is defined'
- 'output_4.diff.after is defined'
always:
always:
- name : Cleanup
- name : Cleanup
docker_swarm:
docker_swarm:
state : absent
state : absent
force : true
force : true
diff : no