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
+23 -6
View File
@@ -1,7 +1,17 @@
---
# tasks file for ensure_log_rotation
- 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_log_rotation
@@ -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_log_rotation is defined
- ensure_log_rotation.package_list is defined
- ensure_log_rotation.package_list is iterable
@@ -48,7 +55,6 @@
- Ensure_Log_Rotation.Service_Facts
- name: Ensure Configuration
when:
- ansible_facts["system"] == 'Linux'
- ensure_log_rotation is defined
- ensure_log_rotation.template_list is defined
- ensure_log_rotation.template_list is iterable
@@ -77,7 +83,6 @@
- Ensure_Log_Rotation.Service_Restart
- name: Ensure Services
when:
- ansible_facts["system"] == 'Linux'
- ensure_log_rotation is defined
- ensure_log_rotation.service_list is defined
- ensure_log_rotation.service_list is iterable
@@ -93,3 +98,15 @@
- Ensure_Log_Rotation.Service_Facts
- name: Flush Handlers
ansible.builtin.meta: flush_handlers
- name: Assert Logrotate Configuration
ansible.builtin.stat:
path: /etc/logrotate.conf
register: _logrotate_stat
- name: Assert Logrotate File Exists
when:
- _logrotate_stat.stat is defined
ansible.builtin.assert:
fail_msg: "/etc/logrotate.conf does not exist"
quiet: true
that:
- _logrotate_stat.stat.exists