Nagios Module - Scheduling Downtime

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,

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.

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,