2016-12-07 16:16:06 +00:00
|
|
|
---
|
2020-06-12 08:59:56 +00:00
|
|
|
- name: Gather host facts to get ansible_distribution_version ansible_distribution_major_version
|
|
|
|
setup:
|
|
|
|
gather_subset: '!all'
|
|
|
|
filter: ansible_distribution_*version
|
|
|
|
|
2021-01-07 18:50:53 +00:00
|
|
|
- name: Add proxy to yum.conf or dnf.conf if http_proxy is defined
|
|
|
|
ini_file:
|
|
|
|
path: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('/etc/yum.conf','/etc/dnf/dnf.conf') }}"
|
|
|
|
section: main
|
|
|
|
option: proxy
|
|
|
|
value: "{{ http_proxy | default(omit) }}"
|
|
|
|
state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
|
|
|
|
no_extra_spaces: true
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2021-01-07 18:50:53 +00:00
|
|
|
become: true
|
|
|
|
when: not skip_http_proxy_on_os_packages
|
|
|
|
|
2020-03-14 13:28:34 +00:00
|
|
|
# For Oracle Linux install public repo
|
|
|
|
- name: Download Oracle Linux public yum repo
|
|
|
|
get_url:
|
|
|
|
url: https://yum.oracle.com/public-yum-ol7.repo
|
|
|
|
dest: /etc/yum.repos.d/public-yum-ol7.repo
|
|
|
|
when:
|
|
|
|
- use_oracle_public_repo|default(true)
|
2021-02-11 16:14:16 +00:00
|
|
|
- '''ID="ol"'' in os_release.stdout_lines'
|
2020-06-12 08:59:56 +00:00
|
|
|
- (ansible_distribution_version | float) < 7.6
|
2021-01-11 15:21:08 +00:00
|
|
|
environment: "{{ proxy_env }}"
|
2020-03-14 13:28:34 +00:00
|
|
|
|
|
|
|
- name: Enable Oracle Linux repo
|
|
|
|
ini_file:
|
|
|
|
dest: /etc/yum.repos.d/public-yum-ol7.repo
|
|
|
|
section: "{{ item }}"
|
|
|
|
option: enabled
|
|
|
|
value: "1"
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2020-03-14 13:28:34 +00:00
|
|
|
with_items:
|
|
|
|
- ol7_latest
|
|
|
|
- ol7_addons
|
|
|
|
- ol7_developer_EPEL
|
|
|
|
when:
|
|
|
|
- use_oracle_public_repo|default(true)
|
2021-02-11 16:14:16 +00:00
|
|
|
- '''ID="ol"'' in os_release.stdout_lines'
|
2020-06-12 08:59:56 +00:00
|
|
|
- (ansible_distribution_version | float) < 7.6
|
|
|
|
|
2021-05-25 15:30:23 +00:00
|
|
|
- name: Install EPEL for Oracle Linux repo package
|
|
|
|
package:
|
|
|
|
name: "oracle-epel-release-el{{ ansible_distribution_major_version }}"
|
|
|
|
state: present
|
|
|
|
when:
|
|
|
|
- use_oracle_public_repo|default(true)
|
|
|
|
- '''ID="ol"'' in os_release.stdout_lines'
|
|
|
|
- (ansible_distribution_version | float) >= 7.6
|
|
|
|
|
2020-06-12 08:59:56 +00:00
|
|
|
- name: Enable Oracle Linux repo
|
|
|
|
ini_file:
|
|
|
|
dest: "/etc/yum.repos.d/oracle-linux-ol{{ ansible_distribution_major_version }}.repo"
|
2020-09-07 08:15:41 +00:00
|
|
|
section: "ol{{ ansible_distribution_major_version }}_addons"
|
|
|
|
option: "{{ item.option }}"
|
|
|
|
value: "{{ item.value }}"
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2020-06-12 08:59:56 +00:00
|
|
|
with_items:
|
2021-05-25 15:30:23 +00:00
|
|
|
- { option: "name", value: "ol{{ ansible_distribution_major_version }}_addons" }
|
2020-09-07 08:15:41 +00:00
|
|
|
- { option: "enabled", value: "1" }
|
2021-07-09 01:52:53 +00:00
|
|
|
- { option: "baseurl", value: "http://yum.oracle.com/repo/OracleLinux/OL{{ ansible_distribution_major_version }}/addons/$basearch/" }
|
|
|
|
when:
|
|
|
|
- use_oracle_public_repo|default(true)
|
|
|
|
- '''ID="ol"'' in os_release.stdout_lines'
|
|
|
|
- (ansible_distribution_version | float) >= 7.6
|
|
|
|
|
2021-07-19 13:18:55 +00:00
|
|
|
- name: Enable Centos extra repo for Oracle Linux
|
2021-07-09 01:52:53 +00:00
|
|
|
ini_file:
|
|
|
|
dest: "/etc/yum.repos.d/centos-extras.repo"
|
|
|
|
section: "extras"
|
|
|
|
option: "{{ item.option }}"
|
|
|
|
value: "{{ item.value }}"
|
2021-09-10 06:35:59 +00:00
|
|
|
mode: 0644
|
2021-07-09 01:52:53 +00:00
|
|
|
with_items:
|
|
|
|
- { option: "name", value: "CentOS-{{ ansible_distribution_major_version }} - Extras" }
|
|
|
|
- { option: "enabled", value: "1" }
|
|
|
|
- { option: "gpgcheck", value: "0" }
|
2021-11-29 21:39:21 +00:00
|
|
|
- { option: "baseurl", value: "http://mirror.centos.org/centos/{{ ansible_distribution_major_version }}/extras/$basearch/{% if ansible_distribution_major_version|int > 7 %}os/{% endif %}" }
|
2020-06-12 08:59:56 +00:00
|
|
|
when:
|
2021-01-29 11:59:41 +00:00
|
|
|
- use_oracle_public_repo|default(true)
|
2021-02-11 16:14:16 +00:00
|
|
|
- '''ID="ol"'' in os_release.stdout_lines'
|
2020-06-12 08:59:56 +00:00
|
|
|
- (ansible_distribution_version | float) >= 7.6
|
2020-03-14 13:28:34 +00:00
|
|
|
|
2019-04-23 22:46:02 +00:00
|
|
|
# CentOS ships with python installed
|
|
|
|
|
2016-12-07 16:16:06 +00:00
|
|
|
- name: Check presence of fastestmirror.conf
|
2017-02-17 21:22:34 +00:00
|
|
|
stat:
|
|
|
|
path: /etc/yum/pluginconf.d/fastestmirror.conf
|
2021-02-10 13:36:59 +00:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2016-12-07 16:16:06 +00:00
|
|
|
register: fastestmirror
|
|
|
|
|
2019-04-23 22:46:02 +00:00
|
|
|
# the fastestmirror plugin can actually slow down Ansible deployments
|
|
|
|
- name: Disable fastestmirror plugin if requested
|
2016-12-07 16:16:06 +00:00
|
|
|
lineinfile:
|
|
|
|
dest: /etc/yum/pluginconf.d/fastestmirror.conf
|
|
|
|
regexp: "^enabled=.*"
|
|
|
|
line: "enabled=0"
|
|
|
|
state: present
|
2019-02-11 22:04:27 +00:00
|
|
|
become: true
|
2019-04-23 22:46:02 +00:00
|
|
|
when:
|
|
|
|
- fastestmirror.stat.exists
|
|
|
|
- not centos_fastestmirror_enabled
|
2017-04-20 16:17:01 +00:00
|
|
|
|
2019-04-23 22:46:02 +00:00
|
|
|
# libselinux-python is required on SELinux enabled hosts
|
|
|
|
# See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#managed-node-requirements
|
2019-08-28 09:33:15 +00:00
|
|
|
- name: Install libselinux python package
|
2019-04-23 22:46:02 +00:00
|
|
|
package:
|
2019-12-09 09:37:10 +00:00
|
|
|
name: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('libselinux-python','python3-libselinux') }}"
|
2017-10-14 08:52:40 +00:00
|
|
|
state: present
|
2019-02-11 22:04:27 +00:00
|
|
|
become: true
|