Current File : //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_puppet.cpython-312.pyc
�

Ӈg�*�
�\�UdZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlZddlm
Z
mZmZmZmZddlmZddlmZdd	lmZdd
lmZmZmZddlmZdZd
gZdZ degedgd�Z!ee"d<ejFe$�Z%Gd�d�Z&dede'fd�Z(d�Z)edddfdefd�Z*de'dedede+ddf
d �Z,y)!z+Puppet: Install, configure and start puppet�N)�suppress)�StringIO)�List�Union)�helpers�subp�
temp_utils�
url_helper�util)�Cloud)�Config)�
MetaSchema)�ALL_DISTROS�Distro�PackageInstallerError)�PER_INSTANCEzKhttps://raw.githubusercontent.com/puppetlabs/install-puppet/main/install.shz--test)�puppet-agent�puppet�	cc_puppetr)�id�distros�	frequency�activate_by_schema_keys�metac��eZdZd�Zy)�PuppetConstantsc���||_||_tjj	|d�|_tjj	|j
d�|_||_y)N�certszca.pem)�	conf_path�ssl_dir�os�path�join�ssl_cert_dir�
ssl_cert_path�csr_attributes_path)�self�puppet_conf_file�puppet_ssl_dirr&s    �</usr/lib/python3/dist-packages/cloudinit/config/cc_puppet.py�__init__zPuppetConstants.__init__*sN��*���%����G�G�L�L���A����W�W�\�\�$�*;�*;�X�F���#6�� �N)�__name__�
__module__�__qualname__r+�r,r*rr)s��
7r,r�cloud�actionc���d}tD]%}	|jj||�d��|}n|s+t
j
d|djt��yy#tj$rY�kwxYw)z8Attempts to perform action on one of the puppet services�z.servicez0Could not '%s' any of the following services: %s�, N)�PUPPET_PACKAGE_NAMES�distro�manage_servicer�ProcessExecutionError�LOG�warningr#)r1r2�service_managed�puppet_names    r*�_manage_puppet_servicesr>7s����O�+���	��L�L�'�'��;�-�x�0H�I�)�O��	�����>���I�I�*�+�	
����)�)�	��	�s�!A�A5�4A5c�Z�tj|dd|g�\}}|j�S)z�Get the config value for a given setting using `puppet config print`
    :param puppet_bin: path to puppet binary
    :param setting: setting to query
    �config�print)r�rstrip)�
puppet_bin�setting�out�_s    r*�get_config_valuerGIs+��
�Y�Y�
�H�g�w�?�
@�F�C���:�:�<�r,Tr7c��g}|�d|g}|�|d|gz
}|r|dgz
}tj|d��j}tj|j�d��5}tjj|d	�}tj||d
��tj|g|zd�
�cddd�S#1swYyxYw)a�Install puppet-agent from the puppetlabs repositories using the one-shot
    shell script

    :param distro: Instance of Distro
    :param url: URL from where to download the install script
    :param version: version to install, blank defaults to latest
    :param collection: collection to install, blank defaults to latest
    :param cleanup: whether to purge the puppetlabs repo after installation
    Nz-vz-cz	--cleanup�)�url�retriesT)�dir�	needs_exezpuppet-installi�)�modeF��capture)r
