-
Notifications
You must be signed in to change notification settings - Fork 37
/
install-docker-rhel.yaml
105 lines (97 loc) · 3.31 KB
/
install-docker-rhel.yaml
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
#
# Install docker and then start and enable it.
#
# NOTE: As of ICP v2.1.0.2 on RHEL it is required that Docker
# available in Passport Advantage (or) eXtreme Leverage is used.
# The install package is an executable binary.
# It has a pre-req that may not be installed already: policycoreutils-python
#
# NOTE: This playbook assumes the Docker install executable is located
# in /root/docker and named icp-docker-install.bin of the localhost when the
# script is run.
#
# NOTE: Check the name of the docker install executable. It is hard-wired
# in the script below.
#
# NOTE: Ubuntu uses overlay2 by default. Centos and RHEL do not. The storage driver
# is explicitly included on the ExecStart line of the docker.service file for clarity.
#
# NOTE: The MountFlags=shared is also explicitly included in the docker.service file
# for clarity. It could be left out all together.
#
# INPUTS:
# vars:
# target_nodes - a regex string or group name that defines the hosts or
# host group.
#
# You can define the vars on the ansible-playbook command line using --extra-vars.
# Or define vars in your hosts inventory or any of the other ways to define
# Ansible variables.
# The --inventory option can be used to provide a path to an inventory file
# on the ansible-playbook command line.
#
# Root privilege is needed to run this configuration script.
# The tasks where root is needed use the "become" option.
#
# Sample invocation:
# ansible-playbook install-docker.yaml --extra-vars "target_nodes=worker0*"
#
# The above invocation assumes the ansible hosts file has nodes with
# names that start with worker0, e.g., worker01, worker02, ...
#
#
- hosts: "{{ target_nodes }}"
tasks:
- name: "Create destination directory for Docker install executable"
file:
path: /root/docker
state: directory
owner: root
group: root
become: True
- name: "Copy Docker executable to host"
copy:
src: /root/docker/icp-install-docker.bin
dest: /root/docker/icp-install-docker.bin
mode: u=rx,g=rx,o=rx
become: True
- name: "Install Docker"
shell: ./icp-install-docker.bin --install
args:
chdir: /root/docker
creates: /usr/bin/docker
become: True
- name: "Configure the logging options"
lineinfile:
dest: /lib/systemd/system/docker.service
backrefs: True
regexp: '^(ExecStart=/usr/bin/dockerd(?!.*[ \t]--log-opt max-size=10m --log-opt max-file=10[ \t\n]).*)$'
line: '\1 --log-opt max-size=10m --log-opt max-file=10'
state: present
become: True
- name: "Use overlay2 storage driver"
lineinfile:
dest: /lib/systemd/system/docker.service
backrefs: True
regexp: '^(ExecStart=/usr/bin/dockerd(?!.*[ \t]--storage-driver=overlay2[ \t\n]).*)$'
line: '\1 --storage-driver=overlay2'
state: present
become: True
- name: "Set MountFlags=shared"
lineinfile:
dest: /lib/systemd/system/docker.service
line: MountFlags=shared
insertafter: StartLimitInterval=*
state: present
become: True
- name: "Do a systemd daemon-reload to reload of changes to docker service file"
systemd:
daemon-reload: yes
become: True
- name: "Start and enable Docker service"
service:
name: docker
state: started
enabled: yes
become: True