File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/idem.cpython-310.pyc
o
�N�g� � @ sN d Z ddlZddlZdZdd� Zdd� Zdd � Z
d
dd�ZdS )z^
Idem Support
============
This state provides access to idem states
.. versionadded:: 3002
� N�idemc C s dt v rtS dS )N�idem.hub)Fzidem is not available)� __utils__�__virtualname__� r r �D/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/idem.py�__virtual__ s r c C s� g }g }|r|� d|� �� | D ]2}t�|�}|�� r=t|jdkr$|jn|j�}|� |� d|j� �}||vr<|� |� q|� |� q||fS )z-
Determine where the sls sources are
zfile://z.sls) �append�pathlib�Path�is_file�str�suffix�stem�name�parent)Zsources�tree�sls_sources�SLSs�sls�path�refZimpliedr r r � _get_refs s
�r c C s2 t �d| �}|�d�|�d�|�d�|�d�d�S )z9
Get salt-style low data from an idem state name
z(.+)_\|-(.+)_\|-(.+)_\|-(.+)� � � � )�stateZ__id__r Zfun)�re�match�group)Zlow_datar r r r �
_get_low_data/ s �r! Fc
C s2 t d � }
t|t�r
|g}t||p|
jjj�\}}|
jjj| ||p%|
jjj |p+|
jjj
dg|p3|
jjj|| |p;|
jjj
|pA|
jjj|pI|
jjjpIdd�}
|
jj�|
� |
jj| d }| }g }|
jj| d �� D ]\}}|d |d |d |�d
�t|�d�}|�|� qj| ||r�dt|�� d
�n|i |d�S )as
Execute an idem sls file through a salt state
sls
A list of idem sls files or sources
acct_file
Path to the acct file used in generating idem ctx parameters.
Defaults to the value in the ACCT_FILE environment variable.
acct_key
Key used to decrypt the acct file.
Defaults to the value in the ACCT_KEY environment variable.
acct_profile
Name of the profile to add to idem's ctx.acct parameter
Defaults to the value in the ACCT_PROFILE environment variable.
cache_dir
The location to use for the cache directory
render
The render pipe to use, this allows for the language to be specified (jinja|yaml)
runtime
Select which execution runtime to use (serial|parallel)
source_dir
The directory containing sls files
.. code-block:: yaml
cheese:
idem.state:
- runtime: parallel
- sls:
- idem_state.sls
- sls_source
:maturity: new
:depends: acct, pop, pop-config, idem
:platform: all
r Zstates�default)r r �render�runtimeZsubs� cache_dirr �test� acct_file�acct_key�acct_profile�errors�runningr �changes�result�comment)r r, r- r. �lowzRan z idem states)r r- r. r, Z
sub_state_run)r �
isinstancer
r ZOPTr r r Zapplyr# r$ r% Zacctr'