Roles only run on intended supported OS, and minor cleanup of when statements to match
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
---
|
||||
# tasks file for ensure_repo_epel
|
||||
- name: Assert Target OS Is Supported
|
||||
when:
|
||||
- ansible_facts["system"] is defined
|
||||
ansible.builtin.assert:
|
||||
fail_msg: "Unsupported OS: {{ ansible_facts['distribution'] | default('unknown') }}"
|
||||
quiet: true
|
||||
that:
|
||||
- ansible_facts["system"] == 'Linux'
|
||||
- >-
|
||||
ansible_facts["distribution"] in ['AlmaLinux', 'CentOS', 'Debian',
|
||||
'Fedora', 'OracleLinux', 'Rocky', 'Ubuntu']
|
||||
- name: Include Variables
|
||||
when: ["ansible_facts[\"system\"] == 'Linux'"]
|
||||
ansible.builtin.include_vars:
|
||||
file: '{{ lookup("first_found", findme) }}'
|
||||
name: ensure_repo_epel
|
||||
@@ -23,17 +33,14 @@
|
||||
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
|
||||
@@ -48,7 +55,6 @@
|
||||
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
|
||||
@@ -62,7 +68,6 @@
|
||||
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"
|
||||
@@ -71,7 +76,6 @@
|
||||
|
||||
- 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
|
||||
@@ -85,7 +89,6 @@
|
||||
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"
|
||||
@@ -97,3 +100,22 @@
|
||||
create: false
|
||||
- name: Flush Handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
- name: Post Verification Package Discovery
|
||||
when:
|
||||
- ensure_repo_epel is defined
|
||||
- ensure_repo_epel.package_list is defined
|
||||
- ensure_repo_epel.package_list is iterable
|
||||
ansible.builtin.package_facts:
|
||||
- name: Assert Managed Packages Are Installed
|
||||
when:
|
||||
- ensure_repo_epel is defined
|
||||
- ensure_repo_epel.package_list is defined
|
||||
- ensure_repo_epel.package_list is iterable
|
||||
ansible.builtin.assert:
|
||||
fail_msg: "Package {{ item.name }} is not installed"
|
||||
quiet: true
|
||||
that:
|
||||
- item.state != 'present' or ansible_facts['packages'][item.name] is defined
|
||||
loop: "{{ ensure_repo_epel.package_list }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }} will be verified"
|
||||
|
||||
Reference in New Issue
Block a user