관리-도구
편집 파일: file.cpython-39.pyc
a �)g� � @ sr d dl mZmZmZ eZdZdZdZd dl m Z mZ d dlm Z d dlmZ d dlmZ e� ZG d d � d e �ZdS )� )�absolute_import�division�print_functiona� name: file author: Daniel Hokka Zakrisson (!UNKNOWN) <daniel@hozac.com> version_added: "0.9" short_description: read file contents description: - This lookup returns the contents from a file on the Ansible controller's file system. options: _terms: description: path(s) of files to read required: True rstrip: description: whether or not to remove whitespace from the ending of the looked-up file type: bool required: False default: True lstrip: description: whether or not to remove whitespace from the beginning of the looked-up file type: bool required: False default: False notes: - if read in variable context, the file can be interpreted as YAML if the content is valid to the parser. - this lookup does not understand 'globbing', use the fileglob lookup instead. aF - ansible.builtin.debug: msg: "the value of foo.txt is {{lookup('ansible.builtin.file', '/etc/foo.txt') }}" - name: display multiple file contents ansible.builtin.debug: var=item with_file: - "/path/to/foo.txt" - "bar.txt" # will be looked in files/ dir relative to play or in role - "/path/to/biz.txt" zV _raw: description: - content of file(s) type: list elements: str )�AnsibleError�AnsibleParserError)� LookupBase)�to_text)�Displayc @ s e Zd Zddd�ZdS )�LookupModuleNc K s� g }| j ||d� |D ]�}t�d| � | �|d|�}t�d| � zZ|r�| j�|�\}}t|dd�} | �d�rx| � � } | �d�r�| � � } |�| � nt� �W q ty� t d | ��Y q0 q|S ) N)Zvar_optionsZdirectzFile lookup term: %s�fileszFile lookup using %s as fileZsurrogate_or_strict)�errors�lstrip�rstripz#could not locate file in lookup: %s)Zset_options�display�debugZfind_file_in_search_pathZvvvvZ_loaderZ_get_file_contentsr Z get_optionr r �appendr r ) �selfZtermsZ variables�kwargs�retZtermZ lookupfileZ b_contentsZ show_data�contents� r �?/usr/lib/python3.9/site-packages/ansible/plugins/lookup/file.py�run? s&