Update BMRA to v21.03
[kuberef.git] / sw_config / bmra / patched_rhel_packages.yml
1 ##
2 ##   Copyright (c) 2020-2021 Intel Corporation.
3 ##
4 ##   Licensed under the Apache License, Version 2.0 (the "License");
5 ##   you may not use this file except in compliance with the License.
6 ##   You may obtain a copy of the License at
7 ##
8 ##       http://www.apache.org/licenses/LICENSE-2.0
9 ##
10 ##   Unless required by applicable law or agreed to in writing, software
11 ##   distributed under the License is distributed on an "AS IS" BASIS,
12 ##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ##   See the License for the specific language governing permissions and
14 ##   limitations under the License.
15 ##
16 ---
17 - name: enable PowerTools repository on CentOS >= 8 and < 8.3
18 # noqa 303 - yum is called intenionallly here
19   command: yum config-manager --set-enabled PowerTools
20   when:
21     - ansible_distribution == "CentOS"
22     - ansible_distribution_version >= '8' and ansible_distribution_version < '8.3'
23
24 - name: enable PowerTools repository on CentOS >= 8.3
25 # noqa 303 - yum is called intenionallly here
26   command: yum config-manager --set-enabled powertools
27   when:
28     - ansible_distribution == "CentOS"
29     - ansible_distribution_version >= '8.3'
30
31 - name: enable CodeReady Linux Builder repository on RHEL 8
32   rhsm_repository:
33     name: codeready-builder-for-rhel-8-x86_64-rpms
34   when:
35     - ansible_distribution == "RedHat"
36     - ansible_distribution_version >= '8'
37
38 - name: install epel-release on CentOS
39   package:
40     name: epel-release
41   when:
42     - ansible_distribution == "CentOS"
43
44 - name: obtain EPEL GPG key on RHEL8
45   rpm_key:
46     state: present
47     key: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
48   when:
49     - ansible_distribution == "RedHat"
50     - ansible_distribution_version >= '8'
51
52 - name: install epel-release on RHEL8
53   package:
54     name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
55   when:
56     - ansible_distribution == "RedHat"
57     - ansible_distribution_version >= '8'
58
59 - name: get full distribution versions
60   command: cat /etc/redhat-release
61   register: release
62   changed_when: true
63
64 - name: set full distribution version
65   set_fact:
66     full_dist_version: "{{ release.stdout | regex_replace('.*(\\d+.\\d+.\\d\\d\\d\\d).*', '\\1') }}"
67
68 - name: update CentOS Vault yum repository on CentOS 7
69   yum_repository:
70     name: C{{ full_dist_version }}-base
71     description: CentOS-{{ full_dist_version }} - Base
72     file: CentOS-Vault
73     baseurl: http://vault.centos.org/{{ full_dist_version }}/os/$basearch/
74     gpgcheck: yes
75     gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-{{ ansible_distribution_major_version }}
76     enabled: yes
77   when:
78     - ansible_distribution == "CentOS"
79     - ansible_distribution_version < '7.9'
80     - not update_kernel
81
82 #- name: update CentOS Vault yum repository on CentOS 8
83 #  yum_repository:
84 #    name: C{{ full_dist_version }}-base
85 #    description: CentOS-{{ full_dist_version }} - Base
86 #    file: CentOS-Vault
87 #    baseurl: http://vault.centos.org/{{ full_dist_version }}/BaseOS/$basearch/os/
88 #    baseurl: http://vault.centos.org/{{ full_dist_version }}/BaseOS/Source/
89 #    gpgcheck: yes
90 #    gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
91 #    enabled: yes
92 #  when:
93 #    - ansible_distribution == "CentOS"
94 #    - ansible_distribution_version >= '8' and ansible_distribution_version < '8.3'
95 #    - not update_kernel
96
97 # CentOS-Vault repo not working for CentOS 8, so install kernel headers directly
98 - name: pull matching kernel headers on CentOS 8.2
99   package:
100     name: "{{ item }}"
101     state: present
102   register: source_status
103   with_items:
104     - "https://vault.centos.org/8.2.2004/BaseOS/x86_64/os/Packages/kernel-headers-4.18.0-193.el8.x86_64.rpm"
105     - "https://vault.centos.org/8.2.2004/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-193.el8.x86_64.rpm"
106   when:
107     - ansible_distribution == "CentOS"
108     - ansible_distribution_version == '8.2'
109     - not update_kernel
110
111 - name: pull matching kernel headers on CentOS 8.3
112   package:
113     name: "{{ item }}"
114     state: present
115   register: source_status
116   with_items:
117     - "http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-headers-4.18.0-240.el8.x86_64.rpm"
118     - "http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-240.el8.x86_64.rpm"
119 #    - "https://vault.centos.org/8.3.2011/BaseOS/x86_64/os/Packages/kernel-headers-4.18.0-240.el8.x86_64.rpm"
120 #    - "https://vault.centos.org/8.3.2011/BaseOS/x86_64/os/Packages/kernel-devel-4.18.0-240.el8.x86_64.rpm"
121   when:
122     - ansible_distribution == "CentOS"
123     - ansible_distribution_version == '8.3'
124     - not update_kernel
125
126 # pull the matching kernel headers if kernel is not updated
127 - name: pull matching kernel headers from configured repos
128 # noqa 503 - more than one condition, can't be a handler
129   package:
130     name:
131     - kernel-headers-{{ ansible_kernel }}
132     - kernel-devel-{{ ansible_kernel }}
133   register: kernel_source
134   retries: 3
135   until: kernel_source is success
136   when:
137     - not source_status.changed
138     - ansible_os_family == "RedHat"
139     - not update_kernel
140
141 - name: install the 'Development tools' package group
142   package:
143     name: "@Development tools"
144   when:
145     - ansible_os_family == "RedHat"
146
147 - name: install pip
148   package:
149     name: python-pip
150   when:
151     - ansible_distribution in ["RedHat", "CentOS"]
152     - ansible_distribution_version < '8'
153
154 - name: install pip
155   package:
156     name: python3-pip
157   when:
158     - ansible_distribution in ["RedHat", "CentOS"]
159     - ansible_distribution_version >= '8'
160
161 - name: update all packages
162   package:
163     name: '*'
164     state: latest # noqa 403
165     exclude: kernel*
166   when:
167     - ansible_os_family == "RedHat"
168     - update_all_packages | default(false)
169
170 - name: update to the latest kernel and kernel headers on the Red Hat OS family
171   package:
172     name:
173     - kernel
174     - kernel-devel
175     state: latest # noqa 403
176   notify:
177     - reboot server
178   when:
179     - ansible_os_family == "RedHat"
180     - update_kernel | default(false)
181
182 #note(przemeklal): fixes issue with missing selinux in packet.net CentOS 7 images
183 - name: ensure selinux is installed on CentOS/RHEL 7
184   package:
185     name:
186     - policycoreutils
187     - policycoreutils-python
188     - selinux-policy
189     - selinux-policy-targeted
190     - libselinux-utils
191     - setools
192     - setools-console
193     - shtool
194     - lshw
195     state: present
196   when:
197     - ansible_distribution in ["RedHat", "CentOS"]
198     - ansible_distribution_version < '8'
199
200 # Workaround for Equinix Metal CentOS 7
201 - name: set selinux to permissive
202   lineinfile:
203     path: "/etc/sysconfig/selinux"
204     regexp: '^SELINUX=enforcing'
205     line: 'SELINUX=permissive'
206   when:
207     - ansible_distribution in ["RedHat", "CentOS"]
208     - ansible_distribution_version < '8'
209
210 - name: Set python is python3
211   alternatives:
212     name: python
213     path: /usr/bin/python3
214     link: /usr/bin/python
215   when:
216     - ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
217     - ansible_distribution_version >= '8'
218
219 - name: install command line tools to collect hardware details
220   package:
221     name:
222      - hwinfo
223      - inxi
224      - jq
225     state: present
226   when: ansible_distribution in ["RedHat", "CentOS"]