Docker integration tests: factorize setup (#42306)
* Factorize docker_secret & docker_swarm tests setup * failure are only expected inside docker container * docker_swarm: enable RHEL builds
This commit is contained in:
parent
b851321b65
commit
0f2d67b87f
17 changed files with 27 additions and 132 deletions
3
test/integration/targets/docker_secret/meta/main.yml
Normal file
3
test/integration/targets/docker_secret/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- setup_docker
|
|
@ -1,14 +1,2 @@
|
|||
- include: RedHat.yml
|
||||
when: ansible_os_family == 'RedHat' and ansible_distribution != 'Fedora' and ansible_distribution_major_version != '6'
|
||||
|
||||
- include: Fedora.yml
|
||||
when: ansible_distribution == 'Fedora'
|
||||
|
||||
- include: OpenSuse.yml
|
||||
when: ansible_os_family == 'Suse'
|
||||
|
||||
- include: Ubuntu.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include: test_secrets.yml
|
||||
- include_tasks: test_secrets.yml
|
||||
when: ansible_os_family != 'RedHat' or ansible_distribution_major_version != '6'
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
- name: Install Python requirements
|
||||
pip:
|
||||
state: present
|
||||
name: "{{ item }}"
|
||||
with_items:
|
||||
- docker==2.1.0
|
||||
|
||||
- name: Check if already in swarm
|
||||
shell: docker node ls 2>&1 | grep 'docker swarm init'
|
||||
register: output
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
shippable/posix/group2
|
||||
skip/osx
|
||||
skip/freebsd
|
||||
skip/rhel
|
||||
destructive
|
||||
|
|
3
test/integration/targets/docker_swarm/meta/main.yml
Normal file
3
test/integration/targets/docker_swarm/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- setup_docker
|
|
@ -1,18 +0,0 @@
|
|||
- name: Install Docker pre-reqs
|
||||
dnf:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop:
|
||||
- dnf-plugins-core
|
||||
|
||||
- name: Add repository
|
||||
command: dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
|
||||
|
||||
- name: Update cache
|
||||
command: dnf makecache
|
||||
|
||||
- name: Install docker
|
||||
dnf:
|
||||
name: docker-ce
|
||||
state: present
|
||||
enablerepo: docker-ce-test
|
|
@ -1,11 +0,0 @@
|
|||
- name: Template repo
|
||||
template:
|
||||
src: virt.repo.j2
|
||||
dest: /etc/zypp/repos.d/virt.repo
|
||||
|
||||
- name: Install docker 17
|
||||
zypper:
|
||||
name: docker>=17
|
||||
force: yes
|
||||
disable_gpg_check: yes
|
||||
update_cache: yes
|
|
@ -1,57 +0,0 @@
|
|||
- name: Get OS version
|
||||
shell: uname -r
|
||||
register: os_version
|
||||
|
||||
- name: Install packages for Trusty
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
with_items:
|
||||
- "linux-image-extra-{{ os_version.stdout }}"
|
||||
- linux-image-extra-virtual
|
||||
when: ansible_distribution_release == 'trusty'
|
||||
|
||||
- name: Install pre-reqs
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
with_items:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- software-properties-common
|
||||
|
||||
- name: Add gpg key
|
||||
shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg >key && apt-key add key
|
||||
|
||||
- name: Add Docker repo
|
||||
shell: add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||
|
||||
- block:
|
||||
- name: Prevent service restart
|
||||
copy:
|
||||
content: exit 101
|
||||
dest: /usr/sbin/policy-rc.d
|
||||
backup: yes
|
||||
mode: 0755
|
||||
register: policy_rc_d
|
||||
|
||||
- name: Install Docker CE
|
||||
apt:
|
||||
name: docker-ce
|
||||
state: present
|
||||
update_cache: yes
|
||||
always:
|
||||
- name: Restore /usr/sbin/policy-rc.d (if needed)
|
||||
command: mv {{ policy_rc_d.backup_file }} /usr/sbin/policy-rc.d
|
||||
when:
|
||||
- "'backup_file' in policy_rc_d"
|
||||
|
||||
- name: Remove /usr/sbin/policy-rc.d (if needed)
|
||||
file:
|
||||
path: /usr/sbin/policy-rc.d
|
||||
state: absent
|
||||
when:
|
||||
- "'backup_file' not in policy_rc_d"
|
|
@ -1,11 +1,2 @@
|
|||
- include: Fedora.yml
|
||||
when: ansible_distribution == 'Fedora'
|
||||
|
||||
- include: OpenSuse.yml
|
||||
when: ansible_os_family == 'Suse'
|
||||
|
||||
- include: Ubuntu.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include: test_swarm.yml
|
||||
- include_tasks: test_swarm.yml
|
||||
when: ansible_os_family != 'RedHat' or ansible_distribution_major_version != '6'
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
- name: Install Python requirements
|
||||
pip:
|
||||
state: present
|
||||
name: "{{ item }}"
|
||||
with_items:
|
||||
- docker==2.7.0
|
||||
|
||||
- name: Test parameters with state=present
|
||||
docker_swarm:
|
||||
state: present
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
[Virtualization_containers]
|
||||
name=Virtualization:containers (openSUSE_Leap_{{ ansible_distribution_version }})
|
||||
type=rpm-md
|
||||
baseurl=http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_{{ ansible_distribution_version }}/
|
||||
gpgcheck=1
|
||||
gpgkey=http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_{{ ansible_distribution_version }}/repodata/repomd.xml.key
|
||||
enabled=1
|
|
@ -33,4 +33,4 @@
|
|||
service:
|
||||
name: docker
|
||||
state: started
|
||||
ignore_errors: yes
|
||||
ignore_errors: "{{ ansible_virtualization_type == 'docker' }}"
|
18
test/integration/targets/setup_docker/tasks/main.yml
Normal file
18
test/integration/targets/setup_docker/tasks/main.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
- vars:
|
||||
is_rhel: "{{ ansible_os_family == 'RedHat' and ansible_distribution != 'Fedora' }}"
|
||||
is_rhel6: "{{ is_rhel and ansible_distribution_major_version == '6' }}"
|
||||
is_rhel7: "{{ is_rhel and ansible_distribution_major_version == '7' }}"
|
||||
block:
|
||||
- include_tasks: "{{ lookup('first_found', params) }}"
|
||||
vars:
|
||||
params:
|
||||
- '{{ ansible_distribution }}.yml'
|
||||
- '{{ ansible_os_family }}.yml'
|
||||
when: not is_rhel6
|
||||
|
||||
- name: Install Python requirements
|
||||
vars:
|
||||
extra_packages: "{{ '' if not is_rhel7 else ',requests==2.6.0' }}"
|
||||
pip:
|
||||
state: present
|
||||
name: 'docker{{ extra_packages }}'
|
Loading…
Reference in a new issue