Using host groups in a playbook

24 views
Skip to first unread message

István Szukács

unread,
Jun 5, 2015, 11:01:01 PM6/5/15
to ansible...@googlegroups.com
Hi everybody,

I was wondering what is the most idiomatic way of doing the following:

---
- name: Install
  hosts: 'webservers'
  remote_user: 'centos'
  roles:
    - { role: 'webserver', db_conn_string: 'hostA.tld.com:9999,hostB.tld.com:9999,hostC.tld.com:9999' }

The db hosts are are called [database] group in the hosts file.

Can I generate the db conn string somehow in the playbook or there is better way of achieving this.

Thank you in advance,
Istvan

benno joy

unread,
Jun 5, 2015, 11:58:34 PM6/5/15
to ansible...@googlegroups.com
try 

{{ ":9999,".join(groups['database']) + ':9999' }}




--
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/12fceea2-ec6e-47a8-8717-482471aea2bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages