HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/sdb/__pycache__/vault.cpython-310.pyc
o

�N�g��@s>dZddlZddlZe�e�ZddiZddd�Zddd�Z	dS)	aQ
Vault SDB Module

:maintainer:    SaltStack
:maturity:      New
:platform:      all

.. versionadded:: 2016.11.0

This module allows access to Hashicorp Vault using an ``sdb://`` URI.

Base configuration instructions are documented in the execution module docs.
Below are noted extra configuration required for the sdb module, but the base
configuration must also be completed.

Like all sdb modules, the vault module requires a configuration profile to
be configured in either the minion configuration file or a pillar. This profile
requires only setting the ``driver`` parameter to ``vault``:

.. code-block:: yaml

    myvault:
      driver: vault

Once configured you can access data using a URL such as:

.. code-block:: yaml

    password: sdb://myvault/secret/passwords/mypassword

In this URL, ``myvault`` refers to the configuration profile,
``secret/passwords`` is the path where the data resides, and ``mypassword`` is
the key of the data to return.

The above URI is analogous to running the following vault command:

.. code-block:: bash

    $ vault read -field=mypassword secret/passwords
�N�set_�setc	
Cs�d|vr|�d�\}}n|�dd�\}}||i}td|�}|dr*|d}d|i}zd|��}tdd	||d
�}|jdkrB|��WdSty`}zt�d
t|�j	|�t
j�|��d}~ww)z3
    Set a key/value pair in the vault service
    �?�/��vault.is_v2�v2�data�v1/�vault.make_request�POST)�json��TzFailed to write secret! %s: %sN)
�split�rsplit�	__utils__�status_code�raise_for_status�	Exception�log�error�type�__name__�salt�
exceptions�CommandExecutionError)	�key�value�profile�pathr	�version2�url�response�e�r$�B/opt/saltstack/salt/lib/python3.10/site-packages/salt/sdb/vault.pyr3s&

��c
CsJd|vr|�d�\}}n|�dd�\}}td|�}|dr"|d}zfd|��}tdd	|�}|jd
krX|drU|dd|}d|��}tdd	|�}|jd
krTWdSnWdS|jdkra|��|��d}|dr}||dvrx|d|WS|dWS||vr�||WSWdSty�}zt�d
t	|�j
|�tj�
|��d}~ww)z,
    Get a value from the vault service
    rrrrrr	r
rZGETi�N��zFailed to read secret! %s: %s)rrrrrr
rrrrrrrr)rrrr r!r"r	r#r$r$r%�getNsB



�


��r')N)
�__doc__�loggingZsalt.exceptionsr�	getLoggerrrZ__func_alias__rr'r$r$r$r%�<module>s)