make an iad2-internal hosts for our systems

This commit is contained in:
Stephen Smoogen 2020-06-09 11:19:01 -04:00
parent df38d67d44
commit cd97509505
2 changed files with 44 additions and 0 deletions

View file

@ -426,6 +426,18 @@
- nagios_hosts
notify: restart nagios
## These are only available to the internal server
- name: Build out nagios host templates (production)
template: src=nagios/hosts/{{item}}.j2 dest=/etc/nagios/hosts/{{item}} mode=0644 owner=root group=root
with_items:
- iad2-hosts.cfg
when: env == "production" and nagios_location == 'iad2_internal'
tags:
- nagios_server
- nagios_config
- nagios_hosts
notify: restart nagios
- name: Build out nagios host templates (production)
template: src=nagios/hosts/{{item}}.j2 dest=/etc/nagios/hosts/{{item}} mode=0644 owner=root group=root
with_items:

View file

@ -0,0 +1,32 @@
{% for host in groups['all']|sort %}
{% if hostvars[host].datacenter == 'iad2' and hostvars[host].nagios_Can_Connect == true %}
define host {
{% if hostvars[host].nagios_Check_Services['nrpe'] == true %}
use defaulttemplate
{% else %}
use mincheck
{% endif %}
host_name {{ host }}
{% if hostvars[host].ansible_hostname is defined %}
alias {{ hostvars[host].ansible_hostname }}
{% else %}
alias {{ host }}
{% endif %}
{% if hostvars[host].eth0_ip is defined %}
address {{ hostvars[host].eth0_ip }}
{% elif hostvars[host].ansible_default_ipv4 is defined %}
{% if hostvars[host].ansible_default_ipv4.address is defined %}
address {{ hostvars[host].ansible_default_ipv4.address }}
{% endif %}
{% else %}
address {{ host }}
{% endif %}
{% if hostvars[host]['vmhost'] is defined %}
parents {{ hostvars[host]['vmhost'] }}
{% elif hostvars[host].datacenter is defined %}
parents phx2-gw
{% endif %}
}
{% endif %}
{% endfor %}