Generate hostlist.conf for Munin

72 views
Skip to first unread message

Sibin Arsenijevic

unread,
Sep 26, 2014, 7:52:13 AM9/26/14
to ansible...@googlegroups.com
Hello,

I am trying to generate hostlist.conf on munin machine based on inventory variables, i have something like this in template

hostlist.j2
{% for items in groups['all'] %}
[{{ hostvars[items]['inventory_hostname_short'] }}.{{ hostvars[items]['role_long'] }}.{{ domain }}]
 address ssh
://user@{{ hostvars[items]['ansible_default_ipv4']['address'] }}:{{ hostvars[items]['ansible_ssh_port']|default(22) }} --spooldir /var/lib/munin-async/ --spoolfetch
   use_node_name yes
   load
.load.warning :50
  ntp_offset
.offset.warning -1000:1000
  ntp_offset
.offset.critical -10000:10000


{% endfor %}

and test.yml which in turn calls hostlist.j2 template:
---
- hosts: all
  remote_user
: user
  sudo
: True
  name
: Smth
  tasks
:        
     
- name: Generate munin-hostlist.conf
       
template:
              src
=modules/helpers/hostlist.j2
              dest
=/tmp/hostlist_test
        delegate_to
: foo.acme.com

I am running all this on all hosts (not limited to any specific host) with ansible-playbook test.yml -f 200.

During the execution i get a bunch of seemingly random errors on almost all the hosts (some report OK, some changed but most of them report errors as below):

fatal: [host1.acme.com -> foo.acme.com] => ssh connection closed waiting for sudo or su password prompt
failed: [host2.acme.com -> foo.acme.com] => {"failed": true, "parsed": false}
fatal: [host3.acme.com -> foo.acme.com] => failed to transfer file to /home/user/.ansible/tmp/ansible-tmp-1411730299.82-163702781686018/copy:
mux_client_request_session: session request failed: Session open refused by peer
ssh_exchange_identification: Connection closed by remote host
Couldn't read packet: Connection reset by peer
ok: [host4.acme.com -> foo.acme.com]

However, despite the errors, the resulting file is generated as it should be.

Please note that these servers are accessible and i can run other playbooks just fine on all my hosts. 

My question is: is this normal behaviour or am i doing something wrong and is there a way to get this to execute normally without the errors? Do i have to run this on all hosts (because i need host vars and host facts) even though i need the resulting file on one machine? 

Keep up the excellent work with Ansible! Thank you in advance!!!

Best regards,

Dan Vaida

unread,
Nov 11, 2014, 2:57:48 PM11/11/14
to ansible...@googlegroups.com
I think the problem could be caused by the delegate_to
Have you tried running the playbook without it? i.e. let the Munin master node to generate the conf file dynamically by being the one that connects to each Munin node to fill in the template.
Reply all
Reply to author
Forward
0 new messages