That's similar to how I have things setup, but I was missing the piece about the parent group in each inventory file and then having a staging/prod/local group.
I found this<http://stackoverflow.com/questions/20837850/tailor-ansible-roles-to-environment>article on Stack Overflow that had another solution that I'm currently implementing/playing with. Any thoughts or pros/cons of doing it that way? Thanks for your help! On Thursday, March 6, 2014 11:42:19 AM UTC-8, James Martin wrote: > > Sounds like group vars would help you out. Make sure you have 3 inventory > files, one for each environment. In each one create a parent group > (staging, prod or local). In your group_vars dir below your inventory, have > a staging, prod, and local file that would contain the vars for that are > specific or need to be overridden. For variable defaults, keep them in > group_vars/all. > > example inventory file: > > [myservers] > server1 > server2 > server3 > > [prod:children] > myservers > > ex: > > inventory/ > ├── group_vars > │ ├── all > │ ├── local > │ ├── prod > │ └── staging > ├── local > ├── prod > └── staging > > > > On Thu, Mar 6, 2014 at 1:50 PM, James Goodhouse > <[email protected]<javascript:> > > wrote: > >> Hey All, >> >> I currently have three separate inventory files to handle staging, >> production, and local installs for my project. I'm having difficulty >> figuring out the best way to configure variables while doing this. One >> example is that on local and staging servers I need to have nginx run on >> port 80 and not have varnish install, whereas on production servers I need >> the port to be 81 and have varnish install. I suppose I could create a >> host_var file for each and every server to ensure I set the variable to 80 >> or 81 where needed, but this seems way overkill. >> >> How have people been handling this? >> >> Thanks! >> >> James >> >> -- >> 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 [email protected] <javascript:>. >> To post to this group, send email to [email protected]<javascript:> >> . >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/e31ad2b3-0bd5-45b2-b287-f9c306953716%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/e31ad2b3-0bd5-45b2-b287-f9c306953716%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/51c708da-699e-498f-b658-92fc49f4e1b7%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
