File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/__pycache__/rethinkdb_pillar.cpython-310.pyc
Back
o ;j� � @ sj d Z ddlZzddlZdZW n ey dZY nw dZdddddd�Zd d � Ze�e �Z ddd �ZdS )a� Provide external pillar data from RethinkDB .. versionadded:: 2018.3.0 :depends: rethinkdb (on the salt-master) salt master rethinkdb configuration =================================== These variables must be configured in your master configuration file. * ``rethinkdb.host`` - The RethinkDB server. Defaults to ``'salt'`` * ``rethinkdb.port`` - The port the RethinkDB server listens on. Defaults to ``'28015'`` * ``rethinkdb.database`` - The database to connect to. Defaults to ``'salt'`` * ``rethinkdb.username`` - The username for connecting to RethinkDB. Defaults to ``''`` * ``rethinkdb.password`` - The password for connecting to RethinkDB. Defaults to ``''`` salt-master ext_pillar configuration ==================================== The ext_pillar function arguments are given in single line dictionary notation. .. code-block:: yaml ext_pillar: - rethinkdb: {table: ext_pillar, id_field: minion_id, field: pillar_root, pillar_key: external_pillar} In the example above the following happens. * The salt-master will look for external pillars in the 'ext_pillar' table on the RethinkDB host * The minion id will be matched against the 'minion_id' field * Pillars will be retrieved from the nested field 'pillar_root' * Found pillars will be merged inside a key called 'external_pillar' Module Documentation ==================== � NTF� rethinkdb�saltZ28015)�rethinkdb.host�rethinkdb.port�rethinkdb.database�rethinkdb.username�rethinkdb.passwordc C s t sdS dS )NFT)� HAS_RETHINKDB� r r �P/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/rethinkdb_pillar.py�__virtual__C s r �pillarc C sb t d }t d }t d }t d } t d } t�d||| � tj|||| | d�}d}zX|rTt�d ||| � |rFt�|��|| i��|��|�}n1t�|��|| i��|�}n#t�d || � |rlt�|�� | ��|��|�}nt�|�� | ��|�}W |� � r�|�� n |� � r�|�� w w |jr�t |j�dkr�t�d| � i S |j�� } |r�|| iS | S t�d � i S )au Collect minion external pillars from a RethinkDB database Arguments: * `table`: The RethinkDB table containing external pillar information. Defaults to ``'pillar'`` * `id_field`: Field in document containing the minion id. If blank then we assume the table index matches minion ids * `field`: Specific field in the document used for pillar data, if blank then the entire document will be used * `pillar_key`: The salt-master will nest found external pillars under this key before merging into the minion pillars. If blank, external pillars will be merged at top level r r r r r z9Connecting to %s:%s as user '%s' for RethinkDB ext_pillar)�host�portZdb�user�passwordNzIext_pillar.rethinkdb: looking up pillar. table: %s, field: %s, minion: %szIext_pillar.rethinkdb: looking up pillar. table: %s, field: id, minion: %s� z=ext_pillar.rethinkdb: ambiguous documents found for minion %sz'ext_pillar.rethinkdb: no document found)�__opts__�log�debugr �connect�table�filterZpluck�run�getZis_open�close�items�len�error�pop)Z minion_idr r Zid_field�fieldZ pillar_keyr r Zdatabase�usernamer �conn�data�resultr r r � ext_pillarM st � �� ����� �� r% )r NNN)�__doc__�loggingr r �ImportErrorZ__virtualname__r r � getLogger�__name__r r% r r r r �<module> s&