Nagios Module - Scheduling Downtime

187 views
Skip to first unread message

Douglas Thompson

unread,
Apr 25, 2019, 2:51:36 PM4/25/19
to Ansible Project
Hello,

I'm trying to the Ansible nagios module to schedule downtime. In the documentation it says for 'host' to use '{{ inventor_hostname }}'. I'm assuming this is an internal variable that gets the host name from the inventory file. This is not working. Not only that but we only have one nagios server, which is where the commands apparently need to be executed in order to schedule the downtime.

So, my question is: how do you setup the playbook to execute on the nagios server but use the hosts listed in the inventory file to schedule the downtime? As of right now the only way I've been able to do this is to create an extra-vars files and populate that with the hosts names, but this becomes cumbersome.
Any thoughts?
Thank you,

dramaley

unread,
Apr 26, 2019, 10:56:06 AM4/26/19
to Ansible Project
Here's what i do.

    - name: Schedule Nagios downtime
      nagios: action=downtime minutes=20 service="{{ item }}"
              host="{{ inventory_hostname }}" author="Ansible Bot"
              comment="Planned maintenance"
      delegate_to: "{{ nagios_server }}"
      with_items:
        - host
        - all

I have {{nagios_server}} set to the name of the server that runs Nagios. Make sure you use {{inventory_hostname}}; in your post you wrote {{inventor_hostname}}, which is most likely not defined and won't work.

Douglas Thompson

unread,
Apr 26, 2019, 4:00:43 PM4/26/19
to ansible...@googlegroups.com
Thanks, the solution was to add " delegate_to: "{{ nagios_server }}"".  I've never seen the 'delegate_to' directive but once added, that fixed everything.
Thanks,

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e8b19f87-87fe-4ee5-a540-d7cddca61b15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Douglas Thompson
---
Is life so dear or peace so sweet as to be purchased at the price of chains and slavery?  - Patrick Henry
Reply all
Reply to author
Forward
0 new messages