-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
main.yml
78 lines (64 loc) · 2.65 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
# tasks file for docker
- name: Set docker facts
openshift_facts:
role: common
local_facts:
deployment_type: "{{ openshift_deployment_type }}"
# Avoid docker 1.9 when installing origin < 1.2 or OSE < 3.2 on RHEL/Centos and
# See: https://bugzilla.redhat.com/show_bug.cgi?id=1304038
- name: Default to latest docker
set_fact:
docker_version: ''
docker_downgrade: False
- name: Gather installed version of common package
shell: >
rpm -q {{ openshift.common.service_type }} --queryformat '%{version}' | cut -d '.' -f1,2 | grep -v 'not installed'
register: installed_common_version
failed_when: false
changed_when: false
- name: Gather available version of common package
shell: >
yum list available -e 0 -q "{{ openshift.common.service_type}}" 2>&1 | tail -n +2 | awk '{ print $2 }' | sort -r | tr '\n' ' ' | tail -n 1 | cut -d '.' -f1,2
register: available_common_version
failed_when: false
changed_when: false
- name: Gather installed version of docker
shell: >
rpm -q docker --queryformat '%{version}' | cut -d '.' -f1,2 | grep -v 'not installed'
register: installed_docker_version
failed_when: false
changed_when: false
- name: Gather available version of docker
shell: >
yum list available -e 0 -q "docker" 2>&1 | tail -n +2 | awk '{ print $2 }' | sort -r | tr '\n' ' ' | tail -n 1
register: available_docker_version
failed_when: false
changed_when: false
- set_fact:
docker_version: "{{ '1.8.2' }}"
when: " installed_common_version.stdout in ['3.0','3.1','1.0','1.1'] or available_common_version.stdout in ['3.0','3.1','1.0','1.1']"
- set_fact:
docker_downgrade: True
when: " docker_version < installed_docker_version.stdout and docker_version != ''"
- name: Remove deferred removal and deletion for 1.8.2 downgrades
command: >
sed -i 's/--storage-opt dm.use_deferred_deletion=true//' /etc/sysconfig/docker-storage
when: docker_downgrade | bool and docker_version == '1.8.2'
- name: Downgrade docker
command: >
{{ ansible_pkg_mgr }} downgrade -y docker{{ '-' + docker_version if docker_version != '' else '' }}
when: not openshift.common.is_atomic and docker_downgrade | bool
- name: Install docker
action: "{{ ansible_pkg_mgr }} name=docker{{ '-' + docker_version if docker_version != '' else '' }} state=present"
when: not openshift.common.is_atomic | bool and not docker_downgrade | bool
- name: enable and start the docker service
service:
name: docker
enabled: yes
state: started
register: start_result
- set_fact:
docker_service_status_changed: start_result | changed
- include: udev_workaround.yml
when: docker_udev_workaround | default(False)