@ -1,25 +1,35 @@
- 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' }}"
is_ubuntu14 : "{{ ansible_distribution == 'Ubuntu' and ansible_distribution_major_version == '14' }}"
- name : Setup Docker
when : ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6']
block:
- include_tasks : "{{ lookup('first_found', params) }}"
- name : Include distribution specific variables
include_vars : "{{ lookup('first_found', params) }}"
vars:
params:
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'
when : not is_rhel6
files:
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.distribution }}.yml"
- "{{ ansible_facts.os_family }}.yml"
- default.yml
paths:
- vars
- name : Install Python requirements
- name : Include distribution specific tasks
include_tasks : "{{ lookup('first_found', params) }}"
vars:
# Inttalling 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.
# Not sure why RHEL7 needs this specific version
extra_packages : "{{ '' if not (is_rhel7 or is_ubuntu14) else ',requests==2.6.0' }}"
params:
files:
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.distribution }}.yml"
- "{{ ansible_facts.os_family }}.yml"
paths:
- tasks
- name : Install Python requirements
pip:
state : present
name : 'docker{{ extra_packages }}'
name : "{{ docker_pip_packages | union(docker_pip_extra_packages) }}"
extra_args : "-c {{ role_path }}/../../../runner/requirements/constraints.txt"
# Detect docker CLI, API and docker-py versions
@ -39,9 +49,9 @@
ignore_errors : yes
- set_fact:
docker_cli_version : "{{ ( docker_cli_version_stdout.stdout | default('0.0')) or '0.0' }}"
docker_api_version : "{{ docker_api_version_stdout.stdout or '0.0' }}"
docker_py_version : "{{ docker_py_version_stdout.stdout or '0.0' }}"
docker_cli_version : "{{ docker_cli_version_stdout.stdout | default('0.0') }}"
docker_api_version : "{{ docker_api_version_stdout.stdout | default('0.0') }}"
docker_py_version : "{{ docker_py_version_stdout.stdout | default('0.0') }}"
- debug:
msg : "Docker CLI version: {{ docker_cli_version }}; Docker API version: {{ docker_api_version }}; docker-py library version: {{ docker_py_version }}"
@ -51,12 +61,15 @@
- name : "Remove all ansible-test-* docker containers"
shell : 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %} | grep "^ansible-test-" | xargs -r docker rm -f'
register : docker_containers
- name : "Remove all ansible-test-* docker volumes"
shell : 'docker volume ls --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-test-" | xargs -r docker volume rm -f'
register : docker_volumes
- name : "Remove all ansible-test-* docker networks"
shell : 'docker network ls --no-trunc --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-test-" | xargs -r docker network rm'
register : docker_networks
- name : Cleaned docker resources
debug:
var : docker_resources
@ -70,15 +83,19 @@
- name : List all docker containers
command : docker ps --no-trunc -a
register : docker_containers
- name : List all docker volumes
command : docker volume ls
register : docker_volumes
- name : List all docker networks
command : docker network ls --no-trunc
register : docker_networks
- name : List all docker images
command : docker images --no-trunc -a
register : docker_images
- name : Still existing docker resources
debug:
var : docker_resources