mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
docker_swarm inventory plugin: add basic integration tests (#53908)
* Add basic docker_swarm inventory plugin integration tests. * Call dependency explicitly.
This commit is contained in:
parent
ef6da8ec5c
commit
259b2e06a4
7 changed files with 90 additions and 0 deletions
10
test/integration/targets/inventory_docker_swarm/aliases
Normal file
10
test/integration/targets/inventory_docker_swarm/aliases
Normal file
|
@ -0,0 +1,10 @@
|
|||
shippable/posix/group2
|
||||
skip/osx
|
||||
skip/freebsd
|
||||
destructive
|
||||
skip/docker # The tests sometimes make docker daemon unstable; hence,
|
||||
# we skip all docker-based CI runs to avoid disrupting
|
||||
# the whole CI system. On VMs, we restart docker daemon
|
||||
# after finishing the tests to minimize potential effects
|
||||
# on other tests.
|
||||
needs/root
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
plugin: docker_swarm
|
||||
host: unix://var/run/docker.sock
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- setup_docker
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
- hosts: 127.0.0.1
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Make sure swarm is removed
|
||||
docker_swarm:
|
||||
state: absent
|
||||
force: yes
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
- hosts: 127.0.0.1
|
||||
connection: local
|
||||
tasks:
|
||||
- name: Setup docker
|
||||
include_role:
|
||||
name: ../../setup_docker
|
||||
- name: Create a Swarm cluster
|
||||
docker_swarm:
|
||||
state: present
|
||||
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
- hosts: all
|
||||
connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
|
||||
tasks:
|
||||
- name: Check for groups
|
||||
assert:
|
||||
that:
|
||||
- "groups.manager | length > 0"
|
||||
- "groups.worker | length >= 0"
|
||||
- "groups.leader | length == 1"
|
||||
run_once: yes
|
||||
|
||||
- name: List manager group
|
||||
debug:
|
||||
var: groups.manager
|
||||
run_once: yes
|
||||
|
||||
- name: List worker group
|
||||
debug:
|
||||
var: groups.worker
|
||||
run_once: yes
|
||||
|
||||
- name: List leader group
|
||||
debug:
|
||||
var: groups.leader
|
||||
run_once: yes
|
||||
|
||||
- name: Print ansible_host per host
|
||||
debug:
|
||||
var: ansible_host
|
||||
|
||||
- name: Print docker_swarm_node_attributes per host
|
||||
debug:
|
||||
var: docker_swarm_node_attributes
|
20
test/integration/targets/inventory_docker_swarm/runme.sh
Executable file
20
test/integration/targets/inventory_docker_swarm/runme.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
cleanup() {
|
||||
echo "Cleanup"
|
||||
ansible-playbook playbooks/swarm_cleanup.yml
|
||||
echo "Done"
|
||||
exit 0
|
||||
}
|
||||
|
||||
trap cleanup INT TERM EXIT
|
||||
|
||||
echo "Setup"
|
||||
ansible-playbook playbooks/swarm_setup.yml
|
||||
|
||||
echo "Test docker_swarm inventory 1"
|
||||
ansible-playbook -i inventory_1.docker_swarm.yml playbooks/test_inventory_1.yml
|
Loading…
Reference in a new issue