# Learning Ansible for multi-server prod deploy on DO - dependencies questions

**URL:** <https://forum.ansible.com/t/learning-ansible-for-multi-server-prod-deploy-on-do-dependencies-questions/41044>\
**Category:** Get Help\
**Tags:** digitalocean, variables, ubuntu, galaxy-ng\
**Created:** [March 14, 2025, 3:17am UTC](https://forum.ansible.com/t/learning-ansible-for-multi-server-prod-deploy-on-do-dependencies-questions/41044 "2025-03-14T03:17:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![madsciai](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/madsciai/32/7897_2.png) [@madsciai](https://forum.ansible.com/u/madsciai)\
**Post date:** [March 14, 2025, 3:17am UTC](https://forum.ansible.com/t/learning-ansible-for-multi-server-prod-deploy-on-do-dependencies-questions/41044/1 "2025-03-14T03:17:00Z")

</div>

Hi all, I have a few basic questions while working on a deployment to DigitalOcean droplet(s) with Ansible.

1. If I want to use the [DigitalOcean Cloud collection](https://galaxy.ansible.com/ui/repo/published/digitalocean/cloud/docs/), 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?

2. How does the [built in lookup plugin](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/env_lookup.html) 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?)

Thanks for any input!

---

<div class="post-metadata">

**Author:** ![madsciai](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/madsciai/32/7897_2.png) [@madsciai](https://forum.ansible.com/u/madsciai)\
**Post date:** [March 14, 2025, 3:27am UTC](https://forum.ansible.com/t/learning-ansible-for-multi-server-prod-deploy-on-do-dependencies-questions/41044/2 "2025-03-14T03:27:57Z")

</div>

Also - would a vars.yml playbook addition be how to use the lookup plugin? Or do those not go together?

Edit: Not great to be putting these keys as plaintext in YAML files I think, so I suppose vars isn’t the answer.

Update: After more endless docs reading, I think [this](https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-access-shell-environment-variables) answers my second question.

---

<div class="post-metadata">

**Author:** ![kristianheljas](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kristianheljas/32/7702_2.png) [@kristianheljas](https://forum.ansible.com/u/kristianheljas)\
**Post date:** [March 14, 2025, 10:45am UTC](https://forum.ansible.com/t/learning-ansible-for-multi-server-prod-deploy-on-do-dependencies-questions/41044/3 "2025-03-14T10:45:26Z")

</div>

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.

```auto
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:

```auto
- hosts: localhost
  gather_facts: true
  tasks:
    - ansible.builtin.debug:
        msg: "{{ ansible_facts['env'] }}"

```

* * *

Can you clarify what do you mean about the `vars.yml`?

For reference, heres the docs about different ways to set variables:

> **[Using Variables — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#where-to-set-variables)**
