I’m attempting to implement a deployment playbook that deploys to digital ocean. In the ansible docs on the digital_ocean module it states,
“Two environment variables can be used, DO_CLIENT_ID and DO_API_KEY”
I haven’t yet written a task or playbook that uses environment variables that are already set. I’ve tried setting these in the current process manually as well as adding these environment variables in the current users ~/.bash_profile. In both cases I get the following message:
msg: Unable to load DO_CLIENT_ID
I’ve also tried setting these variables in the digital_ocean task using client_id={{ lookup(‘env’,‘DO_CLIENT_ID’) }} and still get the above message. Any tips on what I’m doing wrong?
Thanks!
Typically a provisioning play that talks to the cloud is run locally.
If you’ve added them to ~./bash_profile, be sure to source ~/.bash_profile.
(Do not run your provisioning play via a remote host, as Ansible will otherwise avoid loading this file to ensure repeatability in centralized management)
If setting them with the DO module parameters, it’s not intended you extract them again through the environment, it will either use the environmental parameters or the ones passed to the module.
OK, it’s working now. I was running with --connection=local. What’s odd is I was double-checking that the variables were set using ‘echo’, and even opened up a new terminal tab (I’m running on OS X)… for whatever reason restarting my terminal entirely did the trick. Guessing running it with ‘source’ would have had a similar effect. Thanks!