Skip to content

Commit

Permalink
Improve tests: don't install daemon when running inside a container (#56
Browse files Browse the repository at this point in the history
)

* If running inside a container, only install docker CLI, not docker daemon.

ci_complete

* Fix OpenSUSE.
  • Loading branch information
felixfontein authored Dec 23, 2020
1 parent a1a7692 commit 5fa53e2
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 12 deletions.
3 changes: 3 additions & 0 deletions tests/integration/targets/setup_docker/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
---
docker_cli_version: '0.0'
docker_api_version: '0.0'
docker_py_version: '0.0'
docker_skip_cleanup: yes
docker_prereq_packages: []
docker_packages:
- docker-ce
docker_cli_packages:
- docker-ce-cli

docker_pip_extra_packages: []
docker_pip_package: docker
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/setup_docker/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

- name: Install Docker CE
apt:
name: '{{ docker_packages }}'
name: '{{ docker_packages if needs_docker_daemon else docker_cli_packages }}'
state: present
update_cache: true

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/setup_docker/tasks/Fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

- name: Install docker
dnf:
name: "{{ docker_packages }}"
name: "{{ docker_packages if needs_docker_daemon else docker_cli_packages }}"
state: present
enablerepo: docker-ce-test
notify: cleanup docker
3 changes: 2 additions & 1 deletion tests/integration/targets/setup_docker/tasks/RedHat-7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

- name: Install docker
yum:
name: "{{ docker_packages }}"
name: "{{ docker_packages if needs_docker_daemon else docker_cli_packages }}"
state: present
notify: cleanup docker

Expand All @@ -43,3 +43,4 @@
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
when: needs_docker_daemon
3 changes: 2 additions & 1 deletion tests/integration/targets/setup_docker/tasks/RedHat-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

- name: Install docker
dnf:
name: "{{ docker_packages }}"
name: "{{ docker_packages if needs_docker_daemon else docker_cli_packages }}"
state: present
notify: cleanup docker

Expand All @@ -32,3 +32,4 @@
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
when: needs_docker_daemon
2 changes: 1 addition & 1 deletion tests/integration/targets/setup_docker/tasks/Suse.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Install docker 17
community.general.zypper:
name: "{{ docker_packages }}"
name: "{{ docker_packages if needs_docker_daemon else docker_cli_packages }}"
force: yes
disable_gpg_check: yes
update_cache: yes
Expand Down
10 changes: 7 additions & 3 deletions tests/integration/targets/setup_docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
- name: Setup Docker
when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6']
block:
- name: Detect whether we are running inside a container
current_container_facts:

- name: Determine whether Docker Daemon needs to be installed
set_fact:
needs_docker_daemon: '{{ not ansible_module_running_in_container }}'

- name: Include distribution specific variables
include_vars: "{{ lookup('first_found', params) }}"
vars:
Expand Down Expand Up @@ -136,9 +143,6 @@

when: docker_cli_version is version('0.0', '>')

- name: Detect whether we are running inside a container
current_container_facts:

- name: Inspect current container
docker_container_info:
name: "{{ ansible_module_container_id }}"
Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/setup_docker/vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
docker_prereq_packages:
- apt-transport-https
- ca-certificates
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/targets/setup_docker/vars/Fedora.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
docker_prereq_packages: []

docker_packages:
- docker-ce
---
1 change: 1 addition & 0 deletions tests/integration/targets/setup_docker/vars/RedHat-7.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
docker_prereq_packages:
- yum-utils
- device-mapper-persistent-data
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/targets/setup_docker/vars/RedHat-8.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
docker_prereq_packages:
- yum-utils
- device-mapper-persistent-data
Expand All @@ -7,3 +8,5 @@ docker_prereq_packages:
docker_packages:
- docker-ce-19.03.13
- docker-ce-cli-19.03.13
docker_cli_packages:
- docker-ce-cli-19.03.13
6 changes: 6 additions & 0 deletions tests/integration/targets/setup_docker/vars/Suse.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
---
docker_packages:
- docker>=17

# OpenSUSE 15 does not seem to have docker-client (https://software.opensuse.org/package/docker-client)
# or any other Docker CLI-only package
docker_cli_packages:
- docker>=17
1 change: 1 addition & 0 deletions tests/integration/targets/setup_docker/vars/Ubuntu-14.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
docker_pip_extra_packages:
# Installing requests >=2.12.0 on Ubuntu 14.04 breaks certificate validation. We restrict to an older version
# to ensure out get_url tests work out fine. This is only an issue if pyOpenSSL is also installed.
Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/setup_docker/vars/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---

0 comments on commit 5fa53e2

Please sign in to comment.