mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
Add EE support, support GHA in current_container_facts (#336)
* Try adding EE support. * Use GHA instead of AZP for EE tests. * Update changelog fragment, extend tests. * Disable current_container_facts test. * Increase verbosity. * 2.9 compatibility. * Use docker instead of podman for building EE and running tests in it. * Output some more information (helpful for debugging). * Fix GHA handling for current_container_facts. * Try to fix permissions.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
- 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 }}"
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
- 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 != ''
|
||||
@@ -0,0 +1,34 @@
|
||||
---
|
||||
# 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: Create project and container names
|
||||
set_fact:
|
||||
pname: "{{ cname_prefix }}"
|
||||
cname: "{{ cname_prefix }}-hi"
|
||||
|
||||
- name: Define service
|
||||
set_fact:
|
||||
test_service: |
|
||||
version: '3'
|
||||
services:
|
||||
{{ cname }}:
|
||||
image: "{{ docker_test_image_alpine }}"
|
||||
command: '/bin/sh -c "sleep 10m"'
|
||||
stop_grace_period: 1s
|
||||
|
||||
- name: Present
|
||||
community.docker.docker_compose:
|
||||
project_name: "{{ pname }}"
|
||||
state: present
|
||||
remove_orphans: true
|
||||
definition: "{{ test_service | from_yaml }}"
|
||||
|
||||
- name: Absent
|
||||
community.docker.docker_compose:
|
||||
project_name: "{{ pname }}"
|
||||
state: absent
|
||||
remove_orphans: true
|
||||
definition: "{{ test_service | from_yaml }}"
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
# 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: yes
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# Currently the docker_stack* modules are not supported in the EE since we'd need to install the Docker CLI client
|
||||
@@ -4,4 +4,5 @@
|
||||
.azure-pipelines/scripts/publish-codecov.py compile-3.5!skip # Uses Python 3.6+ syntax
|
||||
.azure-pipelines/scripts/publish-codecov.py future-import-boilerplate
|
||||
.azure-pipelines/scripts/publish-codecov.py metaclass-boilerplate
|
||||
plugins/modules/current_container_facts.py validate-modules:return-syntax-error
|
||||
plugins/modules/docker_container.py use-argspec-type-path # uses colon-separated paths, can't use type=path
|
||||
|
||||
@@ -4,4 +4,5 @@
|
||||
.azure-pipelines/scripts/publish-codecov.py compile-3.5!skip # Uses Python 3.6+ syntax
|
||||
.azure-pipelines/scripts/publish-codecov.py future-import-boilerplate
|
||||
.azure-pipelines/scripts/publish-codecov.py metaclass-boilerplate
|
||||
plugins/modules/current_container_facts.py validate-modules:return-syntax-error
|
||||
plugins/modules/docker_container.py use-argspec-type-path # uses colon-separated paths, can't use type=path
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
.azure-pipelines/scripts/publish-codecov.py replace-urlopen
|
||||
plugins/modules/current_container_facts.py validate-modules:return-syntax-error
|
||||
plugins/modules/docker_container.py use-argspec-type-path # uses colon-separated paths, can't use type=path
|
||||
|
||||
@@ -15,7 +15,7 @@ function join {
|
||||
}
|
||||
|
||||
# Ensure we can write other collections to this dir
|
||||
sudo chown "$(whoami)" "${PWD}/../../"
|
||||
sudo chown -R "$(whoami)" "${PWD}/../../../"
|
||||
|
||||
test="$(join / "${args[@]:1}")"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user