I’ve added a few custom variables to group_vars/production/vault.yml and I ran both provision (ansible-playbook server.yml -e env=production) and deploy (./bin/deploy.sh production example.com), but the variables aren’t getting into the .env on production.
The variables (without quotes around the variable content):
Also be sure your hosts/production and hosts/staging don’t have the same IP or hostname, otherwise Ansible might be using your group_vars/staging such that changes to group_vars/production have no effect. That issue is described here:
If the above applies, it’s just an issue of understanding how Ansible applies/uses host patterns. If you want to think about it a lot, this is a helpful note explaining the issue:
You CAN use the groups as a way to target hosts but that does not mean the other ‘host properties’ disappear. I am in the ‘males’ group and in the ‘programmers’ group, just because you ‘select me’ as a programmer I do not stop being male. – ref
In the Trellis case, if a host is in both staging and production, targeting it with -e env=production doesn’t make the host no longer also in staging. Ansible will load both your production and staging versions of the vault_wordpress_sites variable, and potentially in a sequence that leaves the staging version in effect.
Yes… please actually look at the code, a search for ‘env’ will show you everything
No. The .env file is in the .gitignore file for a reason
I’m locking this thread. If you need further help you can head over to https://roots.io/services/ and purchase a call. Someone (most likely @fullyint, one of the Trellis product owners) can help you sort things out.