diff --git a/templates/contacts.cfg.tmpl b/templates/contacts.cfg.tmpl index e04896b..5a27cd9 100644 --- a/templates/contacts.cfg.tmpl +++ b/templates/contacts.cfg.tmpl @@ -1,18 +1,8 @@ # {{ ansible_managed }} define contact{ - {# loop through all key:value pairs and print out the results #} + {# loop through all key:value pairs and output the results #} {% for key, value in item.iteritems() %} - - {% if key == 'contact_name' %} - {% if key is defined %} - {{ key }} {{ value }} - {% else %} - {{ key }} {{ value |mandatory }} - {% endif %} - {% else %} - {# Special case doesn't apply here #} {{ key }} {{ value }} - {% endif %} {% endfor %} } diff --git a/templates/hosts.cfg.tmpl b/templates/hosts.cfg.tmpl index 7ff4f22..22d49f2 100644 --- a/templates/hosts.cfg.tmpl +++ b/templates/hosts.cfg.tmpl @@ -4,25 +4,11 @@ define host{ {# loop through all key:value pairs and print out the results #} {% for key, value in item.iteritems() %} - {% if key == 'use' %} - {% if key is defined %} - {{ key }} {{ value }} - {% else %} - {{ key }} generic-host - {% endif %} - {% elif key == 'parent' %} - {% if value %} - # Parent nodes of this host - parents {{ value }} - {% endif %} - {% elif key == 'contact_groups' %} - # Contact groups this host is a member of - contact_groups {{ value | join(",") }} - {% elif key == 'hostgroups' %} + # TODO: establish if this special casing is still required. + {% if key == 'hostgroups' %} # Hostgroups this host is a member of hostgroups {{ value | join(",") }},all {% else %} - {# Guess none of the special cases apply here #} {{ key }} {{ value }} {% endif %} {% endfor %} diff --git a/templates/services.cfg.tmpl b/templates/services.cfg.tmpl index 9582fb0..0a8167d 100644 --- a/templates/services.cfg.tmpl +++ b/templates/services.cfg.tmpl @@ -3,23 +3,14 @@ define service{ {# loop through all key:value pairs and print out the results #} {% for key, value in item.iteritems() %} - {% if key == 'use' %} - {% if key is defined %} - {{ key }} {{ value }} - {% endif %} - {% elif key == 'check_command' %} - {% if key is defined %} - {{ key }} {{ value }} - {% else %} - check_command this value is required and was not set in ansible - {% endif %} - {% elif key == 'hostgroup_name' %} - {{ key }} {{ value |join(",") }} + + {% if key == 'hostgroup_name' %} + {{ key }} {{ value |join(",") }} {% else %} - {# Guess none of the special cases apply here #} {{ key }} {{ value }} {% endif %} {% endfor %} + {# We can have multiple sources but its good to have this one as default. Fills in any gaps left by supplied #} use generic-service {% if item.hostgroup_name is not defined %}