File: //lib/python3.9/site-packages/ansible/plugins/lookup/__pycache__/lines.cpython-39.pyc
a
�)g� � @ sd d dl mZmZmZ eZdZdZdZd dl Z d dl
mZ d dlm
Z
d dlmZ G d d
� d
e
�ZdS )� )�absolute_import�division�print_functiona�
name: lines
author: Daniel Hokka Zakrisson (!UNKNOWN) <[email protected]>
version_added: "0.9"
short_description: read lines from command
description:
- Run one or more commands and split the output into lines, returning them as a list
options:
_terms:
description: command(s) to run
required: True
notes:
- Like all lookups, this runs on the Ansible controller and is unaffected by other keywords such as 'become'.
If you need to use different permissions, you must change the command or run Ansible as another user.
- Alternatively, you can use a shell/command task that runs against localhost and registers the result.
a�
- name: We could read the file directly, but this shows output from command
ansible.builtin.debug: msg="{{ item }} is an output line from running cat on /etc/motd"
with_lines: cat /etc/motd
- name: More useful example of looping over a command result
ansible.builtin.shell: "/usr/bin/frobnicate {{ item }}"
with_lines:
- "/usr/bin/frobnications_per_host --param {{ inventory_hostname }}"
za
_list:
description:
- lines of stdout from command
type: list
elements: str
N)�AnsibleError)�
LookupBase��to_textc @ s e Zd Zdd� ZdS )�LookupModulec K sr g }|D ]d}t j|| j�� dt jt jd�}|�� \}}|jdkrZ|�dd� |�� D �� qt d||jf ��q|S )NT)�cwd�shell�stdin�stdoutr c S s g | ]}t |��qS � r )�.0�lr r �@/usr/lib/python3.9/site-packages/ansible/plugins/lookup/lines.py�
<listcomp>; � z$LookupModule.run.<locals>.<listcomp>z#lookup_plugin.lines(%s) returned %d)
�
subprocess�PopenZ_loaderZget_basedir�PIPEZcommunicate�
returncode�extend�
splitlinesr ) �selfZtermsZ variables�kwargs�retZterm�pr
�stderrr r r �run4 s
zLookupModule.runN)�__name__�
__module__�__qualname__r r r r r r 2 s r )Z
__future__r r r �typeZ
__metaclass__Z
DOCUMENTATIONZEXAMPLESZRETURNr Zansible.errorsr Zansible.plugins.lookupr Zansible.module_utils._textr r r r r r �<module> s