Loading variables from .env files in Ansible
Ansible has various ways of looking up data from outside sources, including plain text password files, CSV files and INI files. But it doesn't seem to have a lookup for .env files, as used in Laravel projects, also available for PHP, Ruby, Node.js, Python and others.
One option is to launch Ansible with the Ruby
dotenv command line script... But that requires Ruby, which seems like overkill to me.
So here is a simpler solution that I use. It consists of:
- A small shell script that loads the
.envfile into environment variables -