a )g @srddlmZmZmZeZdZdZdZddl m Z m Z ddl m Z ddlmZddlmZeZGd d d e Zd S) )absolute_importdivisionprint_functiona 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. 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 ) AnsibleErrorAnsibleParserError) LookupBase)to_text)Displayc@seZdZdddZdS) LookupModuleNc Ksg}|j||d|D]}td|||d|}td|zZ|r|j|\}}t|dd} |drx| } |dr| } | | nt Wqt yt d |Yq0q|S) N)Z var_optionsZdirectzFile lookup term: %sfileszFile lookup using %s as fileZsurrogate_or_strict)errorslstriprstripz#could not locate file in lookup: %s)Z set_optionsdisplaydebugZfind_file_in_search_pathZvvvvZ_loaderZ_get_file_contentsrZ get_optionr rappendrr) selfZtermsZ variableskwargsretZtermZ lookupfileZ b_contentsZ show_datacontentsr?/usr/lib/python3.9/site-packages/ansible/plugins/lookup/file.pyrun?s&      zLookupModule.run)N)__name__ __module__ __qualname__rrrrrr =sr N)Z __future__rrrtypeZ __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNZansible.errorsrrZansible.plugins.lookuprZansible.module_utils._textrZansible.utils.displayr rr rrrrs