On the new (pending) nagios module

Oh hi,

So you may have heard by now that I've ported my func nagios module
into an ansible module. [1] I thought I'd start a discussion on the
lists to see if anyone is testing it, or has questions. And to just
generally spread the word around.

What all functionality does the module encompass?

- Setting downtime
- Setting alerts

Right now, as it's implemented in Ansible, the functionality is
limited to HOSTS and their associated services only.

Nagios also has the concepts of hostgroups and servicegroups. The
original func module has methods to work with these concepts as well.
In reality though, the ansible module has all of the same
functionality. Difference being, the ansible module only exposes ways
to interact with hosts in nagios. If you read the source, you'll see
about two dozen unused methods for handling everything the module
already does for hosts, but for service/hostgroups as well.

I brought that up to see if there is interest in exposing that
functionality as well via the ansible module. Or... if somebody wants
to take it on as a challenge and do it themselves, they are more than
welcome to.

How can you use it?

In playbooks this is an action that you will require a delegate host
for. The delegate is going to be your nagios server. Your action will
need to set the host parameter to $inventory_hostname (or whatever you
need to schedule downtime for). The syntax is this simple:

  tasks:
    - name: downtime for a host
      action: nagios action=downtime minutes=5 services=httpd,nfs
host=$inventory_hostname
      delegate_to: nagios.example.com

And with just that you've scheduled 5 minutes of downtime on the
current host for the httpd and nfs services!

How about on the command line? Well, because you have to delegate the
action you can only do one host at a time, but that shouldn't limit
it's usefulness:

$ ansible nagios.example.com -u root -m nagios -a
"action=disable_alerts service=minecraft host=minecraft01.example.com"

Or maybe you're restarting file serving on your mirror:

$ ansible nagios.example.com -u root -m nagios -a
"action=disable_alerts services=rsync,ftp host=mirror01.example.com"

And docs?

It's got 'em. Pull request already submitted [2]

Give 'em a look-over and let me know if there are any areas that need
some re-working, or if clarity is lacking anywhere.

I hope this is useful to somebody, enjoy!

[1] https://github.com/ansible/ansible/pull/948
[2] http://goo.gl/MNARZ

This will be VERY useful for reporting minecraft outages :slight_smile:

Note Tim also supplied an update to the docs, which is available here – http://ansible.github.com/modules.html#nagios

–Michael

So, the nagios server you are delegatin to, it only needs a ssh
connection and no ansible installed there, right?

-andreas

So, the nagios server you are delegatin to, it only needs a ssh
connection and no ansible installed there, right?

Correct.

This will be VERY useful for reporting minecraft outages :slight_smile:

Note Tim also supplied an update to the docs, which is available here --
http://ansible.github.com/modules.html#nagios

--Michael

Oh hi,

...

I hope this is useful to somebody, enjoy!

[1] https://github.com/ansible/ansible/pull/948
[2] http://goo.gl/MNARZ

--
--Tim Bielawa

Minor update, the module now attempts to 'be smart' and locate your
command file for you.

There is basic search functionality added which attempts to find the
nagios configuration file on your system. This is based off a list of
known locations people store their nagios.cfg file. [1]

It is pretty easy to update the list if you find some odd-ball case
where the module can't locate your config file for you.

Enjoy!

[1] https://github.com/ansible/ansible/blob/devel/library/nagios#L51