HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_salt_minion.cpython-310.pyc
o

�Ad$�@s�UdZddlZddlmZddlmZddlmZmZm	Z	ddl
mZddlm
Z
ddlmZmZdd	lmZmZdd
lmZdZdd
deegeed�gdgd�Zeed<ee�ZGdd�d�Zdede
dedededdfdd�ZdS)z&Salt Minion: Setup and run salt minion�N)�Logger)�dedent)�safeyaml�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS�	bsd_utils)�PER_INSTANCEa.This module installs, configures and starts salt minion. If the ``salt_minion``
key is present in the config parts, then salt minion will be installed and
started. Configuration for salt minion can be specified in the ``conf`` key
under ``salt_minion``. Any conf values present there will be assigned in
``/etc/salt/minion``. The public and private keys to use for salt minion can be
specified with ``public_key`` and ``private_key`` respectively. Optionally if
you have a custom package name, service name or config directory you can
specify them with ``pkg_name``, ``service_name`` and ``config_dir``.

Salt keys can be manually generated by: ``salt-key --gen-keys=GEN_KEYS``,
where ``GEN_KEYS`` is the name of the keypair, e.g. 'minion'.  The keypair
will be copied to ``/etc/salt/pki`` on the minion instance.
�cc_salt_minionzSalt MinionzSetup and run salt miniona�            salt_minion:
                pkg_name: salt-minion
                service_name: salt-minion
                config_dir: /etc/salt
                conf:
                    master: salt.example.com
                grains:
                    role:
                        - web
                public_key: |
                    ------BEGIN PUBLIC KEY-------
                    <key data>
                    ------END PUBLIC KEY-------
                private_key: |
                    ------BEGIN PRIVATE KEY------
                    <key data>
                    ------END PRIVATE KEY-------
                pki_dir: /etc/salt/pki/minion
            �salt_minion)�id�name�title�description�distros�	frequency�examples�activate_by_schema_keys�metac@seZdZdZdd�ZdS)�
SaltConstantsz>
    defines default distribution specific salt variables
    cCsht��rd|_d|_d|_n	d|_d|_d|_t�|d|j�|_t�|d|j�|_t�|d|j�|_dS)	Nzpy-saltrz/usr/local/etc/saltzsalt-minionz	/etc/salt�pkg_name�
config_dir�service_name)r�
is_FreeBSDr�srv_name�conf_dir�get_cfg_option_str)�self�cfg�r#�A/usr/lib/python3/dist-packages/cloudinit/config/cc_salt_minion.py�__init__Ns�
�zSaltConstants.__init__N)�__name__�
__module__�__qualname__�__doc__r%r#r#r#r$rIsrrr"�cloud�log�args�returncCs�d|vr|�d|�dS|d}t|d�}|j�|j�t�|j�d|vr<tj	�
|jd�}t�|�
d��}t�||�d|vrVtj	�
|jd�}	t�|�
d��}
t�|	|
�d|vr�d|vr�tj	�
|jd	�}tj	�|�sttj	�
|jd
�}|�
d|�}t�d��+t�|�tj	�
|d
�}
tj	�
|d�}t�|
|d�t�||d�Wd�n1s�wY|jjdkr�t�dd�tjd|jdgdd�dS)Nrz?Skipping module named %s, no 'salt_minion' key in configuration)r"�conf�minion�grains�
public_key�private_keyz
pki/minion�pki�pki_dir�?z
minion.pubz
minion.pem�freebsd�salt_minion_enable�YES�service�restartF)�capture)�debugr�distro�install_packagesrr�
ensure_dirr�os�path�joinr�dumps�get�
write_file�isdir�umask�osfamilyr�set_rc_config_valuerr)rr"r*r+r,�s_cfg�const�
minion_config�minion_data�
grains_config�grains_data�pki_dir_defaultr4�pub_name�pem_namer#r#r$�handleesB�

�	rS)r)r@�loggingr�textwrapr�	cloudinitrrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar	r
�cloudinit.distrosrr�cloudinit.settingsr
�MODULE_DESCRIPTIONr�__annotations__r�str�listrSr#r#r#r$�<module>sL���"������