Skip to content

Instantly share code, notes, and snippets.

@bodsch
Created March 17, 2020 07:43
Show Gist options
  • Save bodsch/a3641af34b769af5f8bb8c3fb4bbf6b9 to your computer and use it in GitHub Desktop.
Save bodsch/a3641af34b769af5f8bb8c3fb4bbf6b9 to your computer and use it in GitHub Desktop.
ansible blank lines
// {{ ansible_managed }}
{% if icinga2_notification_apply.host_notification %}
apply Notification "slack-host-notification" to Host {
{%- for k, v in icinga2_notification_apply.host_notification.items() -%}
{% if k == 'import' %}
{{ k }} = "{{ v }}"
{% elif k == 'assign_where' %}
assign where {{ v }}
{% else %}
{{ k }} = {{ v }}
{% endif %}
{%- endfor -%}
}
{% endif %}
// ---
{% if icinga2_notification_apply.service_notification %}
apply Notification "slack-service-notification" to Service {
{%- for k, v in icinga2_notification_apply.service_notification.items() -%}
{% if k == 'import' %}
{{ k }} = "{{ v }}"
{% elif k == 'assign_where' %}
assign where {{ v }}
{% else %}
{{ k }} = {{ v }}
{% endif %}
{%- endfor -%}
}
{% endif %}
icinga2_notification_apply:
host_notification:
import: slack-host-notification
interval: 2h
assign_where: host.vars.notification.slack
service_notification:
import: slack-service-notification
interval: 2h
assign_where: host.vars.notification.slack
// Ansible managed: Do NOT edit this file manually!
apply Notification "slack-host-notification" to Host { import = "slack-host-notification"
interval = 2h
assign where host.vars.notification.slack
}
// ---
apply Notification "slack-service-notification" to Service { import = "slack-service-notification"
interval = 2h
assign where host.vars.notification.slack
}
@bodsch
Copy link
Author

bodsch commented Mar 17, 2020

try and error

this works:

// {{ ansible_managed }}

{% if icinga2_notification_apply.host_notification %}
apply Notification "slack-host-notification" to Host {
{% for k, v in icinga2_notification_apply.host_notification.items() %}
{% if k == 'import' %}
  {{ k }} = "{{ v }}"
{% elif k == 'assign_where' %}
  assign where {{ v }}
{% else %}
  {{ k }} = {{ v }}
{% endif %}
{%- endfor -%}

}
{% endif %}
// ---
{% if icinga2_notification_apply.service_notification %}
apply Notification "slack-service-notification" to Service {
{% for k, v in icinga2_notification_apply.service_notification.items() %}
{% if k == 'import' %}
  {{ k }} = "{{ v }}"
{% elif k == 'assign_where' %}
  assign where {{ v }}
{% else %}
  {{ k }} = {{ v }}
{% endif %}
{%- endfor -%}

}
{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment