init
This commit is contained in:
commit
c5cd492449
475 changed files with 27928 additions and 0 deletions
26
technology/tools/Ansible/lookups/ansible.builtin.env.md
Normal file
26
technology/tools/Ansible/lookups/ansible.builtin.env.md
Normal 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."
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue