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/roster/__pycache__/dir.cpython-310.pyc
o

�N�g8
�@sXdZddlZddlZddlZddlZddlZddlmZe�	e
�Zd	dd�Zdd�Z
dS)
a*
Create a salt roster out of a flat directory of files.

Each filename in the directory is a minion id.
The contents of each file is rendered using the salt renderer system.

Consider the following configuration for example:

config/master:

    ...
    roster: dir
    roster_dir: config/roster.d
    ...

Where the directory config/roster.d contains two files:

config/roster.d/minion-x:

    host: minion-x.example.com
    port: 22
    sudo: true
    user: ubuntu

config/roster.d/minion-y:

    host: minion-y.example.com
    port: 22
    sudo: true
    user: gentoo

The roster would find two minions: minion-x and minion-y, with the given host, port, sudo and user settings.

The directory roster also extends the concept of roster defaults by supporting a roster_domain value in config:

    ...
    roster_domain: example.org
    ...

If that option is set, then any roster without a 'host' setting will have an implicit host of
its minion id + '.' + the roster_domain. (The default roster_domain is the empty string,
so you can also name the files the fully qualified name of each host. However, if you do that,
then the fully qualified name of each host is also the minion id.)

This makes it possible to avoid having to specify the hostnames when you always want them to match
their minion id plus some domain.
�N)�CommandExecutionError�globc
	Ks�t�dd�}t�t�|�d�}t�dt|�|�t	d|||d�}i}|D]!}t
jj�
||�}tj�|�s<t|�d���t|fi|��||<q%dd	�|��D�}	t�d
t|�||t|�t|	��|	S)za
    Return the targets from the directory of flat yaml files,
    checks opts for location.
    �
roster_dirz/etc/salt/roster.d�zFiltering %d minions in %szroster_matcher.targetsZipv4z does not existcSsi|]	\}}|r||�qS�r)�.0Zid_�datarr�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/roster/dir.py�
<dictcomp>Lsztargets.<locals>.<dictcomp>zrMatched %d minions with tgt=%s and tgt_type=%s. Discarded %d matching filenames because they had rendering errors.)�__opts__�get�dict�fromkeys�os�listdir�log�debug�lenZ	__utils__�salt�utilsZverifyZ
clean_path�path�existsr�_render�items)
ZtgtZtgt_type�kwargsr�rawZmatched_rawZrenderedZ	minion_idZtarget_fileZpruned_renderedrrr	�targets<s&�rcKs�tj�ti�}t�dd�}z(tjj||tdtdtdfddi|��}|�dtj	�
|��d	|���|WStjd
|dd�iYS)
z 
    Render the roster file
    Z
roster_domainrZrendererZrenderer_blacklistZrenderer_whitelistZ
mask_valuez*passw*�host�.z"Unable to render roster file "%s".T)�exc_info)
r�loaderZrenderrr�templateZcompile_template�
setdefaultrr�basenamer�warning)Zroster_filerZ	renderers�domain�resultrrr	rXs&���	r)r)�__doc__�loggingrZsalt.loaderrZ
salt.templateZsalt.utils.verifyZsalt.exceptionsr�	getLogger�__name__rrrrrrr	�<module>s0