I’m working in an ecosystem that includes 5 distinct repositories. A sixth, “server”, repository exists to handle “umbrella” tasks. I’m trying to build things out such that each project knows how to deploy itself (specifically to its vagrant environment), while the server repository is responsible for deploying everything to upstream AWS environments (integration, staging, production).
I’m still learning and still trying to figure out the most efficient way for the server to deploy projects, but at the moment I have, in the SERVER repository, a playbook that:
- launches any necessary ec2 instances
- performs basic configuration of those instances
Now I’d like it to access one of the other repositories and execute its deployment tasks. That project has roles to
- provision the server with its required software (Nginx, Node.js, etc)
- install and configure the project code base
From within the SERVER playbook, I know I can include another playbook or even execute roles via relative paths. What I don’t know is this: in the PROJECT repository, is there any way to have Ansible automatically include a specific vars file based on the environment?
As an example, I execute ansbile from the SERVER project specifying an environment-specific inventory
$ ansible-playbook -i development deploy.yml
The SERVER project automatically loads my development/group_vars/all.yml variables file. When I call out to the PROJECT bits it doesn’t seem to auto-include the development vars from a similar path in the PROJECT path. For each project, how it deploys depends entirely on which environment we’re deploying to.
What are my options (if any) for having the PROJECT script autoload variables based on the environment specified when I executed the SERVER deployment?