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