관리-도구
편집 파일: fileglob.cpython-39.opt-1.pyc
a �)g� � @ sp d dl mZmZmZ eZdZdZdZd dl Z d dl Z d dlmZ d dl mZ d dlmZmZ G d d � d e�ZdS )� )�absolute_import�division�print_functionad name: fileglob author: Michael DeHaan version_added: "1.4" short_description: list files matching a pattern description: - Matches all files in a single directory, non-recursively, that match a pattern. It calls Python's "glob" library. options: _terms: description: path(s) of files to read required: True notes: - Patterns are only supported on files, not directory/paths. - See R(Ansible task paths,playbook_task_paths) to understand how file lookup occurs with paths. - Matching is against local system files on the Ansible controller. To iterate a list of files on a remote node, use the M(ansible.builtin.find) module. - Returns a string list of paths joined by commas, or an empty list if no files match. For a 'true list' pass C(wantlist=True) to the lookup. a_ - name: Display paths of all .txt files in dir ansible.builtin.debug: msg={{ lookup('ansible.builtin.fileglob', '/my/path/*.txt') }} - name: Copy each file over that matches the given pattern ansible.builtin.copy: src: "{{ item }}" dest: "/etc/fooapp/" owner: "root" mode: 0600 with_fileglob: - "/playbooks/files/fooapp/*" zS _list: description: - list of files type: list elements: path N)� LookupBase)�AnsibleFileNotFound)�to_bytes�to_textc @ s e Zd Zddd�ZdS )�LookupModuleNc K s� g }|D ]�}t j�|�}g }||krB|�| �|dt j�|��� nFd|v rT|d }n| �|�g}|D ]"} |�t j�| d�� |�| � qd|D ]D} | r�t�t t j�| |�dd��}dd� |D �}|r�|� |� qq�q|S )N�filesZansible_search_path�surrogate_or_strict��errorsc S s$ g | ]}t j�|�rt|d d��qS )r r )�os�path�isfiler )�.0�g� r �C/usr/lib/python3.9/site-packages/ansible/plugins/lookup/fileglob.py� <listcomp>P � z$LookupModule.run.<locals>.<listcomp>)r r �basename�appendZfind_file_in_search_path�dirnameZget_basedir�join�globr �extend) �selfZtermsZ variables�kwargs�retZtermZ term_fileZfound_paths�paths�pZdwimmed_pathZglobbedZterm_resultsr r r �run; s( zLookupModule.run)N)�__name__� __module__�__qualname__r"