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:
Pilou 2018-08-09 19:37:03 +02:00 committed by Matt Clay
commit 0f2d67b87f
17 changed files with 27 additions and 132 deletions

View file

@ -0,0 +1,57 @@
- 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"

View file

@ -0,0 +1,18 @@
- 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

View file

@ -0,0 +1,36 @@
# The RHEL extras repository must be enabled to provide the container-selinux package.
# See: https://docs.docker.com/engine/installation/linux/docker-ee/rhel/#install-using-the-repository
- name: Install Docker pre-reqs
yum:
name: "{{ item }}"
state: present
loop:
- yum-utils
- device-mapper-persistent-data
- lvm2
- libseccomp
- name: Install epel repo which is missing on rhel-7 and is needed for pigz (needed for docker-ce 18)
yum:
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- name: Enable extras repository for RHEL on AWS
command: yum-config-manager --enable rhui-REGION-rhel-server-extras
- name: Add repository
command: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- name: Update cache
command: yum -y makecache fast
- name: Install docker
yum:
name: docker-ce
state: present
- name: Make sure the docker daemon is running (failure expected inside docker container)
service:
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type == 'docker' }}"

View file

@ -0,0 +1,11 @@
- 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

View 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 }}'

View file

@ -0,0 +1,7 @@
[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