---

- name: Configure proxy for yum
  ini_file:
    path: /etc/yum.conf
    section: main
    option: proxy
    value: "{{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
    state: "{{ (system_proxy is defined and system_proxy != '') | ternary('present','absent') }}"
  tags: proxy

- name: Configure proxy for dnf
  ini_file:
    path: /etc/dnf/yum.conf
    section: main
    option: proxy
    value: "{{ (system_proxy is defined and system_proxy != '') | ternary(system_proxy,'') }}"
    state: "{{ (system_proxy is defined and system_proxy != '') | ternary('present','absent') }}"
  when: ansible_distribution_major_version is version('8', '>=')
  tags: proxy
