1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/docker_swarm/tasks/test_swarm.yml
Thierry BOUVET 8b9fe42c72 Add new module to create/update a docker swarm. (#38280)
* Add new module to create/update a docker swarm.

* Fix ansible-test sanity

* Fix requirements

* Fix requirements

* Add tag for author

* Test integration test.

* Fix main.yml

* Add linux arch

* Add template

* Fix test result

* Integration test to create/remove a swarm manager

* fix join test

* Downgrade docker-py

* fix rhel

* Fix review documentation.

* Fix whitespace

* Check docker installation.

* test docker install

* check

* Remove docker socket

* Fix docker install

* Fix sanity test

* Rebase

* Add docker_swarm maintainer

* Fix review

* Fix new version.

* Add docker default values

* Fix description.

* Reworked documentation

* Fix YAML error

* Rebase

* Fix example for update state.

* Fix idempotent states. Fix states: present/absent.

* Fix sanity

* Fix variables sanity

* Update example for absent state.

* fix sanity

* Wrap the contents of error message in to_native.


Co-authored by: Dag Wieers <dag@wieers.com>
2018-06-08 10:45:09 -04:00

68 lines
1.8 KiB
YAML

- name: Install Python requirements
pip:
state: present
name: "{{ item }}"
with_items:
- docker==2.7.0
- name: Test parameters with state=present
docker_swarm:
state: present
ignore_errors: yes
register: output
- name: assert failure when called with state=init and no advertise_addr
assert:
that:
- 'output.failed'
- 'output.msg == "advertise_addr is required to initialize a swarm cluster."'
- 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
advertise_addr: "{{ansible_default_ipv4.address}}"
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 leaved the swarm cluster"'