--- # tasks file for ensure_repo_epel - name: Include Variables when: ["ansible_facts[\"system\"] == 'Linux'"] ansible.builtin.include_vars: file: '{{ lookup("first_found", findme) }}' name: ensure_repo_epel vars: findme: files: - '{{ ansible_facts["distribution"] }}-{{ ansible_facts["distribution_major_version"] }}-{{ ansible_facts["architecture"] }}.yml' - '{{ ansible_facts["distribution"] }}-{{ ansible_facts["distribution_major_version"] }}-default.yml' - '{{ ansible_facts["distribution"] }}-default.yml' - '{{ ansible_facts["os_family"] }}-{{ ansible_facts["distribution_major_version"] }}-{{ ansible_facts["architecture"] }}.yml' - '{{ ansible_facts["os_family"] }}-{{ ansible_facts["distribution_major_version"] }}-default.yml' - '{{ ansible_facts["os_family"] }}-default.yml' - default.yml paths: [../vars/] errors: ignore - name: Package Discovery when: - ansible_facts["system"] == 'Linux' - ansible_facts["packages"] is not defined ansible.builtin.package_facts: - name: Service Discovery when: - ansible_facts["system"] == 'Linux' - ansible_facts["services"] is not defined ansible.builtin.service_facts: - name: Ensure Packages when: - ansible_facts["system"] == 'Linux' - ensure_repo_epel is defined - ensure_repo_epel.package_list is defined - ensure_repo_epel.package_list is iterable - ansible_facts.packages[item.name] is not defined ansible.builtin.package: disable_gpg_check: '{{ item.disable_gpg_check | default(omit) }}' name: '{{ item.url }}' state: '{{ item.state }}' loop: '{{ ensure_repo_epel.package_list }}' loop_control: label: '{{ item.name }} will be {{ item.state }}' notify: [Ensure_Repo_Epel.Package_Facts, Ensure_Repo_Epel.Service_Facts] - name: Ensure Services when: - ansible_facts["system"] == 'Linux' - ensure_repo_epel is defined - ensure_repo_epel.service_list is defined - ensure_repo_epel.service_list is iterable ansible.builtin.service: enabled: '{{ item.enabled }}' name: '{{ item.name }}' state: '{{ item.state }}' loop: '{{ ensure_repo_epel.service_list }}' loop_control: label: '{{ item.name }} will be {{ item.state }}' notify: [Ensure_Repo_Epel.Package_Facts, Ensure_Repo_Epel.Service_Facts] - name: Read Oracle EPEL Repo File when: - ansible_facts["system"] == 'Linux' - ansible_facts["distribution"] == 'OracleLinux' ansible.builtin.slurp: src: "/etc/yum.repos.d/oracle-epel-ol{{ ansible_facts['distribution_major_version'] }}.repo" register: oracle_epel_repo_file ignore_errors: true - name: Prioritize Oracle Epel Repo when: - ansible_facts["system"] == 'Linux' - ansible_facts["distribution"] == 'OracleLinux' - oracle_epel_repo_file.content is defined - (oracle_epel_repo_file.content | b64decode | community.general.from_ini).keys() | select('search', '_EPEL') | length > 0 community.general.ini_file: path: "/etc/yum.repos.d/oracle-epel-ol{{ ansible_facts['distribution_major_version'] }}.repo" section: "{{ (oracle_epel_repo_file.content | b64decode | community.general.from_ini).keys() | select('search', '_EPEL') | first }}" option: priority value: '1' no_extra_spaces: true mode: '0644' create: false - name: Deprioritize Upstream Epel Repo when: - ansible_facts["system"] == 'Linux' - ansible_facts["distribution"] == 'OracleLinux' community.general.ini_file: path: "/etc/yum.repos.d/epel.repo" section: epel option: priority value: '99' no_extra_spaces: true mode: '0644' create: false - name: Flush Handlers ansible.builtin.meta: flush_handlers