7d1ab3374e
* Fix proxy and module_hotfixes On CentOS 8 with proxy ansible render inline `proxy` and `module_hotfixes` options. For example: `proxy=http://127.0.0.1:3128module_hotfixes=True` But expected result: ``` proxy=http://127.0.0.1:3128 module_hotfixes=True ``` * Use ini_file module for work with ini files * Prevent duplicates proxy= option in /etc/yum.conf Module `lineinfile` is weak, use most powerful module `ini_file` and add or remove `proxy=` when `http_proxy` is defined or not.
65 lines
1.9 KiB
YAML
65 lines
1.9 KiB
YAML
---
|
|
# 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)
|
|
- '"Oracle" in os_release.stdout'
|
|
|
|
- name: Enable Oracle Linux repo
|
|
ini_file:
|
|
dest: /etc/yum.repos.d/public-yum-ol7.repo
|
|
section: "{{ item }}"
|
|
option: enabled
|
|
value: "1"
|
|
with_items:
|
|
- ol7_latest
|
|
- ol7_addons
|
|
- ol7_developer_EPEL
|
|
when:
|
|
- use_oracle_public_repo|default(true)
|
|
- '"Oracle" in os_release.stdout'
|
|
|
|
# CentOS ships with python installed
|
|
|
|
- name: Check presence of fastestmirror.conf
|
|
stat:
|
|
path: /etc/yum/pluginconf.d/fastestmirror.conf
|
|
register: fastestmirror
|
|
|
|
# the fastestmirror plugin can actually slow down Ansible deployments
|
|
- name: Disable fastestmirror plugin if requested
|
|
lineinfile:
|
|
dest: /etc/yum/pluginconf.d/fastestmirror.conf
|
|
regexp: "^enabled=.*"
|
|
line: "enabled=0"
|
|
state: present
|
|
become: true
|
|
when:
|
|
- fastestmirror.stat.exists
|
|
- not centos_fastestmirror_enabled
|
|
|
|
- name: Add proxy to /etc/yum.conf if http_proxy is defined
|
|
ini_file:
|
|
path: "/etc/yum.conf"
|
|
section: main
|
|
option: proxy
|
|
value: "{{ http_proxy | default(omit) }}"
|
|
state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
|
|
no_extra_spaces: true
|
|
become: true
|
|
|
|
- name: Gather host facts to get ansible_distribution_major_version
|
|
setup:
|
|
gather_subset: '!all'
|
|
filter: ansible_distribution_major_version
|
|
|
|
# libselinux-python is required on SELinux enabled hosts
|
|
# See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#managed-node-requirements
|
|
- name: Install libselinux python package
|
|
package:
|
|
name: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('libselinux-python','python3-libselinux') }}"
|
|
state: present
|
|
become: true
|