o nnh @sjddlmZdZdZdZddlmZmZmZddl m Z ddl m Z ddl mZeZGd d d e Zd S) ) annotationsa name: file author: Daniel Hokka Zakrisson (!UNKNOWN) 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. seealso: - ref: playbook_task_paths description: Search paths used for relative files. aG - 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 ) AnsibleErrorAnsibleOptionsErrorAnsibleLookupError) LookupBase)to_text)Displayc@seZdZdddZdS) LookupModuleNc Ksg}|j||d|D][}td|z>|j|d|dd}td||rM|j|\}}t|dd} |d r>| } |d rG| } | | nt d Wq t yf} ztd || d d} ~ ww|S)N) var_optionsdirectzFile lookup term: %sfilesT)ignore_missingzFile lookup using %s as filesurrogate_or_strict)errorslstriprstripz0file not found, use -vvvvv to see paths searchedz6The 'file' lookup had an issue accessing the file '%s')orig_exc) set_optionsdisplaydebugfind_file_in_search_pathvvvv_loader_get_file_contentsr get_optionrrappendrrr) selfterms variableskwargsretterm lookupfile b_contents show_datacontentser'F/usr/local/lib/python3.10/dist-packages/ansible/plugins/lookup/file.pyrunAs,    zLookupModule.run)N)__name__ __module__ __qualname__r)r'r'r'r(r ?sr N) __future__r DOCUMENTATIONEXAMPLESRETURNansible.errorsrrransible.plugins.lookupr+ansible.module_utils.common.text.convertersransible.utils.displayrrr r'r'r'r(s