a )g @shddlmZmZmZeZdZdZdZddl m Z ddl m Z ddl mZddlmZGd d d eZd S) )absolute_importdivisionprint_functiona 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 C(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 ) Undefined)AnsibleUndefinedVariable) LookupBase) py3compatc@seZdZddZdS) LookupModulec Ksd|j||dg}|d}|D]>}|d}tj||}t|trTtd|| |q |S)N)Z var_optionsZdirectdefaultrz1The "env" lookup, found an undefined variable: %s) Z set_optionsZ get_optionsplitrenvironget isinstancerrappend) selfZtermsZ variableskwargsretdZtermvarvalr>/usr/lib/python3.9/site-packages/ansible/plugins/lookup/env.pyrunCs     zLookupModule.runN)__name__ __module__ __qualname__rrrrrr Bsr N)Z __future__rrrtypeZ __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNZjinja2.runtimerZansible.errorsrZansible.plugins.lookuprZ ansible.utilsrr rrrrs