�readurl�contentsr	�tempdir�get_tmp_exec_pathr!r"r#r�
write_filer)	r7rJ�version�
collection�cleanup�args�content�tmpd�tmpfs	         r*�install_puppet_aior]Rs��� �D����g�������z�"�"�����
���� � �S�!�4�=�=�G�
�	�	��$�$�&�$�
�7�	
��w�w�|�|�D�"2�3������g�E�2��y�y�$��$���6�7�7�7�s
� AB=�=C�name�cfgrY�returnc�f�d|vrtjd|�y|d}tj|dd�}tj|dd�}tj|dd�}tj|dd�}tj|d	d�}	tj|d
d��}
tj|d
d��}tj|dt
��}|dk(rd}
d}d}nd}
d}d}tj|d|�}|s|rtj
d�n�|r�tjd|r|nd|�|dk(r�|�xtD]C}tt�5|r||ggn|g}|jj|�|}	ddd�n|s�tj
ddjt��n]|r||ggn|g}|jj|�n7|dk(rt|j||||	�ntj
d|�d}
tj|dt|d��}tj|dt|d��}tj|dt|d��}t|||�}d |v�rYtj |j"�}t%j&�}|j)�D�cgc]}|j+���}}d!j|�}|j-t/|�|j"�"�|d j1�D�]�\}}|d#k(r�tj2|j4d$�tj6|j4|
d�tj2|j8�tj6|j8|
d�tj:|j<|�tj6|j<|
d�n�|j1�D]q\}}|d%k(rT|j?d&tAjB��}|j?d'|jE��}|jG�}|jI|||��stjJ|j"d(|j"z�tj:|j"|jM�����d|vr8tj:|jNtQjR|dd�)��|rtU|d*�|
r�tjd+�|d,g}d-|vr�|d-} tW| tXtZf�r|j]| �nztW| t^�r |j]| ja��nJtj
d.tc| ��|j]td�n|j]td�tgjf|d�/�|r
tU|d0�yy#1swY���xYwcc}w)1Nrz9Skipping module named %s, no 'puppet' configuration found�installTrVrW�install_type�packagesrX�execF)�default�
start_service�aio_install_url�aio�rootz/opt/puppetlabs/bin/puppetr�package_namez@Puppet install set to false but version supplied, doing nothing.z'Attempting to install puppet %s from %s�latestz+No installable puppet package in any of: %sr5z Unknown puppet install type '%s'�	conf_filer@r �ssldirr&�csr_attributes�conf�
)�source�ca_certi��certnamez%fz%iz%s.old)�default_flow_style�enablezRunning puppet-agent�agent�	exec_argszOUnknown type %s provided for puppet 'exec_args' expected list, tuple, or stringrO�start)4r:�debugr�get_cfg_option_bool�get_cfg_option_str�AIO_INSTALL_URLr;r6rrr7�install_packagesr#r]rGr�load_text_filerr�DefaultingConfigParser�
splitlines�lstrip�	read_filer�items�
ensure_dirr �chownbynamer$rUr%�replace�socket�getfqdn�get_instance_id�lower�set�rename�	stringifyr&�yaml�dumpr>�
isinstance�list�tuple�extend�str�split�type�PUPPET_AGENT_DEFAULT_ARGSr)!r^r_r1rY�
puppet_cfgrbrVrWrcrX�run�
start_puppetdrh�puppet_userrC�puppet_packagerkr=�
to_installrmr r&�p_constantsrR�
puppet_config�i�
cleaned_lines�cleaned_contents�cfg_name�o�v�cmd�cmd_argss!                                 r*�handler�vs����s���	�	�G��	
�	��X��J��&�&�z�9�d�C�G��%�%�j�)�T�B�G��(�(��\�4�H�J��*�*��N�J��L��&�&�z�9�d�C�G�
�
"�
"�:�v�u�
E�C��,�,��O�T��M��-�-��%���O�
�u����1�
�'�����
����*�*��N�N��L��w����N�	
�
��	�	�5��G�H��	
��:�%��#�#7�	�K�!�"7�8�� '�*�7�3�4�"-��#�
���5�5�j�A�'2�����	�$��K�K�E��	�	�"6�7��29�l�G�,�-�|�n�����-�-�j�9�
�U�
"�����o�w�
�G�
�
�K�K�:�L�I��C��'�'��K�!1�*�h�!G��I��%�%��I�/�
�H�E��G��1�1�����%5�6���"�)�W�6I�J�K�����&�&�{�'<�'<�=���6�6�8�
�.6�-@�-@�-B�C������C�
�C��9�9�]�3������%�&�{�/D�/D�	 �	
�(��/�5�5�7�!	N�M�H�c��9�$����� 3� 3�U�;�� � ��!4�!4�k�6�J����� 8� 8�9�� � ��!9�!9�;��O����� 9� 9�3�?�� � ��-�-�{�F�� �I�I�K�	6�D�A�q��J���I�I�d�F�N�N�,<�=���I�I�d�E�,A�,A�,C�D���G�G�I��!�%�%�h��1�5�	6�
�K�K��%�%�x�;�3H�3H�'I�
�
�O�O�K�1�1�=�3J�3J�3L�M�C!	N�F�:�%�����+�+��I�I�j�!1�2�u�M�	
�
���x�0���	�	�(�)��7�#���*�$�!�+�.�H��(�T�5�M�2��
�
�8�$��H�c�*��
�
�8�>�>�+�,����!���N�	��
�
�4�5��J�J�0�1��	�	�#�u�%����w�/��w���fDs�)X!�X.�!X+	)-�__doc__�loggingr!r��
contextlibr�ior�typingrrr��	cloudinitrrr	r
r�cloudinit.cloudr�cloudinit.configr
�cloudinit.config.schemar�cloudinit.distrosrrr�cloudinit.settingsrr}r�r6r�__annotations__�	getLoggerr-r:rr�r>rGr]r�r�r0r,r*�<module>r�s���2��	�
�����A�A�!�#�.�H�H�+�_��%�J��1����}�� (�z�	��j���g����!��7�7�
�5�
�#�
�$�	����!7��!7�Hr0��r0�6�r0�%�r0�t�r0��r0r,