Hi community! I have a simple, newbie question related to setting the
environment for plugins. This playbook illustrates my problem:

---
- name: env behaviour
  hosts: localhost
  gather_facts: no
  environment:
    MY_VAR: foo

  tasks:
    - name: shell w/environment
      shell: echo $MY_VAR
      environment:
        MY_VAR: bar

    - name: env lookup w/environment
      debug:
        msg: "{{ lookup('ansible.builtin.env', 'MY_VAR') }}"
      environment:
        MY_VAR: bar

As documented, although the environment keyword will work in the first
task, the lookup is not aware of the env value set for MY_VAR, either at
the play or task level. Now, is there any way to set the environment that
will work for plugins as well? I have a lookup plugin that retrieves a
token from the environment (calling os.getenv/os.environ.get), and I'd like
to be able to set it at run time instead of hardcoding it in a shell
variable.
Thanks,

Gabriel

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF_Khd%2BdnkWdmD0Q0vCaVRPB5v%3DCm7VYdTjZ_88c_0r6oWJyAg%40mail.gmail.com.

Reply via email to