refactor(roles): remove redundant post-task service and package assertions
Eliminate post-verification discovery and assert tasks (service_facts and package_facts) across all 19 roles and align AGENTS.md. Ansible's built-in declarative modules (package, service) already enforce target state natively and abort execution immediately on failure. The subsequent assertion loops were redundant, added significant runtime overhead, and produced false positives on non-service systemd units (.socket, .timer) and service aliases (e.g., dbus.socket failing under service_facts). - Remove service_facts and Assert Managed Services Are Active across 11 service roles (ensure_apache, ensure_cockpit, ensure_dbus, ensure_dovecot, ensure_fail2ban, ensure_firewalld, ensure_gitea, ensure_mariadb, ensure_podman, ensure_postfix, ensure_timezone). - Remove package_facts and Assert Managed Packages Are Installed across 8 package roles (ensure_ansible_prereq, ensure_git, ensure_os_patch, ensure_os_upgrade, ensure_repo_epel, ensure_repo_rpmfusion, ensure_rsync, ensure_vim). - Update AGENTS.md Section 8.2, Section 10, and Section 21 to codify declarative state enforcement and prohibit redundant post-task assertion loops.
This commit is contained in:
@@ -150,27 +150,3 @@
|
||||
notify: [Ensure_Postfix.Package_Facts, Ensure_Postfix.Service_Facts]
|
||||
- name: Flush Handlers
|
||||
ansible.builtin.meta: flush_handlers
|
||||
- name: Post Verification Service Discovery
|
||||
when:
|
||||
- ensure_postfix is defined
|
||||
- ensure_postfix.service_list is defined
|
||||
- ensure_postfix.service_list is iterable
|
||||
ansible.builtin.service_facts:
|
||||
- name: Assert Managed Services Are Active
|
||||
when:
|
||||
- ensure_postfix is defined
|
||||
- ensure_postfix.service_list is defined
|
||||
- ensure_postfix.service_list is iterable
|
||||
ansible.builtin.assert:
|
||||
fail_msg: "Service {{ item.name }} is not active"
|
||||
quiet: true
|
||||
that:
|
||||
- >-
|
||||
item.state != 'started' or
|
||||
(ansible_facts['services'][item.name ~ '.service'] is defined and
|
||||
ansible_facts['services'][item.name ~ '.service']['state'] == 'running') or
|
||||
(ansible_facts['services'][item.name] is defined and
|
||||
ansible_facts['services'][item.name]['state'] == 'running')
|
||||
loop: "{{ ensure_postfix.service_list }}"
|
||||
loop_control:
|
||||
label: "{{ item.name }} will be verified"
|
||||
|
||||
Reference in New Issue
Block a user