blob: 687142ab0064ef4eb0fd836fee15249e794cd0d0 (
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
# SPDX-FileCopyrightText: 2021 Intel Corporation.
#
# SPDX-License-Identifier: Apache-2.0
---
- name: enable PowerTools repository on CentOS >= 8 and < 8.3
# noqa 303 - yum is called intenionallly here
command: yum config-manager --set-enabled PowerTools
when:
- ansible_distribution == "CentOS"
- ansible_distribution_version >= '8' and ansible_distribution_version < '8.3'
- name: enable powertools repository on CentOS >= 8.3
# noqa 303 - yum is called intenionallly here
command: yum config-manager --set-enabled powertools
when:
- ansible_distribution == "CentOS"
- ansible_distribution_version >= '8.3'
- name: enable CodeReady Linux Builder repository on RHEL 8
rhsm_repository:
name: codeready-builder-for-rhel-8-x86_64-rpms
when:
- ansible_distribution == "RedHat"
- ansible_distribution_version >= '8'
- name: install epel-release on CentOS
package:
name: epel-release
when:
- ansible_distribution == "CentOS"
- name: obtain EPEL GPG key on RHEL8
rpm_key:
state: present
key: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
when:
- ansible_distribution == "RedHat"
- ansible_distribution_version >= '8'
- name: install epel-release on RHEL8
package:
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
when:
- ansible_distribution == "RedHat"
- ansible_distribution_version >= '8'
- name: get full distribution versions
command: cat /etc/redhat-release
register: release
changed_when: true
- name: set full distribution version
set_fact:
full_dist_version: "{{ release.stdout | regex_replace('.*(\\d+.\\d+.\\d\\d\\d\\d).*', '\\1') }}"
- name: update CentOS Vault yum repository on CentOS 7
yum_repository:
name: C{{ full_dist_version }}-base
description: CentOS-{{ full_dist_version }} - Base
file: CentOS-Vault
baseurl: http://vault.centos.org/{{ full_dist_version }}/os/$basearch/
gpgcheck: yes
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-{{ ansible_distribution_major_version }}
enabled: yes
when:
- ansible_distribution == "CentOS"
- ansible_distribution_version < '7.9'
- not update_kernel
#- name: update CentOS Vault yum repository on CentOS 8
# yum_repository:
# name: C{{ full_dist_version }}-base
# description: CentOS-{{ full_dist_version }} - Base
# file: CentOS-Vault
# baseurl: http://vault.centos.org/{{ full_dist_version }}/BaseOS/$basearch/os/
# baseurl: http://vault.centos.org/{{ full_dist_version }}/BaseOS/Source/
# gpgcheck: yes
# gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
# enabled: yes
# when:
# - ansible_distribution == "CentOS"
# - ansible_distribution_version >= '8' and ansible_distribution_version < '8.3'
# - not update_kernel
# CentOS-Vault repo not working for CentOS 8, so install kernel headers directly
- name: pull matching kernel headers on CentOS 8.2
package:
name: "{{ item }}"
state: present
retries: 5
delay: 10
register: source_status
until: source_status is not failed
with_items:
- "https://vault.centos.org/8.2.2004/BaseOS/x86_64/os/Packages/kernel-headers-4.18.0-193.el8.x86_64.rpm"
- "https://vault.centos.org/8.2.2004/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-193.el8.x86_64.rpm"
when:
- ansible_distribution == "CentOS"
- ansible_distribution_version == '8.2'
- not update_kernel
- name: pull matching kernel headers on CentOS 8.3
package:
name: "{{ item }}"
state: present
register: source_status
with_items:
- "https://vault.centos.org/8.3.2011/BaseOS/x86_64/os/Packages/kernel-headers-4.18.0-240.el8.x86_64.rpm"
- "https://vault.centos.org/8.3.2011/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-240.el8.x86_64.rpm"
when:
- ansible_distribution == "CentOS"
- ansible_distribution_version == '8.3'
- not update_kernel
- name: pull matching kernel headers on CentOS 8.4
package:
name: "{{ item }}"
state: present
register: source_status
with_items:
- "http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-headers-4.18.0-305.3.1.el8.x86_64.rpm"
- "http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-305.3.1.el8.x86_64.rpm"
# - "https://vault.centos.org/8.4.2105/BaseOS/x86_64/os/Packages/kernel-headers-4.18.0-305.el8.x86_64.rpm"
# - "https://vault.centos.org/8.4.2105/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-305.el8.x86_64.rpm"
when:
- ansible_distribution == "CentOS"
- ansible_distribution_version == '8.4'
- not update_kernel
# pull the matching kernel headers if kernel is not updated
- name: pull matching kernel headers from configured repos
# noqa 503 - more than one condition, can't be a handler
package:
name:
- kernel-headers-{{ ansible_kernel }}
- kernel-devel-{{ ansible_kernel }}
register: kernel_source
retries: 3
until: kernel_source is success
when:
- not source_status.changed
- ansible_os_family == "RedHat"
- not update_kernel
- name: install the 'Development tools' package group
package:
name: "@Development tools"
when:
- ansible_os_family == "RedHat"
- name: install pip
package:
name: python-pip
when:
- ansible_distribution in ["RedHat", "CentOS"]
- ansible_distribution_version < '8'
- name: install pip
package:
name: python3-pip
when:
- ansible_distribution in ["RedHat", "CentOS"]
- ansible_distribution_version >= '8'
- name: update all packages
package:
name: '*'
state: latest # noqa 403
exclude: kernel*
when:
- ansible_os_family == "RedHat"
- update_all_packages | default(false)
- name: update to the latest kernel and kernel headers on the Red Hat OS family
package:
name:
- kernel
- kernel-devel
state: latest # noqa 403
notify:
- reboot server
when:
- ansible_os_family == "RedHat"
- update_kernel | default(false)
#note(przemeklal): fixes issue with missing selinux in packet.net CentOS 7 images
- name: ensure selinux is installed on CentOS/RHEL 7
package:
name:
- policycoreutils
- policycoreutils-python
- selinux-policy
- selinux-policy-targeted
- libselinux-utils
- setools
- setools-console
- shtool
- lshw
state: present
when:
- ansible_distribution in ["RedHat", "CentOS"]
- ansible_distribution_version < '8'
# Workaround for Equinix Metal CentOS 7
- name: set selinux to permissive
lineinfile:
path: "/etc/sysconfig/selinux"
regexp: '^SELINUX=enforcing'
line: 'SELINUX=permissive'
when:
- ansible_distribution in ["RedHat", "CentOS"]
- ansible_distribution_version < '8'
- name: set python is python3
alternatives:
name: python
path: /usr/bin/python3
link: /usr/bin/python
when:
- ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
- ansible_distribution_version >= '8'
- name: install command line tools to collect hardware details
package:
name:
- hwinfo
- inxi
- jq
state: present
when: ansible_distribution in ["RedHat", "CentOS"]
- name: Add kubic yum repo and install updated version of podman
block:
- name: disable container-tools module
# noqa 305 - shell is used intentionally here
shell: dnf -y module disable container-tools
- name: enable rhcontainerbot/container-selinux repository
# noqa 305 - shell is used intentionally here
shell: dnf -y copr enable rhcontainerbot/container-selinux
- name: Add kubic yum repo
yum_repository:
name: devel_kubic_libcontainers_stable
description: Stable Releases of Upstream github.com/containers packages (CentOS_$releasever)
baseurl: https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_$releasever/
gpgcheck: yes
gpgkey: https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_$releasever/repodata/repomd.xml.key
keepcache: '0'
- name: install runc
dnf:
name: runc
state: present
- name: install podman package
package:
name: podman
state: present
when:
- ansible_os_family == "RedHat" and ansible_distribution_version >= '8.2'
- '"docker" not in container_runtime'
# SELINUX will be disabled later stage so, these packages are required when container_runtime is docker
- name: install packages in RHEL >= 8.4 when container_runtime is docker
dnf:
name:
- bridge-utils
- lsof
- lvm2
- tcpdump
- iproute-tc
- openssh-server
- chrony
- iputils
when:
- ansible_distribution == "RedHat" and ansible_distribution_version >= '8.4'
- container_runtime == "docker"
# Workaround - Set pip to a version that supports correct version of packages needed
- name: use the correct pip version for CentOS 7
pip:
name:
- pip==9.0.3
when:
- ansible_distribution == "CentOS"
- ansible_distribution_version < '7.9'
- name: Install pip3 required by dpdk
yum:
name: python3-pip
state: latest
when:
- ansible_distribution == "CentOS"
- ansible_distribution_version < '7.9'
|