-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
# defaults file for icinga2-ansible-add-zones | ||
|
||
icinga2_zones_dir: "/etc/icinga2/zones.d/" | ||
icinga_master_zone: "master" | ||
icinga_merged_zones: '{{icinga_zones|combine({ icinga_master_zone : {} })}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
# handlers file for icinga2-ansible-add-zones | ||
|
||
- name: restart icinga2 | ||
service: name=icinga2 | ||
state=restarted | ||
enabled=yes | ||
|
||
- name: reload icinga2 | ||
service: name=icinga2 | ||
state=reloaded | ||
enabled=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
--- | ||
galaxy_info: | ||
author: your name | ||
description: | ||
company: your company (optional) | ||
# Some suggested licenses: | ||
# - BSD (default) | ||
# - MIT | ||
# - GPLv2 | ||
# - GPLv3 | ||
# - Apache | ||
# - CC-BY | ||
license: license (GPLv2, CC-BY, etc) | ||
min_ansible_version: 1.2 | ||
# | ||
# Below are all platforms currently available. Just uncomment | ||
# the ones that apply to your role. If you don't see your | ||
# platform on this list, let us know and we'll get it added! | ||
# | ||
platforms: | ||
- name: EL | ||
versions: | ||
# - all | ||
# - 5 | ||
- 6 | ||
- 7 | ||
#- name: GenericUNIX | ||
# versions: | ||
# - all | ||
# - any | ||
- name: Fedora | ||
versions: | ||
# - all | ||
# - 16 | ||
# - 17 | ||
# - 18 | ||
# - 19 | ||
- 20 | ||
- 21 | ||
- 22 | ||
- 23 | ||
- 24 | ||
#- name: opensuse | ||
# versions: | ||
# - all | ||
# - 12.1 | ||
# - 12.2 | ||
# - 12.3 | ||
# - 13.1 | ||
# - 13.2 | ||
#- name: Amazon | ||
# versions: | ||
# - all | ||
# - 2013.03 | ||
# - 2013.09 | ||
#- name: GenericBSD | ||
# versions: | ||
# - all | ||
# - any | ||
#- name: FreeBSD | ||
# versions: | ||
# - all | ||
# - 8.0 | ||
# - 8.1 | ||
# - 8.2 | ||
# - 8.3 | ||
# - 8.4 | ||
# - 9.0 | ||
# - 9.1 | ||
# - 9.1 | ||
# - 9.2 | ||
#- name: Ubuntu | ||
# versions: | ||
# - all | ||
# - lucid | ||
# - maverick | ||
# - natty | ||
# - oneiric | ||
# - precise | ||
# - quantal | ||
# - raring | ||
# - saucy | ||
# - trusty | ||
#- name: SLES | ||
# versions: | ||
# - all | ||
# - 10SP3 | ||
# - 10SP4 | ||
# - 11 | ||
# - 11SP1 | ||
# - 11SP2 | ||
# - 11SP3 | ||
#- name: GenericLinux | ||
# versions: | ||
# - all | ||
# - any | ||
#- name: Debian | ||
# versions: | ||
# - all | ||
# - etch | ||
# - lenny | ||
# - squeeze | ||
# - wheezy | ||
# | ||
# Below are all categories currently available. Just as with | ||
# the platforms above, uncomment those that apply to your role. | ||
# | ||
#categories: | ||
#- cloud | ||
#- cloud:ec2 | ||
#- cloud:gce | ||
#- cloud:rax | ||
#- clustering | ||
#- database | ||
#- database:nosql | ||
#- database:sql | ||
#- development | ||
#- monitoring | ||
#- networking | ||
#- packaging | ||
#- system | ||
#- web | ||
dependencies: [] | ||
# List your role dependencies here, one per line. Only | ||
# dependencies available via galaxy should be listed here. | ||
# Be sure to remove the '[]' above if you add dependencies | ||
# to this list. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: Copy Endpoint Zone Definitions | ||
template: src=endpoint_zones.j2 | ||
dest={{ icinga2_zones_dir }}/{{ hostvars[item]['ansible_fqdn'] }}.conf | ||
owner=icinga | ||
group=icinga | ||
mode=0640 | ||
with_items: "{{ groups['all'] }}" | ||
notify: | ||
- reload icinga2 | ||
|
||
- name: Copy Zone Definitions | ||
template: | ||
src: zone.j2 | ||
dest: "{{ icinga2_zones_dir }}/{{ item }}.conf" | ||
owner: icinga | ||
group: icinga | ||
mode: 0640 | ||
with_items: "{{ icinga_merged_zones }}" | ||
notify: | ||
- reload icinga2 | ||
|
||
- name: Copy zones.conf | ||
template: | ||
src: zones.conf | ||
dest: /etc/icinga2/zones.conf | ||
owner: icinga | ||
group: icinga | ||
mode: 0640 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
# tasks file for icinga2-ansible-add-zones | ||
|
||
- name: Ensure existance of {{ icinga2_zones_dir }} | ||
file: | ||
name: "{{ icinga2_zones_dir }}" | ||
state: directory | ||
owner: icinga | ||
group: icinga | ||
|
||
- include: icinga2_add_zones.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
object Endpoint "{{ hostvars[item]['ansible_fqdn'] }}" { | ||
host = "{{ hostvars[item]['ansible_fqdn'] }}" | ||
} | ||
|
||
{% if 'icinga_zone' in hostvars[item] %} | ||
object Zone "{{ hostvars[item]['ansible_fqdn'] }}" { | ||
endpoints = [ "{{ hostvars[item]['ansible_fqdn'] }}" ] | ||
{% if 'icinga_zone' in hostvars[item] %} | ||
parent = "{{ hostvars[item]['icinga_zone'] }}" | ||
{% else %} | ||
parent = "{{ icinga_master_zone }}" | ||
{% endif %} | ||
} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
object Zone "{{ item }}" { | ||
{% if 'parent' in icinga_merged_zones[item] %} | ||
parent = "{{ icinga_merged_zones[item].parent }}" | ||
{% endif %} | ||
|
||
endpoints = [ | ||
{% for host, params in hostvars.iteritems() %} | ||
{% if item == icinga_master_zone and 'icinga_zone' not in params %} | ||
"{{ host }}", | ||
{% endif %}{% endfor %} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include_recursive "zones.d" |