관리-도구
편집 파일: env.cpython-39.pyc
a �)g� � @ sh d dl mZmZmZ eZdZdZdZd dl m Z d dlmZ d dl mZ d dlmZ G d d � d e�ZdS )� )�absolute_import�division�print_functiona� name: env author: Jan-Piet Mens (@jpmens) <jpmens(at)gmail.com> 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 @ s e Zd Zdd� ZdS )�LookupModulec K sd | j ||d� g }| �d�}|D ]>}|�� d }tj�||�}t|t�rTtd| ��|� |� q |S )N)Zvar_optionsZdirect�defaultr z1The "env" lookup, found an undefined variable: %s) Zset_optionsZ get_option�splitr �environ�get� isinstancer r �append) �selfZtermsZ variables�kwargs�ret�dZterm�var�val� r �>/usr/lib/python3.9/site-packages/ansible/plugins/lookup/env.py�runC s zLookupModule.runN)�__name__� __module__�__qualname__r r r r r r B s r N)Z __future__r r r �typeZ __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNZjinja2.runtimer Zansible.errorsr Zansible.plugins.lookupr Z ansible.utilsr r r r r r �<module> s