관리-도구
편집 파일: inventory_hostnames.cpython-39.pyc
a �)g� � @ s\ d dl mZmZmZ eZdZdZdZd dl m Z d dlmZ d dl mZ G dd � d e�Zd S )� )�absolute_import�division�print_functiona name: inventory_hostnames author: - Michael DeHaan - Steven Dossett (!UNKNOWN) <sdossett@panath.com> version_added: "1.3" short_description: list of inventory hosts matching a host pattern description: - "This lookup understands 'host patterns' as used by the C(hosts:) keyword in plays and can return a list of matching hosts from inventory" notes: - this is only worth for 'hostname patterns' it is easier to loop over the group/group_names variables otherwise. z� - name: show all the hosts matching the pattern, i.e. all but the group www ansible.builtin.debug: msg: "{{ item }}" with_inventory_hostnames: - all:!www zk _hostnames: description: list of hostnames that matched the host pattern in inventory type: list )�AnsibleError)�InventoryManager)� LookupBasec @ s e Zd Zddd�ZdS )�LookupModuleNc K sz t | jdd�}|d �� D ]*\}}|�|� |D ]}|j||d� q0qzdd� |j|d�D �W S tyt g Y S 0 d S )NF)�parse�groups)�groupc S s g | ] }|j �qS � )�name)�.0�hr r �N/usr/lib/python3.9/site-packages/ansible/plugins/lookup/inventory_hostnames.py� <listcomp>3 � z$LookupModule.run.<locals>.<listcomp>)�pattern)r Z_loader�items� add_groupZadd_hostZ get_hostsr )�selfZtermsZ variables�kwargsZmanagerr �hosts�hostr r r �run+ s zLookupModule.run)N)�__name__� __module__�__qualname__r r r r r r * s r N)Z __future__r r r �typeZ __metaclass__Z DOCUMENTATIONZEXAMPLESZRETURNZansible.errorsr Zansible.inventory.managerr Zansible.plugins.lookupr r r r r r �<module> s