# Nagios module usage

**URL:** <https://forum.ansible.com/t/nagios-module-usage/19262>\
**Category:** Ansible Project\
**Created:** [September 14, 2015, 4:40pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262 "2015-09-14T16:40:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 14, 2015, 4:40pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262/1 "2015-09-14T16:40:29Z")

</div>

I’d like to set downtime in Nagios for several hosts at once using the Nagios module. How do I specify those several hosts?

```auto
- nagios: action=downtime minutes=30 service=all host=?

```

Many thanks.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 14, 2015, 4:41pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262/2 "2015-09-14T16:41:44Z")

</div>

you can do:

- nagios: action=downtime minutes=30 service=all host={{item}}  
&nbsp;&nbsp;with\_items: "{{ listofhosts }}"

or if it is a specific ansible inventory group:

- nagios: action=downtime minutes=30 service=all host={{item}}  
&nbsp;&nbsp;with\_items: "{{ groups['specificgroup'] }}"

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 14, 2015, 4:45pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262/3 "2015-09-14T16:45:21Z")

</div>

Excellent - thank you, Brian!

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 14, 2015, 4:57pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262/4 "2015-09-14T16:57:50Z")

</div>

Oh, Brian, is the {{ listofhosts }} just a space-delimited list?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 14, 2015, 5:04pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262/5 "2015-09-14T17:04:12Z")

</div>

its a list

listofhosts:  
&nbsp;&nbsp;- host1  
&nbsp;&nbsp;- host2

or

listofhosts: ['host1', 'host2', ....]

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 14, 2015, 6:17pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262/6 "2015-09-14T18:17:04Z")

</div>

Sorry I’m asking Ansible 101 questions, but my play isn’t working:

tasks:

- nagios: action=downtime minutes=5 author=“My Name” service=all host={{item}}  
with\_items: “{{ listofhosts }}”  
listofhosts:
- summitauto  
delegate\_to: nagios\_server  
tags:
- nagios\_downtime

I guess I don’t know where to put my list. Also not sure if “author” belongs where I have it.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 14, 2015, 6:22pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262/7 "2015-09-14T18:22:10Z")

</div>

you cannot define it that way, you either predefine the list in a  
vars: or vars\_file or just do it like this:

&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- nagios: action=downtime minutes=5 author="My Name" service=all  
host={{item}}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with\_items:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- summitauto  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delegate\_to: nagios\_server  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tags:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- nagios\_downtime

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 14, 2015, 7:13pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262/8 "2015-09-14T19:13:31Z")

</div>

When I try that, I get the following errors:

fatal: [host1 → nagios\_server] =\> Authentication failure.  
fatal: [host2 → nagios\_server] =\> Authentication failure.  
fatal: [host3 → nagios\_server] =\> Authentication failure.  
changed: [host4 → nagios\_server] =\> (item=summitauto)  
changed: [host5 → nagios\_server] =\> (item=summitauto)  
changed: [host6 → nagios\_server] =\> (item=summitauto)

That’s clearly not what I’m after. The beginning of the playbook looks like this:

- hosts: all  
gather\_facts: false  
sudo: yes

and I run the playbook like this: ansible-playbook someplaybook.yml --tags “nagios\_downtime” -u sudoacct

Thanks for your continuing help.

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [September 15, 2015, 1:39pm UTC](https://forum.ansible.com/t/nagios-module-usage/19262/9 "2015-09-15T13:39:53Z")

</div>

I didn’t realize that I needed to create a separate play in my playbook to do this piece. Once I did that, everything worked as advertise. Sorry that my learning mistakes have created noise. Thanks, again, to Brian Coca for all the help - greatly appreciated!
