%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_chef.cpython-312.pyc

�

���f�0�
�0�UdZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZmZddl
mZddlmZddlmZddlmZdd	lmZd
Zegd��Zedg�Zd
ZdZdZdZdddeddedddddd�Ze dg�Z!e gd��Z"e ejFejI�e!e"gd���Z%dZ&dZ'egd��Z(ejRe*�Z+d d!ged"gd#�Z,ee-d$<d%�Z.d&�Z/d'e0d(ed)ed*e1d+df
d,�Z2d-�Z3d.ed*e1fd/�Z4	d4d.efd0�Z5d)efd1�Z6d+ee0fd2�Z7d3�Z8y)5z7Chef: module that configures, starts and installs chef.�N)�List)�subp�
temp_utils�	templater�
url_helper�util)�Cloud)�Config)�
MetaSchema)�Distro)�
PER_ALWAYS�1.8)�	/etc/chefz
/var/log/chefz
/var/lib/chef�/var/cache/chef�/var/backups/chefz
/var/run/chefrz#https://www.chef.io/chef/install.sh�z/etc/chef/validation.pemz/etc/chef/firstboot.jsonz:verify_nonez:infoz/var/log/chef/client.logz/etc/chef/client.pemrrz/var/run/chef/client.pidT)�ssl_verify_mode�	log_level�log_location�validation_key�validation_cert�
client_key�json_attribs�file_cache_path�file_backup_path�pid_file�	show_time�encrypted_data_bag_secretr)rrrrrrr)�
server_url�	node_name�environment�validation_name�chef_licensez/etc/chef/client.rbz/usr/bin/chef-client)z-dz-i�1800z-s�20�cc_chef�all�chef)�id�distros�	frequency�activate_by_schema_keys�metac��tj|dd��}|r>tjj	t
�rtjt
�yyy)N�delete_validation_post_execF��default)r�get_cfg_option_bool�os�path�isfile�CHEF_VALIDATION_PEM_PATH�unlink)�chef_cfg�
delete_pems  �:/usr/lib/python3/dist-packages/cloudinit/config/cc_chef.py�
post_run_chefr;isC���)�)��/���J��b�g�g�n�n�%=�>�
�	�	�*�+�?�z�c	���tj�}|j�D]g\}}|tvrtjd|��%|�d||<�-|tvrtj||�||<�Otj||�||<�i|jtj�tj|d|��tj|dd��|d|dd��|S)	Nz'Skipping unknown chef template key '%s'r r0r!�_defaultrr")�generated_byr r!rr")�CHEF_RB_TPL_DEFAULTS�copy�items�CHEF_RB_TPL_KEYS�LOG�debug�CHEF_RB_TPL_BOOL_KEYSrr2�get_cfg_option_str�update�make_header)�iidr8�params�k�vs     r:�get_template_paramsrNqs���
!�
&�
&�
(�F���� �A���1��$�$��I�I�?��C���9��F�1�I��)�)� �4�4�X�q�A��q�	� �3�3�H�a�@��q�	�A��M�M� �,�,�.��0�0��+�s�� �2�2��-���#�<�0�'�(9�:�	
�
��Mr<�name�cfg�cloud�args�returnc���d|vrtjd|�y|d}tj|d�}|st	t
�}t
j|t�D]}tj|��|jdt�}|jd�}|rQ|dk7rtj||�n5tjj|�stj!d|�|j#d	�}	|	r�t%|j&j)��}
t+|
|�}t-�}|j/�D]?\}
}|
t0vs�|s�|j3tjj5|���Atj6|�t9j:|	t<|�ntj!d
t<�tj>|dt@��}|stjCd
�nfi}d|vr|d|d<d|vr+|d}t	|jE��D]
}
||
||
<�tj|tGjH|��tjJ|dd��}tMjNtP�}|r|r
tS||�}n|rtjJ|dd��}nd}|rtU|�tW|�yy)z'Handler method activated by cloud-init.r(z8Skipping module named %s, no 'chef' key in configurationN�directoriesrr�systemzWchef validation_cert provided as 'system', but validation_key path '%s' does not exist.zchef_client.rbz&No template found, not rendering to %s�firstboot_pathr0z7First boot path empty, not writing first boot json file�run_list�initial_attributes�
force_installF�exec),rDrEr�get_cfg_option_list�list�	CHEF_DIRS�	itertools�chain�REQUIRED_CHEF_DIRS�
ensure_dir�getr6�
write_filer3r4r5�warning�get_template_filename�str�
datasource�get_instance_idrN�setrB�CHEF_RB_TPL_PATH_KEYS�add�dirname�ensure_dirsr�render_to_file�CHEF_RB_PATHrG�CHEF_FB_PATH�info�keys�json�dumpsr2r�is_exe�CHEF_EXEC_PATH�install_chef�run_chefr;)rOrPrQrRr8�	chef_dirs�d�	vkey_path�vcert�template_fnrJrK�param_pathsrLrM�fb_filename�initial_jsonrYrZ�	installed�runs                     r:�handler��s����S���	�	�F��	
�	��6�{�H��(�(��=�A�I����O�	�
�_�_�Y�(:�
;������������-�/G�H�I��L�L�*�+�E�
��H���O�O�I�u�-������	�*��K�K�;��
��-�-�.>�?�K���%�"�"�2�2�4�5��$�S�(�3���e���L�L�N�	4�D�A�q��)�)�a���������� 2�3�	4�	
����%�� � ��l�F�C����<�l�K��)�)��"�L��K�����J�K�����!�'/�
�';�L��$��8�+�!)�*>�!?���,�1�1�3�4�
8��"4�Q�"7��Q��
8�����T�Z�Z��%=�>��,�,��/�5��M����N�+�I��
��5�(�+��	��&�&�x���G����
�����h��r<c��tjd�tg}d|vr�|d}t|tt
f�r|j
|�nlt|t�r|j|�nJtjdt|��|j
t�n|j
t�tj|d��y)NzRunning chef-client�exec_argumentszRUnknown type %s provided for chef 'exec_arguments' expected list, tuple, or stringF��capture)
rDrErw�
isinstancer]�tuple�extendrg�appendre�type�CHEF_EXEC_DEF_ARGSr)r8�cmd�cmd_argss   r:ryry�s����I�I�#�$��
�C��8�#��,�-���h��u�
�.��J�J�x� �
��#�
&��J�J�x� ��K�K���X��	
�
�J�J�)�*��
�
�%�&��I�I�c�5�!r<�distroc�~�|j�}|jdd�}tj|j	�d��5}t
jj||�}|jd|�tj||d��tjd
d|i|��cd	d	d	�S#1swYy	xYw)aWrite blob to a tempfile, and call subp with args, kwargs. Then cleanup.

    'basename' as a kwarg allows providing the basename for the file.
    The 'args' argument to subp will be updated with the full path to the
    filename as the first argument.
    �basename�	subp_blobT)�dir�	needs_exeri�)�moderRN�)rA�popr�tempdir�get_tmp_exec_pathr3r4�join�insertrrdr)�blobr�rR�kwargsr��tmpd�tmpfs       r:�subp_blob_in_tempfiler��s����9�9�;�D��z�z�*�k�2�H�	�	�	��$�$�&�$�
