From 9007df7619e1d92bb72a0da9cd393fa600cc6e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bompard?= Date: Mon, 23 Jun 2025 10:27:03 +0200 Subject: [PATCH] Don't change the template name, or it will be the name of the remote file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Bompard --- roles/nagios_server/tasks/main.yml | 4 ++-- .../nagios_server/templates/nagios/hostgroups/all.cfg.iad2.j2 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/nagios_server/tasks/main.yml b/roles/nagios_server/tasks/main.yml index 27fbadd76b..ffa8898f27 100644 --- a/roles/nagios_server/tasks/main.yml +++ b/roles/nagios_server/tasks/main.yml @@ -498,10 +498,10 @@ - nagios_config notify: Restart nagios -- name: Build out nagios hostgroup templates (iad2) +- name: Build out nagios hostgroup templates ansible.builtin.template: src=nagios/hostgroups/{{item}}.j2 dest=/etc/nagios/hostgroups/{{item}} mode=0644 owner=root group=root with_items: - - "all.cfg.{{datacenter}}" + - all.cfg - vpnclients.cfg - nomail.cfg - checkswap.cfg diff --git a/roles/nagios_server/templates/nagios/hostgroups/all.cfg.iad2.j2 b/roles/nagios_server/templates/nagios/hostgroups/all.cfg.iad2.j2 index b66ca65e72..57d518e154 100644 --- a/roles/nagios_server/templates/nagios/hostgroups/all.cfg.iad2.j2 +++ b/roles/nagios_server/templates/nagios/hostgroups/all.cfg.iad2.j2 @@ -7,7 +7,7 @@ define hostgroup{ hostgroup_name {{ key }} alias {{ key }} -{%- for host in groups[key]|sort if hostvars[host].nagios_Can_Connect == true and hostvars[host].datacenter == 'iad2' %} +{%- for host in groups[key]|sort if hostvars[host].nagios_Can_Connect == true and '.iad2.' in hostvars[host].inventory_hostname %} {% if loop.first +%} members {{ host }}{% else %}, {{ host }}{% endif %} {% endfor +%}