Ansible production and development, change hostname

31 views
Skip to first unread message

Victor Caballero

unread,
Nov 9, 2016, 2:10:36 PM11/9/16
to Ansible Project
Hello,

I want to use the same playbook for production and development. The playbook is divided in separate role-hosts, let's say: pubsubservers and mongoservers. I have a hosts file assigning the hostnames: 

[mongoservers]
172.16.2.198


[pubsubservers]
172.16.2.211

[pubsubandmongo:children]
mongoservers
pubsubservers

Imagine that the configuration shown above is for production (production ip adresses). Is there any way to "override" the ip adresses for development (i.e. 127.0.0.1 for both mongoservers and pubsubservers) without changing the hosts file?

Thank you,

Dick Davies

unread,
Nov 9, 2016, 7:28:15 PM11/9/16
to ansible list
Have 2 inventories, one for prod and one for dev. then just call
Ansible with '-i prod/' or '-i dev/' .
> --
> 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/0b593ff9-6d62-4300-ad06-36aba002bdbb%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Simon Wydooghe

unread,
Nov 10, 2016, 1:39:00 PM11/10/16
to Ansible Project
As Dick says, you can use multiple inventories. Check out the directory layout in the Ansible Best Practices guide for more info: http://docs.ansible.com/ansible/playbooks_best_practices.html#directory-layout
Reply all
Reply to author
Forward
0 new messages