blob: 7fbe412e3e3999834fa0e119314d457aa1b473c8 (
plain)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
---
- hosts: all
vars_files:
- ../vars/zuul.yml
tasks:
- name: Create dir for kolla logs
file:
path: "{{ kolla_logs_dir }}"
state: directory
- name: Dump host info to logs
command: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tools/dump_info.sh"
args:
chdir: "{{ kolla_logs_dir }}"
- name: Create dir for kolla build logs
file:
path: "{{ kolla_build_logs_dir }}"
state: directory
# On RAX hosts, we have a small root partition and a large,
# unallocated ephemeral device attached at /dev/xvde
- name: Set ephemeral device if /dev/xvde exists
when: ansible_devices["xvde"] is defined
set_fact:
ephemeral_device: "/dev/xvde"
# On other providers, we have a device called "ephemeral0".
- name: Set ephemeral device by label
when: ephemeral_device is undefined
block:
- name: Get ephemeral0 device node
command: /sbin/blkid -L ephemeral0
register: ephemeral0
# rc !=0 is expected
failed_when: False
changed_when: False
- name: Set ephemeral device if LABEL exists
when: "ephemeral0.rc == 0"
set_fact:
ephemeral_device: "{{ ephemeral0.stdout }}"
- name: Configure additional disk (if available)
become: true
when: ephemeral_device is defined
block:
- name: Ensure ephemeral device is unmounted
ansible.posix.mount:
name: "{{ ephemeral_device }}"
state: "{{ item }}"
loop:
- unmounted
- absent
- name: Get existing partitions
community.general.parted:
device: "{{ ephemeral_device }}"
unit: MiB
state: info
register: ephemeral_partitions
- name: Remove any existing partitions
community.general.parted:
device: "{{ ephemeral_device }}"
number: "{{ item.num }}"
state: absent
loop: "{{ ephemeral_partitions.partitions }}"
- name: Create filesystem on additional partition
community.general.filesystem:
fstype: ext4
dev: "{{ ephemeral_device }}"
opts: "-L kolla"
- name: Ensure /var/lib/docker mountpoint is created
ansible.builtin.file:
path: "/var/lib/docker"
owner: root
group: root
state: directory
mode: 0755
- name: Mount additional filesystem
ansible.posix.mount:
path: "/var/lib/docker"
src: "LABEL=kolla"
fstype: ext4
state: mounted
- name: Install Python3 pip and setuptools
package:
name:
- python3-pip
- python3-setuptools
become: true
# NOTE(hrw): On RedHat systems venv is part of python3-libs
- name: Install Python3 venv on Debian systems
package:
name:
- python3-venv
become: true
when:
ansible_os_family == "Debian"
- name: Create virtualenv
command: python3 -m venv {{ virtualenv_path }}
- name: Install kolla
command: "{{ virtualenv_path }}/bin/python -m pip install {{ zuul.project.src_dir }}"
- name: Install podman python library
command: "{{ virtualenv_path }}/bin/python -m pip install podman"
when: container_engine == "podman"
- name: Configure Docker repo for Debian/Ubuntu
block:
- name: Add key for Docker APT repository
apt_key:
url: "{{ nodepool_docker_proxy }}/{{ ansible_distribution | lower }}/gpg"
state: present
- name: Add Docker APT repository
apt_repository:
repo: "deb {{ nodepool_docker_proxy }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: present
- name: Ensure AppArmor is installed
package:
name: apparmor
state: present
when:
- ansible_os_family == "Debian"
- container_engine == "docker"
become: true
- name: Configure Docker repo for CentOS
block:
- name: Add Docker repository
yum_repository:
name: docker
description: Docker
baseurl: "{{ nodepool_docker_proxy }}/centos/9/$basearch/stable"
enabled: yes
gpgcheck: yes
gpgkey: "{{ nodepool_docker_proxy }}/centos/gpg"
# module_hotfixes: True # enabled below (dnf, not yum, feature)
- name: Enable module_hotfixes in Docker YUM repository
lineinfile:
path: /etc/yum.repos.d/docker.repo
line: 'module_hotfixes=True'
when:
- ansible_os_family == "RedHat"
- container_engine == "docker"
become: true
- name: Configure docker
block:
- name: Ensure /etc/docker exists
become: true
file:
path: /etc/docker
state: directory
mode: 0755
- name: Configure registry-mirror in daemon.json
become: true
copy:
dest: /etc/docker/daemon.json
content: |
{
"registry-mirrors": [
"http://{{ zuul_site_mirror_fqdn }}:8082/"
]
}
# NOTE(yoctozepto): We configure Docker before installing it because Debuntu starts services
# during installation.
- name: Install Docker
package:
name: docker-ce
become: true
- name: Ensure Docker service is started
service:
name: docker
state: started
become: true
- name: Ensure Docker socket is world-writable
file:
path: /run/docker.sock
mode: 0666
become: true
when:
- container_engine == "docker"
- name: Configure podman
block:
- name: Ensure /etc/containers exists
become: true
file:
path: /etc/containers
state: directory
mode: 0755
- name: Configure registries.conf
become: true
copy:
dest: /etc/containers/registries.conf
content: |
unqualified-search-registries = ['docker.io']
[[registry]]
prefix = "docker.io"
location = "docker.io"
[[registry.mirror]]
prefix = "docker.io"
location = "{{ zuul_site_mirror_fqdn }}:8082"
- name: Install Podman
package:
name: podman
become: true
# NOTE(jangutter): It appears that the default mount option
# in the shipped `/etc/containers/storage.conf` for EL9 based distros
# (Rocky, CentOS Stream, ...) has severe performance implications for
# Kolla builds. This is because enabling `metacopy=on` disables `Native
# Overlay Diff` This can be removed if the config is dropped from those
# distros, or the underlying incompatibility can somehow be addressed.
# Debian based distros do not ship `storage.conf` and seem
# to be unaffected.
- name: Remove metacopy, enable native overlay diff
ini_file:
path: /etc/containers/storage.conf
section: storage.options.overlay
option: mountopt
value: '"nodev"'
become: true
when: ansible_os_family == "RedHat"
- name: Ensure Podman service is started
service:
name: podman
state: started
become: true
- name: Ensure Podman socket is world-writable
file:
path: /run/podman/podman.sock
mode: 0666
become: true
when:
- container_engine == "podman"
|