Nagios module usage

49 views
Skip to first unread message

Dimitri Yioulos

unread,
Sep 14, 2015, 12:40:29 PM9/14/15
to Ansible Project
I'd like to set downtime in Nagios for several hosts at once using the Nagios module.  How do I specify those several hosts?

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

Many thanks.

Brian Coca

unread,
Sep 14, 2015, 12:41:49 PM9/14/15
to Ansible Project
you can do:

- nagios: action=downtime minutes=30 service=all host={{item}}
with_items: "{{ listofhosts }}"

or if it is a specific ansible inventory group:

- nagios: action=downtime minutes=30 service=all host={{item}}
with_items: "{{ groups['specificgroup'] }}"


--
Brian Coca

Dimitri Yioulos

unread,
Sep 14, 2015, 12:45:22 PM9/14/15
to Ansible Project
Excellent - thank you, Brian!

Dimitri Yioulos

unread,
Sep 14, 2015, 12:57:50 PM9/14/15
to Ansible Project
Oh, Brian, is the {{ listofhosts }} just a space-delimited list?


On Monday, September 14, 2015 at 12:40:29 PM UTC-4, Dimitri Yioulos wrote:

Brian Coca

unread,
Sep 14, 2015, 1:04:15 PM9/14/15
to Ansible Project
its a list

listofhosts:
- host1
- host2

or


listofhosts: [ 'host1', 'host2', ....]
> --
> 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/6ee0a403-4646-4a72-8521-dc223c40d32f%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Dimitri Yioulos

unread,
Sep 14, 2015, 2:17:04 PM9/14/15
to Ansible Project
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.

On Monday, September 14, 2015 at 12:40:29 PM UTC-4, Dimitri Yioulos wrote:

Brian Coca

unread,
Sep 14, 2015, 2:22:14 PM9/14/15
to Ansible Project
you cannot define it that way, you either predefine the list in a
vars: or vars_file or just do it like this:

tasks:
- nagios: action=downtime minutes=5 author="My Name" service=all
host={{item}}
with_items:
- summitauto
delegate_to: nagios_server
tags:
- nagios_downtime


--
Brian Coca

Dimitri Yioulos

unread,
Sep 14, 2015, 3:13:31 PM9/14/15
to Ansible Project
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.


On Monday, September 14, 2015 at 12:40:29 PM UTC-4, Dimitri Yioulos wrote:

Dimitri Yioulos

unread,
Sep 15, 2015, 9:39:53 AM9/15/15
to Ansible Project
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!


On Monday, September 14, 2015 at 12:40:29 PM UTC-4, Dimitri Yioulos wrote:
Reply all
Reply to author
Forward
0 new messages