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

Commit

Permalink
Start of contact groups for issue #5
Browse files Browse the repository at this point in the history
Contact groups are a useful way of sending alerts and avoiding single person
failures. I can't quite figure out what I need to do yet so I'm goint to put
this on the backburner while I consider issues #7 and #9.
  • Loading branch information
goetzk committed Apr 11, 2017
1 parent 94bec3e commit b69cd34
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tasks/configure-shinken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,31 @@
notify:
- restart shinken arbiter

# Following Jinja magic thanks to mikecee
# - name: Build list of admin users
# set_fact:
# admin_users="{{ shinken_contacts | sum(attribute='is_admin', start=[]) | unique }}"

# - debug:
# msg: "{{ shinken_contacts.0 }}"
#
# - name: Populate admins list
# set_fact:
# admin_users: "{{ admin_users|default([]) | combine( item.name ) }}"
# with_items: shinken_contacts
# when: item.is_admin == 1
#
# - name: Install admins contact group
# # with_items: "{{ admin_users }}"
# with_items: "{{ shinken_contacts }}"
# template:
# src: contactgroup-admin.cfg.tmpl
# dest: /etc/shinken/contactgroups/admin.cfg
# notify:
# - restart shinken arbiter

# TODO: after figuring out admins, do that for users too

- name: Create configuration for services to monitor
with_items: "{{ shinken_services }}"
template:
Expand Down
14 changes: 14 additions & 0 deletions templates/contactgroup-admin.cfg.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# {{ ansible_managed }}
{% set admin_users = [0] -%}
{% for key, value in item.iteritems() %}
{% if key == 'is_admin' and value == '1' %}
{% set admin_users.append('item.name') %}
{% endif %}
{% endfor %}

define contactgroup{
contactgroup_name admins
alias admins
members {{ admin_users }}
}

0 comments on commit b69cd34

Please sign in to comment.