This commit is contained in:
JMARyA 2023-12-04 11:02:23 +01:00
commit c5cd492449
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
475 changed files with 27928 additions and 0 deletions

View file

@ -0,0 +1,26 @@
# ansible.builtin.env
Allows you to query the environment variables available on the controller when you invoked Ansible.
## Examples
```yml
- name: Basic usage
ansible.builtin.debug:
msg: "'{{ lookup('ansible.builtin.env', 'HOME') }}' is the HOME environment variable."
- name: Before 2.13, how to set default value if the variable is not defined.
This cannot distinguish between USR undefined and USR=''.
ansible.builtin.debug:
msg: "{{ lookup('ansible.builtin.env', 'USR')|default('nobody', True) }} is the user."
- name: Example how to set default value if the variable is not defined, ignores USR=''
ansible.builtin.debug:
msg: "{{ lookup('ansible.builtin.env', 'USR', default='nobody') }} is the user."
- name: Set default value to Undefined, if the variable is not defined
ansible.builtin.debug:
msg: "{{ lookup('ansible.builtin.env', 'USR', default=Undefined) }} is the user."
- name: Set default value to undef(), if the variable is not defined
ansible.builtin.debug:
msg: "{{ lookup('ansible.builtin.env', 'USR', default=undef()) }} is the user."
```