mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-06 22:24:23 -07:00
Initial commit
This commit is contained in:
commit
aebc1b03fd
4861 changed files with 812621 additions and 0 deletions
11
tests/integration/targets/inventory_docker_swarm/aliases
Normal file
11
tests/integration/targets/inventory_docker_swarm/aliases
Normal file
|
@ -0,0 +1,11 @@
|
|||
shippable/posix/group2
|
||||
skip/aix
|
||||
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,2 @@
|
|||
plugin: community.general.docker_swarm
|
||||
docker_host: unix://var/run/docker.sock
|
|
@ -0,0 +1,4 @@
|
|||
plugin: community.general.docker_swarm
|
||||
docker_host: unix://var/run/docker.sock
|
||||
verbose_output: false
|
||||
include_host_uri: true
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- setup_docker
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- hosts: 127.0.0.1
|
||||
connection: local
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Make sure swarm is removed
|
||||
docker_swarm:
|
||||
state: absent
|
||||
force: yes
|
||||
|
||||
- name: remove docker pagkages
|
||||
action: "{{ ansible_facts.pkg_mgr }}"
|
||||
args:
|
||||
name:
|
||||
- docker
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
state: absent
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
- hosts: 127.0.0.1
|
||||
connection: local
|
||||
vars:
|
||||
docker_skip_cleanup: yes
|
||||
|
||||
tasks:
|
||||
- name: Setup docker
|
||||
import_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,58 @@
|
|||
---
|
||||
- hosts: 127.0.0.1
|
||||
connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Show all groups
|
||||
debug:
|
||||
var: groups
|
||||
- name: Make sure docker_swarm groups are there
|
||||
assert:
|
||||
that:
|
||||
- groups.all | length > 0
|
||||
- groups.leader | length == 1
|
||||
- groups.manager | length > 0
|
||||
- groups.worker | length >= 0
|
||||
- groups.nonleaders | length >= 0
|
||||
|
||||
- hosts: all
|
||||
connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
|
||||
vars:
|
||||
# for some reason, Ansible can't find the Python interpreter when connecting to the nodes,
|
||||
# which is in fact just localhost in disguise. That's why we use ansible_playbook_python.
|
||||
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
||||
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: Make sure docker_swarm_node_attributes is available
|
||||
assert:
|
||||
that:
|
||||
- docker_swarm_node_attributes is not undefined
|
||||
- name: Print docker_swarm_node_attributes per host
|
||||
debug:
|
||||
var: docker_swarm_node_attributes
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
- hosts: 127.0.0.1
|
||||
connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Show all groups
|
||||
debug:
|
||||
var: groups
|
||||
- name: Make sure docker_swarm groups are there
|
||||
assert:
|
||||
that:
|
||||
- groups.all | length > 0
|
||||
- groups.leader | length == 1
|
||||
- groups.manager | length > 0
|
||||
- groups.worker | length >= 0
|
||||
- groups.nonleaders | length >= 0
|
||||
|
||||
- hosts: all
|
||||
connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
|
||||
vars:
|
||||
# for some reason, Ansible can't find the Python interpreter when connecting to the nodes,
|
||||
# which is in fact just localhost in disguise. That's why we use ansible_playbook_python.
|
||||
ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
||||
tasks:
|
||||
- name: Make sure docker_swarm_node_attributes is not available
|
||||
assert:
|
||||
that:
|
||||
- docker_swarm_node_attributes is undefined
|
||||
- name: Make sure ansible_host_uri is available
|
||||
assert:
|
||||
that:
|
||||
- ansible_host_uri is defined
|
||||
- name: Print ansible_host_uri
|
||||
debug:
|
||||
var: ansible_host_uri
|
23
tests/integration/targets/inventory_docker_swarm/runme.sh
Executable file
23
tests/integration/targets/inventory_docker_swarm/runme.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/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_ROLES_PATH=.. 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
|
||||
|
||||
echo "Test docker_swarm inventory 2"
|
||||
ansible-playbook -i inventory_2.docker_swarm.yml playbooks/test_inventory_2.yml
|
Loading…
Add table
Add a link
Reference in a new issue