Zabbix: Make agent service handler global

We have some hosts that do not include the zabbix_agent role which means
they cannot find the restart handler for things like the postfix
monitoring - and even then the restart would fail because the agent
service doesn't exist

This adds a global handler that is allowed to fail if the service is
missing, but otherwise should fail normally for other problems

This can probably be changed once we have zabbix everywhere...

Signed-off-by: Greg Sutcliffe <fedora@emeraldreverie.org>
This commit is contained in:
Greg Sutcliffe 2025-10-02 13:25:12 +01:00
commit 4d0a89d1fd
Signed by: gwmngilfen
SSH key fingerprint: SHA256:dNHcz65ApR68w2TkCIAXDBdt4oNL62Fyx48U7dXWuk0
2 changed files with 11 additions and 3 deletions

View file

@ -185,3 +185,14 @@
- name: Restart debuginfod
service: name=debuginfod state=restarted
# This is allowed to fail when the zabbix agent is not found
# as it may be triggered from hosts without the zabbix_agent role
- name: Restart zabbix agent
ansible.builtin.systemd:
name: zabbix-agent
state: restarted
register: zabbix_restart
failed_when:
- zabbix_restart.failed
- "'Could not find' not in zabbix_restart.msg"

View file

@ -1,7 +1,4 @@
---
- name: Restart zabbix agent
service: name=zabbix-agent state=restarted
- name: Reload custom selinux files
ansible.builtin.shell: /usr/sbin/semodule -u "/etc/selinux/centos/centos-zabbix-agent.pp"
when: ansible_selinux.mode == "enforcing"