HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible/plugins/lookup/__pycache__/subelements.cpython-39.pyc
a

�)g��@sxddlmZmZmZeZdZdZdZddl	m
Z
ddlmZddl
mZddlmZdd	lmZd
ZGdd�de�Zd
S)�)�absolute_import�division�print_functionaj
    name: subelements
    author: Serge van Ginderachter (!UNKNOWN) <[email protected]>
    version_added: "1.4"
    short_description: traverse nested key from a list of dictionaries
    description:
      - Subelements walks a list of hashes (aka dictionaries) and then traverses a list with a given (nested sub-)key inside of those records.
    options:
      _terms:
         description: tuple of list of dictionaries and dictionary key to extract
         required: True
      skip_missing:
        default: False
        description:
          - Lookup accepts this flag from a dictionary as optional. See Example section for more information.
          - If set to C(True), the lookup plugin will skip the lists items that do not contain the given subkey.
          - If set to C(False), the plugin will yield an error and complain about the missing subkey.
a 
- name: show var structure as it is needed for example to make sense
  hosts: all
  vars:
    users:
      - name: alice
        authorized:
          - /tmp/alice/onekey.pub
          - /tmp/alice/twokey.pub
        mysql:
            password: mysql-password
            hosts:
              - "%"
              - "127.0.0.1"
              - "::1"
              - "localhost"
            privs:
              - "*.*:SELECT"
              - "DB1.*:ALL"
        groups:
          - wheel
      - name: bob
        authorized:
          - /tmp/bob/id_rsa.pub
        mysql:
            password: other-mysql-password
            hosts:
              - "db1"
            privs:
              - "*.*:SELECT"
              - "DB2.*:ALL"
  tasks:
    - name: Set authorized ssh key, extracting just that data from 'users'
      ansible.posix.authorized_key:
        user: "{{ item.0.name }}"
        key: "{{ lookup('file', item.1) }}"
      with_subelements:
         - "{{ users }}"
         - authorized

    - name: Setup MySQL users, given the mysql hosts and privs subkey lists
      community.mysql.mysql_user:
        name: "{{ item.0.name }}"
        password: "{{ item.0.mysql.password }}"
        host: "{{ item.1 }}"
        priv: "{{ item.0.mysql.privs | join('/') }}"
      with_subelements:
        - "{{ users }}"
        - mysql.hosts

    - name: list groups for users that have them, don't error if groups key is missing
      ansible.builtin.debug: var=item
      loop: "{{ q('ansible.builtin.subelements', users, 'groups', {'skip_missing': True}) }}"
z5
_list:
  description: list of subelements extracted
��AnsibleError)�string_types)�boolean)�
LookupBase)�listify_lookup_plugin_terms)�skip_missingc@seZdZdd�ZdS)�LookupModulecKsNddd�}t|d|jd�|d<t|t�rDdt|�krBdksJn|�t|dttf�rjt|dt�sr|d	�|d�d
�}t|dt�r�|d�dd�dur�gSg}|dD]}|�	|d|�q�n|d}i}t|�dkr�|d}t|t��st
d
d�|D���s|dt�g}	|D�]&}
t|
t��s>td|
��|
�dd�du�rT�q t
|�dd�dd�}|
}d}
g}|D]�}||dk�r�d}
||v�r�|�r��qxntd||f��|
�s�t||t��s�|�r֐qxntd|||f��n||}n2t||t��std|||f��n|�|g�}�qx|D]}|	�	|
|f��q0�q |	S)N�cSstd|��dS)Nz9subelements lookup expects a list of two or three items, r)�msg�r�F/usr/lib/python3.9/site-packages/ansible/plugins/lookup/subelements.py�_raise_terms_errords�z,LookupModule.run.<locals>._raise_terms_errorr)Ztemplar���z>first a dict or a list, second a string pointing to the subkey�.ZskippedFcss |]}t|t�o|tvVqdS)N)�
isinstancer�FLAGS)�.0�keyrrr�	<genexpr>��z#LookupModule.run.<locals>.<genexpr>z4the optional third item must be a dict with flags %sz1subelements lookup expects a dictionary, got '%s'r)�strict���Tz-could not find '%s' key in iterated item '%s'z1the key %s should point to a dictionary, got '%s'z+the key %s should point to a list, got '%s')r
)r
Z_templarr�list�len�dictr�split�get�append�allrrr�pop)�selfZtermsZ	variables�kwargsrZsubelementsZelementlistr�flags�retZitem0rZsubvalueZ
lastsubkeyZsublistZsubkeyZitem1rrr�runbs`
$  


zLookupModule.runN)�__name__�
__module__�__qualname__r*rrrrr`srN)Z
__future__rrr�typeZ
__metaclass__Z
DOCUMENTATIONZEXAMPLESZRETURNZansible.errorsrZansible.module_utils.sixrZ)ansible.module_utils.parsing.convert_boolrZansible.plugins.lookupr	Zansible.utils.listifyr
rrrrrr�<module>s7