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.
This commit is contained in:
Denis Kadyshev
2020-04-09 15:25:44 +07:00
committed by GitHub
parent 01b9b263ed
commit 7d1ab3374e
3 changed files with 12 additions and 11 deletions

View File

@@ -42,15 +42,14 @@
- not centos_fastestmirror_enabled
- name: Add proxy to /etc/yum.conf if http_proxy is defined
lineinfile:
ini_file:
path: "/etc/yum.conf"
regexp: "^proxy=.*$"
line: "proxy={{ http_proxy }}"
create: true
state: present
section: main
option: proxy
value: "{{ http_proxy | default(omit) }}"
state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
no_extra_spaces: true
become: true
when:
- http_proxy is defined
- name: Gather host facts to get ansible_distribution_major_version
setup: