Roles only run on intended supported OS, and minor cleanup of when statements to match

This commit is contained in:
2026-09-01 22:01:59 -05:00
parent d38a19c9b5
commit a81059d4e4
26 changed files with 720 additions and 200 deletions
@@ -2,7 +2,6 @@
# tasks file for ensure_os_upgrade - Debian
- name: Update sources.list for Debian Upgrade
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["os_family"] == 'Debian'
- ensure_os_upgrade is defined
- ensure_os_upgrade.target_codename is defined
@@ -14,7 +13,6 @@
- name: Safe Upgrade Debian Packages
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["os_family"] == 'Debian'
- ensure_os_upgrade is defined
- ensure_os_upgrade.target_codename is defined
@@ -27,7 +25,6 @@
- name: Full Upgrade Debian Packages
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["os_family"] == 'Debian'
- ensure_os_upgrade is defined
- ensure_os_upgrade.target_codename is defined
@@ -41,7 +38,6 @@
- name: Reboot Debian After Upgrade
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["os_family"] == 'Debian'
- ensure_os_upgrade is defined
- ensure_os_upgrade.target_codename is defined
@@ -2,7 +2,6 @@
# tasks file for ensure_os_upgrade - Fedora
- name: Ensure System-upgrade Download
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["distribution"] == 'Fedora'
- ensure_os_upgrade is defined
- ensure_os_upgrade.package_list is defined
@@ -13,7 +12,6 @@
dnf -y system-upgrade download --refresh --releasever={{ ensure_os_upgrade.target_version | int }}
- name: Ensure System-upgrade Reboot
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["distribution"] == 'Fedora'
- ensure_os_upgrade is defined
- ensure_os_upgrade.package_list is defined
@@ -26,7 +24,6 @@
sleep 5 && dnf -y system-upgrade reboot
- name: Wait For The Reboot
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["distribution"] == 'Fedora'
- ensure_os_upgrade is defined
- ensure_os_upgrade.package_list is defined
@@ -2,7 +2,6 @@
# tasks file for ensure_os_upgrade - Ubuntu
- name: Ensure update-manager-core is installed
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["distribution"] == 'Ubuntu'
- ensure_os_upgrade is defined
ansible.builtin.apt:
@@ -11,7 +10,6 @@
- name: Configure Ubuntu Release Upgrade Prompt
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["distribution"] == 'Ubuntu'
- ensure_os_upgrade is defined
- ensure_os_upgrade.target_version is defined
@@ -22,7 +20,6 @@
- name: Execute Ubuntu Release Upgrade
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["distribution"] == 'Ubuntu'
- ensure_os_upgrade is defined
- ensure_os_upgrade.target_version is defined
@@ -34,7 +31,6 @@
- name: Reboot Ubuntu After Upgrade
when:
- ansible_facts["system"] == 'Linux'
- ansible_facts["distribution"] == 'Ubuntu'
- ensure_os_upgrade is defined
- ensure_os_upgrade.target_version is defined
+30 -6
View File
@@ -1,7 +1,17 @@
---
# tasks file for ensure_os_upgrade
- 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_os_upgrade
@@ -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_os_upgrade is defined
- ensure_os_upgrade.package_list is defined
- ensure_os_upgrade.package_list is iterable
@@ -48,7 +55,6 @@
- Ensure_Os_Upgrade.Service_Facts
- name: Ensure Services
when:
- ansible_facts["system"] == 'Linux'
- ensure_os_upgrade is defined
- ensure_os_upgrade.service_list is defined
- ensure_os_upgrade.service_list is iterable
@@ -63,7 +69,6 @@
- Ensure_Os_Upgrade.Package_Facts
- Ensure_Os_Upgrade.Service_Facts
- name: Include Vendor / Version Specific Tasks
when: ["ansible_facts[\"system\"] == 'Linux'"]
ansible.builtin.include_tasks:
file: '{{ lookup("first_found", findme) }}'
vars:
@@ -88,3 +93,22 @@
- Ensure_Os_Upgrade.Service_Facts
- name: Flush Handlers
ansible.builtin.meta: flush_handlers
- name: Post Verification Package Discovery
when:
- ensure_os_upgrade is defined
- ensure_os_upgrade.package_list is defined
- ensure_os_upgrade.package_list is iterable
ansible.builtin.package_facts:
- name: Assert Managed Packages Are Installed
when:
- ensure_os_upgrade is defined
- ensure_os_upgrade.package_list is defined
- ensure_os_upgrade.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_os_upgrade.package_list }}"
loop_control:
label: "{{ item.name }} will be verified"