Proxy fixes (#5869)
* 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.pull/5929/head
parent
01b9b263ed
commit
7d1ab3374e
|
@ -42,15 +42,14 @@
|
||||||
- not centos_fastestmirror_enabled
|
- not centos_fastestmirror_enabled
|
||||||
|
|
||||||
- name: Add proxy to /etc/yum.conf if http_proxy is defined
|
- name: Add proxy to /etc/yum.conf if http_proxy is defined
|
||||||
lineinfile:
|
ini_file:
|
||||||
path: "/etc/yum.conf"
|
path: "/etc/yum.conf"
|
||||||
regexp: "^proxy=.*$"
|
section: main
|
||||||
line: "proxy={{ http_proxy }}"
|
option: proxy
|
||||||
create: true
|
value: "{{ http_proxy | default(omit) }}"
|
||||||
state: present
|
state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
|
||||||
|
no_extra_spaces: true
|
||||||
become: true
|
become: true
|
||||||
when:
|
|
||||||
- http_proxy is defined
|
|
||||||
|
|
||||||
- name: Gather host facts to get ansible_distribution_major_version
|
- name: Gather host facts to get ansible_distribution_major_version
|
||||||
setup:
|
setup:
|
||||||
|
|
|
@ -136,11 +136,12 @@
|
||||||
when: ansible_distribution in ["CentOS","RedHat","OracleLinux"] and not is_ostree
|
when: ansible_distribution in ["CentOS","RedHat","OracleLinux"] and not is_ostree
|
||||||
|
|
||||||
- name: Edit copy of yum.conf to set obsoletes=0
|
- name: Edit copy of yum.conf to set obsoletes=0
|
||||||
lineinfile:
|
ini_file:
|
||||||
path: "{{ docker_yum_conf }}"
|
path: "{{ docker_yum_conf }}"
|
||||||
state: present
|
section: main
|
||||||
regexp: '^obsoletes='
|
option: obsoletes
|
||||||
line: 'obsoletes=0'
|
value: "0"
|
||||||
|
no_extra_spaces: true
|
||||||
when: ansible_distribution in ["CentOS","RedHat","OracleLinux"] and not is_ostree
|
when: ansible_distribution in ["CentOS","RedHat","OracleLinux"] and not is_ostree
|
||||||
|
|
||||||
- name: ensure docker packages are installed
|
- name: ensure docker packages are installed
|
||||||
|
|
|
@ -6,4 +6,5 @@ gpgcheck={{ '1' if docker_rh_repo_gpgkey else '0' }}
|
||||||
keepcache={{ docker_rpm_keepcache | default('1') }}
|
keepcache={{ docker_rpm_keepcache | default('1') }}
|
||||||
gpgkey={{ docker_rh_repo_gpgkey }}
|
gpgkey={{ docker_rh_repo_gpgkey }}
|
||||||
{% if http_proxy is defined %}proxy={{ http_proxy }}{% endif %}
|
{% if http_proxy is defined %}proxy={{ http_proxy }}{% endif %}
|
||||||
|
|
||||||
{% if ansible_os_family == "RedHat" and ansible_distribution_major_version|int == 8 %}module_hotfixes=True{% endif %}
|
{% if ansible_os_family == "RedHat" and ansible_distribution_major_version|int == 8 %}module_hotfixes=True{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue