docker_swarm: hopefully fix debug CI problems, and fix check mode (#52825)

* Let's see some debug output.

* Also check LocalNodeState.

* Improve tests.

* Actually implement check mode.

* Add changelog.

* Add pretty-printing and more output.
This commit is contained in:
Felix Fontein
2019-02-23 23:18:17 +01:00
committed by ansibot
parent e2856127f6
commit 81d58cfef6
5 changed files with 93 additions and 33 deletions

View File

@@ -1,10 +1,14 @@
---
- block:
- shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool"
- name: Make sure we're not already using Docker swarm
docker_swarm:
state: absent
force: true
- shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool"
- name: Create a Swarm cluster
docker_swarm:
state: present

View File

@@ -29,30 +29,73 @@
- 'output.failed'
- 'output.msg == "state is remove but all of the following are missing: node_id"'
- name: Create a Swarm cluster (check mode)
docker_swarm:
state: present
check_mode: yes
register: output_1
- name: Create a Swarm cluster
docker_swarm:
state: present
register: output
register: output_2
- name: Create a Swarm cluster (idempotent)
docker_swarm:
state: present
register: output_3
- name: Create a Swarm cluster (idempotent, check mode)
docker_swarm:
state: present
check_mode: yes
register: output_4
- 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'
- 'output_1 is changed'
- 'output_2 is changed'
- 'output_2.actions[0] | regex_search("New Swarm cluster created: ")'
- 'output_2.swarm_facts.JoinTokens.Manager'
- 'output_2.swarm_facts.JoinTokens.Worker'
- 'output_3 is not changed'
- 'output_4 is not changed'
- name: Remove a Swarm cluster (check mode)
docker_swarm:
state: absent
force: true
check_mode: yes
register: output_1
- name: Remove a Swarm cluster
docker_swarm:
state: absent
force: true
register: output
register: output_2
- name: Remove a Swarm cluster (idempotent)
docker_swarm:
state: absent
force: true
register: output_3
- name: Remove a Swarm cluster (idempotent, check mode)
docker_swarm:
state: absent
force: true
check_mode: yes
register: output_4
- name: assert changed when remove a swarm cluster
assert:
that:
- 'output.changed'
- 'output.actions[0] == "Node has left the swarm cluster"'
- 'output_1 is changed'
- 'output_2 is changed'
- 'output_2.actions[0] == "Node has left the swarm cluster"'
- 'output_3 is not changed'
- 'output_4 is not changed'
always:
- name: Cleanup