From 51e673ca94c794aa555353f22bedc45c5572dcb1 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Mon, 11 Mar 2024 18:23:42 +0100 Subject: [PATCH] icinga_agent: [WIP] --- roles/icinga_agent/handlers/main.yml | 10 ++++++++++ roles/icinga_agent/tasks/main.yml | 12 ++++++++++++ roles/icinga_agent/templates/hosts.agent.j2 | 3 +++ 3 files changed, 25 insertions(+) create mode 100644 roles/icinga_agent/handlers/main.yml create mode 100644 roles/icinga_agent/templates/hosts.agent.j2 diff --git a/roles/icinga_agent/handlers/main.yml b/roles/icinga_agent/handlers/main.yml new file mode 100644 index 0000000..4462113 --- /dev/null +++ b/roles/icinga_agent/handlers/main.yml @@ -0,0 +1,10 @@ +--- + +- name: Run acertmgr + command: /usr/bin/acertmgr + +- name: Restart icinga2 + service: name=icinga2 state=restarted + +- name: Restart nginx + service: name=nginx state=restarted diff --git a/roles/icinga_agent/tasks/main.yml b/roles/icinga_agent/tasks/main.yml index 283024a..f21a0fa 100644 --- a/roles/icinga_agent/tasks/main.yml +++ b/roles/icinga_agent/tasks/main.yml @@ -57,6 +57,18 @@ - --accept-config when: not cert_file.stat.exists +- name: Set agent address on master + template: src=hosts.agent.j2 dest=/etc/icinga2/conf.d/hosts/{{ inventory_hostname }}.01_agent owner={{ icinga_user }} group={{ icinga_group }} + delegate_to: "{{ icinga_server }}" + +- name: Regenerate hosts.conf + assemble: + src: /etc/icinga2/conf.d/hosts + dest: /etc/icinga2/conf.d/hosts.conf +# validate: /usr/sbin/icinga2 daemon -c %s --validate + notify: Restart icinga2 + delegate_to: "{{ icinga_server }}" + # TODO expand this to cover more than just the root partition - name: Monitor disks include_role: name=icinga-monitor tasks_from=disk diff --git a/roles/icinga_agent/templates/hosts.agent.j2 b/roles/icinga_agent/templates/hosts.agent.j2 new file mode 100644 index 0000000..81dcdf5 --- /dev/null +++ b/roles/icinga_agent/templates/hosts.agent.j2 @@ -0,0 +1,3 @@ + + /* Set custom variable `agent_endpoint` for use in `services.conf`. */ + vars.agent_endpoint = "{{ inventory_hostname }}"