nagios: do not rely on ansible_hostname defined for the ipv6 checks

Changing the `host_name` - it was a "fake" non-DNS address anyway
Specify aliases only if ansible_hostname is stated in cached facts,
see https://pagure.io/fedora-infrastructure/issue/11264
This commit is contained in:
Pavel Raiskup 2023-04-26 08:21:24 +02:00
parent 33ccc11860
commit 5adeb88890

View file

@ -1,12 +1,15 @@
## This template currently only works for noc02. If noc01 gets ipv6 then
## it will need to be revisited.
{% for host in groups['all']|sort %}
{% if hostvars[host].datacenter == 'ibiblio' and hostvars[host].nagios_Can_Connect == true %}
{% for host in groups['all']|sort if
hostvars[host].datacenter == 'ibiblio' and
hostvars[host].nagios_Can_Connect == true
%}
define host {
use mincheck6
host_name {{ hostvars[host].ansible_hostname }}-ipv6.fedoraproject.org
host_name ipv6-{{ host }}
{% if hostvars[host].ansible_hostname is defined %}
alias {{ hostvars[host].ansible_hostname }}-ipv6.fedoraproject.org
alias {{ hostvars[host].ansible_hostname }}-ipv6
{% else %}
alias {{ host }}
@ -26,5 +29,4 @@ define host {
parents ibiblio-gw
{% endif %}
}
{% endif %}
{% endfor %}