diff options
Diffstat (limited to 'ansible_collections/community/docker/tests/ee')
4 files changed, 90 insertions, 0 deletions
diff --git a/ansible_collections/community/docker/tests/ee/all.yml b/ansible_collections/community/docker/tests/ee/all.yml new file mode 100644 index 00000000..907866f9 --- /dev/null +++ b/ansible_collections/community/docker/tests/ee/all.yml @@ -0,0 +1,20 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- hosts: localhost + vars: + docker_test_image_alpine: quay.io/ansible/docker-test-containers:alpine3.8 + tasks: + - name: Find all roles + find: + paths: + - "{{ (playbook_dir | default('.')) ~ '/roles' }}" + file_type: directory + depth: 1 + register: result + - name: Include all roles + include_role: + name: "{{ item }}" + loop: "{{ result.files | map(attribute='path') | map('regex_replace', '.*/', '') | sort }}" diff --git a/ansible_collections/community/docker/tests/ee/roles/current_container_facts/tasks/main.yml b/ansible_collections/community/docker/tests/ee/roles/current_container_facts/tasks/main.yml new file mode 100644 index 00000000..d5096cdd --- /dev/null +++ b/ansible_collections/community/docker/tests/ee/roles/current_container_facts/tasks/main.yml @@ -0,0 +1,32 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +- name: Retrieve information on current container + community.docker.current_container_facts: + register: result + +# The following two tasks are useful if we ever have to debug why this fails. + +- name: Print all Ansible facts + debug: + var: ansible_facts + +- name: Read some files + slurp: + src: "{{ item }}" + loop: + - /proc/self/cpuset + - /proc/1/cgroup + - /proc/1/environ + +- name: Print facts returned by module + debug: + var: result.ansible_facts + +- name: Validate results + assert: + that: + - ansible_module_running_in_container + - ansible_module_container_type != '' diff --git a/ansible_collections/community/docker/tests/ee/roles/docker_plain/tasks/main.yml b/ansible_collections/community/docker/tests/ee/roles/docker_plain/tasks/main.yml new file mode 100644 index 00000000..9c2be8a0 --- /dev/null +++ b/ansible_collections/community/docker/tests/ee/roles/docker_plain/tasks/main.yml @@ -0,0 +1,32 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +# Create random name prefix (for containers, networks, ...) +- name: Create random container name prefix + set_fact: + cname_prefix: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" + +- name: Make sure image is absent + community.docker.docker_image: + name: "{{ docker_test_image_alpine }}" + state: absent + +- name: Make sure image is pulled + community.docker.docker_image: + name: "{{ docker_test_image_alpine }}" + source: pull + +- name: Start container + community.docker.docker_container: + name: "{{ cname_prefix }}-1" + image: "{{ docker_test_image_alpine }}" + state: started + +- name: Remove container + community.docker.docker_container: + name: "{{ cname_prefix }}-1" + state: absent + stop_timeout: 1 + force_kill: true diff --git a/ansible_collections/community/docker/tests/ee/roles/docker_stack/tasks/main.yml b/ansible_collections/community/docker/tests/ee/roles/docker_stack/tasks/main.yml new file mode 100644 index 00000000..5d4d5698 --- /dev/null +++ b/ansible_collections/community/docker/tests/ee/roles/docker_stack/tasks/main.yml @@ -0,0 +1,6 @@ +--- +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +# Currently the docker_stack* modules are not supported in the EE since we'd need to install the Docker CLI client |