Skip to content
This repository has been archived by the owner on Oct 12, 2019. It is now read-only.

Commit

Permalink
Start of work on issue #9
Browse files Browse the repository at this point in the history
This is the bulk of the in built validity checking. The items which remain are
things I want to test further before changing which means they won't be
modified for the moment.
  • Loading branch information
goetzk committed Apr 16, 2017
1 parent 94bec3e commit be159e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 40 deletions.
12 changes: 1 addition & 11 deletions templates/contacts.cfg.tmpl
Original file line number Diff line number Diff line change
@@ -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 %}
}

18 changes: 2 additions & 16 deletions templates/hosts.cfg.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
17 changes: 4 additions & 13 deletions templates/services.cfg.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down

0 comments on commit be159e0

Please sign in to comment.