at our company we extensively use Icinga 2 and Ansible.
We configure commands, hosts, users, templates and practically all other objects trough the director with the help of an Ansible-role.
This proved cumbersome and hard to manage, so we developed some native Ansible-modules.
This is an early release with missing features and probably some bugs. But I wanted to get them out quickly to gather feedback.
One question Iād like direct feedback on: what about the name? Itās āansible-icinga-modulesā for now, however it utilizes the director-api, so should we rename it to āansible-icinga-director-modulesā?
I would change the name to clarify that it uses the director, because there are many other roles and playbooks out there already and they mostly use the icinga Api to add hosts. I will give it a try, as i just started to install Icinga2 agent with ansible and i want to add the new agent into the director.
@Mili_D, I briefly took a look at this library and it seemed good. However we only alter objects through the director, not trough the icinga-api. As far as I can see, this library does not support the director.
No, it should not matter. Iām not quite fluent with the icinga-api. Does it support auditing and rollbacks like the director does? Does it support multiple masters?
The advantage of using the director Api is, that the host is actually shown in the director. Adding it with icinga-api you will not be able to edit the host inside the director (As far as i know the icinga2 api is not aware of the Director). The Director is so powerfull, that i always use it, because you get a lot of good features with him. (service sets, import sources, gui with selectabel lists/dropdowns, etc.)
Iāam rather new to ansible/python and copied the plugins/module content to /usr/share/ansible/plugins/modules. But i get the Erromessage āCould not find imported module support code for icinga_host. Looked either for Icinga2APIObject.py or icinga.pyā Where to copy the content of module_utils?
I tested it now and its working great!
As i do not have access to galaxy.ansible.com from the host, i used the manual way you explained before. I needed some time to find out how to get it up and running.
If you use a proxy by default you need to add āproxy: noā if its a local website (at least on our installation, otherwise Iāam getting this error: "bad return code while creating: "
After renaming the collection the import command needs to be updated:
from
from ansible_collections.T_Systems_MMS.icinga.plugins.module_utils.icinga import Icinga2APIObject
to
from ansible_collections.t_systems_mms.icinga_director.plugins.module_utils.icinga import Icinga2APIObject
inside icinga_host.py f.e.
So here is my working example:
-name: Icinga Host
hosts: icingaagents
collections:
- t_systems_mms.icinga_director
tasks:
- name: Include Director Vars
include_vars:
file: vars/main.yaml
- name: Create a Host in Icinga
#no ideas if i need local connection here, but other remote hosts can't reach the director url.
connection: local
icinga_host:
state: present
use_proxy: no
#validate_certs: no
url: "{{ director_url }}"
url_username: "{{ director_user }}"
url_password: "{{ director_pass }}"
object_name: "{{ ansible_hostname }}"
address: "{{ ansible_default_ipv4.address }}"
display_name: "{{ ansible_hostname }}"
#groups:
# - "foo"
imports:
- "LINUX SERVER AGENT"
vars:
os: "{{ ansible_distribution }}"
...
Weāre working hard on the collection and I wanted to give you an excerpt on what we did the last couple of months. The bold features are (to me) the most interesting ones!