Commit 7ceb07bc authored by aflatto's avatar aflatto Committed by GitHub
Browse files

Merge pull request #44 from rubdos/object_logic

Object logic extensions
parents 7922cd4e a9d8d300
......@@ -22,9 +22,11 @@ Example Playbook
roles:
- role: icinga2-ansible-add-hosts
configuration_logic: "object"
host_attributes: |
check_command = "http"
vars.sla = "24x7"
icinga_host_attributes:
check_command: "http"
vars.sla: "24x7"
icinga_host_templates:
- icinga/sensors.j2
host_checks: |
object Service "load_average" {
host_name = "{{ hostvars[item]['ansible_fqdn'] }}"
......@@ -41,6 +43,22 @@ Example Playbook
```
The `icinga_host_templates` allows you to inject more complex
`host_variables` through a template.
In this example, you would add `templatse/icinga/sensors.j2`, e.g.
```
vars.sensors = {
{% for sensor in hostvars[item].sensors %}
"Sensor {{ sensor.name }}" = {
sensor_name = "{{ sensor.name }}"
cpu_temp_crit = {{ sensor.critical }}
cpu_temp_warn = {{ sensor.warning }}
},
{% endfor %}
}
```
Role Variables
--------------
......
# {{ ansible_managed }}
{% if hostvars[item]['group_names'] | difference('monitoring_servers') %}
# A host definition
object Host "{{ hostvars[item]['ansible_fqdn'] }}" {
......@@ -8,6 +10,19 @@ object Host "{{ hostvars[item]['ansible_fqdn'] }}" {
{{ host_attributes }}
{% if 'icinga_host_attributes' in hostvars[item] %}
{% for attribute, value in hostvars[item].icinga_host_attributes.iteritems() %}
{{ attribute }} = {{ value }}
{% endfor %}
{% endif %}
{% if 'icinga_host_templates' in hostvars[item] %}
{% for template in hostvars[item].icinga_host_templates %}
{% include template %}
# Intentional newline
{% endfor %}
{% endif %}
}
#Here Goes Checks if Any
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment