o nnhV @sXddlmZdZdZdZddlZddlmZddlm Z ddl m Z Gd d d e Z dS) ) annotationsa name: env author: Jan-Piet Mens (@jpmens) version_added: "0.9" short_description: Read the value of environment variables description: - Allows you to query the environment variables available on the controller when you invoked Ansible. options: _terms: description: - Environment variable or list of them to lookup the values for. required: True default: description: What return when the variable is undefined type: raw default: '' version_added: '2.13' notes: - You can pass the C(Undefined) object as O(default) to force an undefined error a - 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." zY _list: description: - Values from the environment variables. type: list N) Undefined)AnsibleUndefinedVariable) LookupBasec@seZdZddZdS) LookupModulec Ksd|j||dg}|d}|D]}|d}tj||}t|tr*td|| |q|S)N) var_optionsdirectdefaultrz1The "env" lookup, found an undefined variable: %s) set_options get_optionsplitosenvironget isinstancerrappend) selfterms variableskwargsretdtermvarvalrE/usr/local/lib/python3.10/dist-packages/ansible/plugins/lookup/env.pyrunCs     zLookupModule.runN)__name__ __module__ __qualname__rrrrrrBs r) __future__r DOCUMENTATIONEXAMPLESRETURNr jinja2.runtimeransible.errorsransible.plugins.lookuprrrrrrs