2016-12-08 00:16:06 +08:00
|
|
|
---
|
2020-06-12 16:59:56 +08:00
|
|
|
- name: Gather host facts to get ansible_distribution_version ansible_distribution_major_version
|
|
|
|
setup:
|
|
|
|
gather_subset: '!all'
|
|
|
|
filter: ansible_distribution_*version
|
|
|
|
|
2021-01-08 02:50:53 +08: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 15:00:47 +08:00
|
|
|
mode: 0644
|
2021-01-08 02:50:53 +08:00
|
|
|
become: true
|
|
|
|
when: not skip_http_proxy_on_os_packages
|
|
|
|
|
2020-03-14 21:28:34 +08: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-12 00:14:16 +08:00
|
|
|
- '''ID="ol"'' in os_release.stdout_lines'
|
2020-06-12 16:59:56 +08:00
|
|
|
- (ansible_distribution_version | float) < 7.6
|
2021-01-11 23:21:08 +08:00
|
|
|
environment: "{{ proxy_env }}"
|
2020-03-14 21:28:34 +08: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 15:00:47 +08:00
|
|
|
mode: 0644
|
2020-03-14 21:28:34 +08:00
|
|
|
with_items:
|
|
|
|
- ol7_latest
|
|
|
|
- ol7_addons
|
|
|
|
- ol7_developer_EPEL
|
|
|
|
when:
|
|
|
|
- use_oracle_public_repo|default(true)
|
2021-02-12 00:14:16 +08:00
|
|
|
- '''ID="ol"'' in os_release.stdout_lines'
|
2020-06-12 16:59:56 +08:00
|
|
|
- (ansible_distribution_version | float) < 7.6
|
|
|
|
|
2021-05-25 23:30:23 +08: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 16:59:56 +08:00
|
|
|
- name: Enable Oracle Linux repo
|
|
|
|
ini_file:
|
|
|
|
dest: "/etc/yum.repos.d/oracle-linux-ol{{ ansible_distribution_major_version }}.repo"
|
2020-09-07 16:15:41 +08:00
|
|
|
section: "ol{{ ansible_distribution_major_version }}_addons"
|
|
|
|
option: "{{ item.option }}"
|
|
|
|
value: "{{ item.value }}"
|
2021-07-12 15:00:47 +08:00
|
|
|
mode: 0644
|
2020-06-12 16:59:56 +08:00
|
|
|
with_items:
|
2021-05-25 23:30:23 +08:00
|
|
|
- { option: "name", value: "ol{{ ansible_distribution_major_version }}_addons" }
|
2020-09-07 16:15:41 +08:00
|
|
|
- { option: "enabled", value: "1" }
|
2021-07-09 09:52:53 +08: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 21:18:55 +08:00
|
|
|
- name: Enable Centos extra repo for Oracle Linux
|
2021-07-09 09:52:53 +08:00
|
|
|
ini_file:
|
|
|
|
dest: "/etc/yum.repos.d/centos-extras.repo"
|
|
|
|
section: "extras"
|
|
|
|
option: "{{ item.option }}"
|
|
|
|
value: "{{ item.value }}"
|
|
|
|
with_items:
|
|
|
|
- { option: "name", value: "CentOS-{{ ansible_distribution_major_version }} - Extras" }
|
|
|
|
- { option: "enabled", value: "1" }
|
|
|
|
- { option: "gpgcheck", value: "0" }
|
|
|
|
- { option: "baseurl", value: "http://mirror.centos.org/centos/{{ ansible_distribution_major_version }}/extras/$basearch/" }
|
2020-06-12 16:59:56 +08:00
|
|
|
when:
|
2021-01-29 19:59:41 +08:00
|
|
|
- use_oracle_public_repo|default(true)
|
2021-02-12 00:14:16 +08:00
|
|
|
- '''ID="ol"'' in os_release.stdout_lines'
|
2020-06-12 16:59:56 +08:00
|
|
|
- (ansible_distribution_version | float) >= 7.6
|
2020-03-14 21:28:34 +08:00
|
|
|
|
2019-04-24 06:46:02 +08:00
|
|
|
# CentOS ships with python installed
|
|
|
|
|
2016-12-08 00:16:06 +08:00
|
|
|
- name: Check presence of fastestmirror.conf
|
2017-02-18 05:22:34 +08:00
|
|
|
stat:
|
|
|
|
path: /etc/yum/pluginconf.d/fastestmirror.conf
|
2021-02-10 21:36:59 +08:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2016-12-08 00:16:06 +08:00
|
|
|
register: fastestmirror
|
|
|
|
|
2019-04-24 06:46:02 +08:00
|
|
|
# the fastestmirror plugin can actually slow down Ansible deployments
|
|
|
|
- name: Disable fastestmirror plugin if requested
|
2016-12-08 00:16:06 +08:00
|
|
|
lineinfile:
|
|
|
|
dest: /etc/yum/pluginconf.d/fastestmirror.conf
|
|
|
|
regexp: "^enabled=.*"
|
|
|
|
line: "enabled=0"
|
|
|
|
state: present
|
2019-02-12 06:04:27 +08:00
|
|
|
become: true
|
2019-04-24 06:46:02 +08:00
|
|
|
when:
|
|
|
|
- fastestmirror.stat.exists
|
|
|
|
- not centos_fastestmirror_enabled
|
2017-04-21 00:17:01 +08:00
|
|
|
|
2019-04-24 06:46:02 +08: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 17:33:15 +08:00
|
|
|
- name: Install libselinux python package
|
2019-04-24 06:46:02 +08:00
|
|
|
package:
|
2019-12-09 17:37:10 +08:00
|
|
|
name: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('libselinux-python','python3-libselinux') }}"
|
2017-10-14 16:52:40 +08:00
|
|
|
state: present
|
2019-02-12 06:04:27 +08:00
|
|
|
become: true
|