�.�	
��w�w�|�|�D�(�+�����A�t������d��/��y�y�-�d�-�f�-�
.�.�.�s
�A!B3�3B<c��|�t}|�t}|�g}nd|g}tj||��j}t|||dd��S)agInstall an omnibus unified package from url.

    @param url: URL where blob of chef content may be downloaded. Defaults to
        OMNIBUS_URL.
    @param retries: Number of retries to perform when attempting to read url.
        Defaults to OMNIBUS_URL_RETRIES
    @param omnibus_version: Optional version string to require for omnibus
        install.
    z-v)�url�retrieszchef-omnibus-installF)r�r�rRr�r�)�OMNIBUS_URL�OMNIBUS_URL_RETRIESr�readurl�contentsr�)r�r�r��omnibus_versionrR�contents      r:�install_chef_from_omnibusr�sa���{�����%�������o�&��� � �S�'�:�C�C�G� ��
�
�'���r<c�f�tj|dd�}tj|dd��}|dk(rctj|dd�}tj|dt�}t	|||j
�tj|dd	��}|S|dk(r|j
j
d
g�|S|dk(rYtj|d�}t|j
tj|d
�tj|d�|��|Stjd|�d}|S)N�install_type�packagesr[Fr0�gems�version�ruby_versionTr(�omnibusr��omnibus_url�omnibus_url_retries)r�r�r�r�zUnknown chef install type '%s')rrGr2�RUBY_VERSION_DEFAULT�install_chef_from_gemsr��install_packagesr��get_cfg_option_intrDre)rQr8r�r��chef_versionr�r�s       r:rxrx.s)���*�*��.�*��L��
"�
"�8�V�U�
C�C��v���.�.�x��D�I���.�.��n�&:�
��	�|�\�5�<�<�H��&�&�x���F���J�
��	#�
���%�%�v�h�/��J�
��	"��1�1�(�<M�N��!��<�<��'�'��-�@��+�+�H�6K�L�+�		
��J�	���4�l�C����Jr<c�F�d|zd|zg}|dk(r|jd�|S)Nzruby%sz
ruby%s-devr)zlibopenssl-ruby1.8zrubygems1.8)r�)r��pkgss  r:�get_ruby_packagesr�Os0���'�)�<�'�+A�B�D��%�����9�:��Kr<c��|jt|��tjj	d�stjd|zd�tjj	d�stjd|zd�|r$tjdddd|zdd	d
ddg	d
��ytjgd�d
��y)N�/usr/bin/gemz/usr/bin/gem%sz
/usr/bin/rubyz/usr/bin/ruby%s�installr(z-v %s�--no-ri�	--no-rdoc�--bindir�/usr/bin�-qFr�)r�r�r(r�r�r�r�r�)r�r�r3r4�existsr�sym_linkr)r�r�r�s   r:r�r�Ws���
���-�l�;�<�
�7�7�>�>�.�)��
�
�&��5�~�F�
�7�7�>�>�/�*��
�
�'�,�6��H���	�	�����,�&������

��
	
�	
�	�	�	
��	
r<)NNN)9�__doc__r_rt�loggingr3�typingr�	cloudinitrrrrr�cloudinit.cloudr	�cloudinit.configr
�cloudinit.config.schemar�cloudinit.distrosr�cloudinit.settingsr
r�r�r^rar�r�r6rqr@�	frozensetrFrkr`rsrCrprwr��	getLogger�__name__rDr-�__annotations__r;rNrgr]r�ryr�r�rxr�r�r�r<r:�<module>r�s���>����	��C�C�!�#�.�$�)�����	
�	������4����5��)��&��.�.��(� �(�+�*��!%��� "�;�-�0��!��
����I�O�O��!�!�#���	
�	�
��%��'���;�<���g����!����w�� &�x�	��j��,� �FO ��O �6�O �%�O �t�O ��O �d"�,.��.�d�.�(=A����>���B�$�s�)��"
r<

Zerion Mini Shell 1.0