Hi all, I have a few basic questions while working on a deployment to DigitalOcean droplet(s) with Ansible.
If I want to use the DigitalOcean Cloud collection, does the collection need to be in the same directory as my playbooks vs. in my global config Ansible files? If so, can I use a requirements.yml file including this collection to ensure it’s installed in the right place, or do this manually?
How does the built in lookup plugin find environment variables - is it just what I set in my shell environment during development? If so, how does it find anything if on a cloud hosted server? (Where should I put my environment variable keys and values so they can be looked up?)
For collections, use ansible-galaxy to install the collections.
You can either install it manually with ansible-galaxy collection install digitalocean.cloud, but it’s best to specify requirements file to it’s checked into source control.
collections:
- name: digitalocean.cloud
Then ansible-galaxy install -r requirements.yml
Lookup plugins will always execute on the controller node, hence the env lookup plugin will have same environment you run ansible from.
To get remote environment variables, you can use ansible facts: