> On Jan 3, 2017, at 10:30, [email protected] wrote: > > Hello - Thanks for the response. > > Yea right now I have a top level ansible.cfg that already points to my own > inventory file (currently just one). > > I guess I'm still not connecting the dots as to how site.yml (in their > example) would know which inventory, host_vars, and group_vars to load. Is > there an ansible.cfg that also needs to be split into the 'production' and > 'staging' directories? > > If I used the environment variable option that you presented above, I'm > assuming I would load that in the .profile for the user running the playbook? > In that way my PL user and DR user would each point to their own inventory > file (via the .profile when the shell is opened) even before the ansible > playbook is executed. Also, I wouldn't have to hard code the inventory into > the playbook or the command line. Am I thinking about that right? Sorry for > the perhaps simple question, I'm still getting used to Linux systems.
You don't need to create separate users. Environment variables can be set for a single shell session, or you can use Ansible's `-i` flag to specify the inventory per-run instead. I have a fair bit of experience using multiple inventories in the same repo now. Here's the setup I'd recommend: * Specify the default inventory you want to use in ansible.cfg (hostfile = path/to/prod/). * Override the default when you're configuring the DR environment (ansible-playbook playbook.yml -i path/to/pldr/). Another strategy I've used for per-inventory options: set the correct variables in a file in your Ansible repo, and source that in your shell when you want to work on that environment, e.g.: # /path/to/ansible/repo/prodvars.sh # For example let's say you need to set options for ec2.py: AWS_REGION=us-west-2 AWS_PROFILE=profilename # ...and the inventory or other Ansible params: ANSIBLE_INVENTORY=path/to/prod/ (Note: in case the convention isn't clear, wherever it says `path/to/...` above, replace that with the real path.) pacem in terris / мир / शान्ति / سَلاَم / 平和 Kevin R. Bullock -- 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/A0D1F011-78C1-48E8-BA29-20ABE1B2A17F%40softwareforgood.com. For more options, visit https://groups.google.com/d/optout.
