RAX modules and delegate_to directive.

29 views
Skip to first unread message

Marcin Prączko

unread,
May 30, 2014, 9:07:53 AM5/30/14
to ansible...@googlegroups.com
Hello.

I would like to ask for hint related with following challange.
- Gather details about hosts (external IP for example) from RackSpace-Cloud with RAX_modules
- Generate configuration for monitoring server related with RS-images.

So I have following setup:
- Remote VMs in RackSpace (RS) Cloud - which are behind NAT - so ansible facts gather internal IP
- Remote VM with monitoring system
- Local VM for running ansible.

I've manged to do:
- Gather facts from RS-Cloud VMs - for example partiions, etc
- Gather external IP from RS with RAX modules.

Challnage:
How to force run delegate_to on monitoring system to generate correct nagios configuation with valid external VM per host.

Following Ansible documenation I have following playbook:
# Gather details about RS
- name: RS-Cloud-VMs | Gather info about servers
  hosts
: www
  connection
: local
  gather_facts
: False

  tasks
:
   
- { include: roles/rax/tasks/gather_info_about_nodes.yml, rax_credentials: 'files/rax/terr01.cfg', rax_region: DFW }
   
- include: roles/monitoring-server/tasks/generate_nagios_hostcfg.yml


And task to generate nagios hostcfg looks:
- name: Monitoring-Server | Generate main host files for node
 
template: src={{ item }}.j2 dest=/path/to/file/{{ item }}-{{ ansible_fqdn }}.cfg
            owner
=ssh_login group=users mode=0644
  delegate_to
: monitoring
  with_items
:
   
- host


As you can see connection for Playbook is 'local' as recommended on your documentation, task is doing delegate_to remote monitoring host, however ansible is connecting with local host (forced by connection: local).

Could you let me know what is a best practice to achieve this, please?
Especially that:
- Some VMs (in RS cloud) are behind NAT so ansible is able only gather internal IP
- Have to use rax module to get info about RS VMs with external IP.

The only one solution which comes to me is now:
- Generate required files locally
- Use rsync module later on monitoring system.

Not quite happy with this solution, but maybe will be the fastests.

Best regards,
Marcin Praczko

Michael DeHaan

unread,
May 31, 2014, 12:18:45 PM5/31/14
to ansible...@googlegroups.com


--
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/52c9f995-bedc-4b40-9bbc-86ad0cdad116%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages