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__/cloud.cpython-310.pyc
o

�N�gs�@sJdZddlZddlZddlZddlZddlZddlZddd�Zdd�Z	dS)	a�
Use the cloud cache on the master to derive IPv4 addresses based on minion ID.

This roster requires that the minion in question was created using at least the
2015.5.0 version of Salt Cloud. Starting with the 2015.5.0 release, Salt Cloud
maintains an index of minions that it creates and deletes. This index tracks the
provider and profile configuration used to provision the minion, including
authentication information. So long as this configuration remains current, it can
be used by Salt SSH to log into any minion in the index.

To connect as a user other than root, modify the cloud configuration file
usually located at /etc/salt/cloud. For example, add the following:

.. code-block:: yaml

    ssh_username: my_user
    sudo: True
�N�globcKs�i}tj�tj�tj�td�d��}td|�}|�	�D]�\}}|�
dd�|�
dd�}}	|	|d�}
|�
dg�}|�
d	g�}g}
||fD]}t|t�rQ|
|}
qEt|t
�r[|
�|�qEt�
d
d�}t||
�}t�t�
di��||<||�d
|i�tjj�|
|�}t|t
�r�|||d<nt|t�r�|ddkr�|d||d<tjjd|
|ddd�}|r�|||d<tjjd|
|ddd�}|r�|||d<tjjd|
|ddd�}|r�|||d<q|S)zs
    Return the targets from the flat yaml file, checks opts for location but
    defaults to /etc/salt/roster
    Z	conf_file�cloudzcache.cloud�profileN�provider)Zdriverr�
public_ips�private_ips�roster_order)�public�private�localZroster_defaults�host�userr�rootZssh_passwordF)Z
search_global�default�passwordZprivate_keyZpriv�sudo)�saltZconfigZcloud_config�os�path�join�dirnameZ__opts__Z
__runner__�items�get�
isinstance�list�str�append�extract_ipv4�copy�deepcopy�update�utilsrZ
ssh_usernamesZget_cloud_config_value)ZtgtZtgt_type�kwargs�retZ
cloud_optsZminionsZ	minion_idZ	full_inforrZvm_rrZip_list�itemrZpreferred_ipZssh_usernamerZkey_filenamer�r%�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/roster/cloud.py�targetss`�

��



�



�
�
��r'cCs�|D]F}|D]A}d|vr
qtjjj�|�sq|dkr%|�d�r%|S|dkr6tjj�|�s6|S|dkrGtjj�|�rG|SqqdS)z>
    Extract the preferred IP address from the ipv4 grain
    �:rz127.r
r	N)rr!�validate�netZ	ipv4_addr�
startswithrZis_public_ip)rZipv4Zip_typeZip_r%r%r&r]s��r)r)
�__doc__rrZsalt.configrZsalt.loaderZsalt.utils.cloudZsalt.utils.validate.netr'rr%r%r%r&�<module>s
@