HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_ansible.cpython-311.pyc
�

܍~c�!���UdZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lmZmZdd
lmZmZddlmZddlmZmZdd
lmZmZdddeegdged��ed��ed��gd�Z ee!d<ee ��Ze	e"��Z#dZ$Gd�dej%��Z&Gd�de&��Z'Gd�de&��Z(de)ded ed!ed"e*d#dfd$�Z+de,fd%�Z-de,d#e,fd&�Z.d'e&de,fd(�Z/de,de&fd)�Z0de,de&fd*�Z1dS)+z9ansible enables running on first boot either ansible-pull�N)�deepcopy)�Logger�	getLogger)�dedent)�Optional)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS�Distro)�PER_INSTANCE)�subp�which)�Version�get_cfg_by_path�
cc_ansible�AnsiblezConfigure ansible for instance�ansiblea        This module provides ``ansible`` integration for
        augmenting cloud-init's configuration of the local
        node.


        This module installs ansible during boot and
        then uses ``ansible-pull`` to run the playbook
        repository at the remote URL.
        z�            ansible:
              install_method: distro
              pull:
                url: "https://github.com/holmanb/vmboot.git"
                playbook_name: ubuntu.yml
            z�            ansible:
              package_name: ansible-core
              install_method: pip
              pull:
                url: "https://github.com/holmanb/vmboot.git"
                playbook_name: ubuntu.yml
            )�id�name�title�	frequency�distros�activate_by_schema_keys�description�examples�meta�ansible_configc��eZdZdefd�Zdeefd�Zdefd�Z	d�Z
defd�Zd	�Z
ejd
���Zejdefd���Zd
S)�AnsiblePull�distroc��dg|_ddg|_||_tj|_d|_|j�dd��|jd<dS)Nzansible-pullz	--version�HOMEz/root)�cmd_pull�cmd_versionr"�os�environ�env�run_user�get)�selfr"s  �=/usr/lib/python3/dist-packages/cloudinit/config/cc_ansible.py�__init__zAnsiblePull.__init__CsT��'�(��
�*�K�8�������:���'+��
� �8�<�<���8�8��������returnc��|�|j��\}}|����d��}t	jd|��}|r)|�d��}tj|��SdS)Nrz	([\d\.]+))	�do_asr&�
splitlines�pop�re�search�groupr�from_str)r,�stdout�_�
first_line�matches�versions      r-�get_versionzAnsiblePull.get_versionNsy���J�J�t�/�0�0�	����&�&�(�(�,�,�Q�/�/�
��)�L�*�5�5���	-��m�m�A�&�&�G��#�G�,�,�,��tr/c�H�|�g|j�|���\}}|S�N)r2r%)r,�argsr9r:s    r-�pullzAnsiblePull.pullWs)���J�J�6���6��6�7�7�	����
r/c�L�|���std���dS)Nz!command: ansible is not installed)�is_installed�
ValueError�r,s r-�
check_depszAnsiblePull.check_deps[s2��� � �"�"�	B��@�A�A�A�	B�	Br/�commandc�^�|js|j|fi|��S|jj||jfi|��Sr@)r*rr"r2�r,rH�kwargss   r-r2zAnsiblePull.do_as_sG���}�	0��4�9�W�/�/��/�/�/� �t�{� ��$�-�B�B�6�B�B�Br/c�*�t|fd|ji|��S)Nr))rr)rJs   r-rzAnsiblePull.subpds���G�4�4���4�V�4�4�4r/c��dSr@�rFs r-rDzAnsiblePull.is_installedg����r/�pkg_namec��dSr@rN�r,rPs  r-�installzAnsiblePull.installkrOr/N)�__name__�
__module__�__qualname__r
r.rrr>�strrBrG�listr2r�abc�abstractmethodrDrSrNr/r-r!r!Bs�������	9�v�	9�	9�	9�	9��X�g�.������S�����B�B�B�C�T�C�C�C�C�
5�5�5�	��
�
���
�	��
��
�
�
���
�
�
r/r!c�L��eZdZdedeef�fd�Zdefd�Zdefd�Z	�xZ
S)�AnsiblePullPipr"�userc�:��t���|��||_|�tjddg��\}}|�d�}|j�d��}|r!d�||g��|jd<dS||jd<dS)Nz-cz('import site; print(site.getuserbase())'z/bin/�PATH�:)	�superr.r*r2�sys�
executabler)r+�join)r,r"r]�	user_baser:�ansible_path�old_path�	__class__s       �r-r.zAnsiblePullPip.__init__qs����
������ � � ���
��z�z�
�^�T�#M�N�
�
��	�1�$�*�*�*���8�<�<��'�'���	,�"�x�x��<�(@�A�A�D�H�V����+�D�H�V���r/rPc�f�|���s�	ddl}n4#t$r'|j�|jj��YnwxYwtjdddg}|jr|�	d��|�
g|�d�d���|�
g|�|���dSdS)zishould cloud-init grow an interface for non-distro package
        managers? this seems reusable
        rN�-m�piprSz--userz	--upgrade)rDrk�ImportErrorr"�install_packages�pip_package_namerbrcr*�appendr2)r,rPrk�cmds    r-rSzAnsiblePullPip.install�s���� � �"�"�
	)�
K��
�
�
�
���
K�
K�
K���,�,�T�[�-I�J�J�J�J�J�
K�����>�4��	�:�C��}�
%��
�
�8�$�$�$��J�J�1��1�k�1�5�1�2�2�2��J�J�'��'�h�'�(�(�(�(�(�
	)�
	)s��.A�Ar0c�V�|�tjdddg��\}}d|vS)NrjrkrXr)r2rbrc)r,r9r:s   r-rDzAnsiblePullPip.is_installed�s-���J�J����e�V�D�E�E�	����F�"�"r/)rTrUrVr
rrWr.rS�boolrD�
__classcell__)rhs@r-r\r\ps��������
,�v�
,�X�c�]�
,�
,�
,�
,�
,�
,�)��)�)�)�)� #�d�#�#�#�#�#�#�#�#r/r\c�&�eZdZdefd�Zdefd�ZdS)�AnsiblePullDistrorPc�f�|���s|j�|��dSdSr@)rDr"rmrRs  r-rSzAnsiblePullDistro.install�s<��� � �"�"�	3��K�(�(��2�2�2�2�2�	3�	3r/r0c�:�ttd����S)Nr)rrrrFs r-rDzAnsiblePullDistro.is_installed�s���E�)�$�$�%�%�%r/N)rTrUrVrWrSrrrDrNr/r-ruru�sJ������3��3�3�3�3�&�d�&�&�&�&�&�&r/rur�cfg�cloud�logrAr0c���|�di��}|�d��}|�d��}|�d��}|�d��}	|�d��}
|�dd��}|r�t|��|j}|d	krt||��}
nt	|��}
|
�|��|
���|�d
d��}|r||
jt<|	rt|	|
��|
rt|
t|
����|rt||
��dSdSdS)Nrr*�install_method�setup_controller�galaxyrB�package_name�rkr)
r+�validate_configr"r\rurSrGr)�CFG_OVERRIDE�ansible_galaxy�run_ansible_pullr�ansible_controller)rrxryrzrA�ansible_cfg�ansible_userr|r}�
galaxy_cfg�pull_cfgrr"rrs               r-�handler��s�����	�2�.�.�K��?�?�:�.�.�L� �_�_�%5�6�6�N�"���'9�:�:������*�*�J����v�&�&�H��?�?�>�2�6�6�L��:���$�$�$�����U�"�"�$�V�\�:�:�G�G�'��/�/�G�����%�%�%�������$���)9�2�>�>���	7�(6�G�K��%��	0��:�w�/�/�/��	:��W�h�x�&8�&8�9�9�9��	:��/��9�9�9�9�9�/:�:�,	:�	:r/c���d}|D]'}t||��std|�d|������(|�d��r*dD]'}t||��std|�d|������(|�d��}|rIt|�d��|�d��g��std	|�����|d
}|dvrtd���dS)
N)r|rzMissing required key 'z' from rB)zpull/urlzpull/playbook_namer}�repositories�run_ansiblezMissing required key from r|)rkr"z Invalid install method {install})rrEr+�any)rx�
required_keys�key�controller_cfgrSs     r-r�r��sN���M��I�I���s�C�(�(�	I��G�c�G�G�#�G�G�H�H�H�	I�
�w�w�v���M�3�	M�	M�C�"�3��,�,�
M� �!K�#�!K�!K�c�!K�!K�L�L�L�
M��W�W�/�0�0�N��L���"�"�>�2�2��"�"�=�1�1�
�
�
�	L��J�.�J�J�K�K�K��"�#�G��'�'�'��;�<�<�<�(�'r/c�>�d�|���D��S)zremove boolean false valuesc�J�i|] \}}|du�	|�dd��|��!S)Fr:�-)�replace��.0r��values   r-�
<dictcomp>zfilter_args.<locals>.<dictcomp>�sA������S�%�����	���C����u���r/)�items)rxs r-�filter_argsr��s+�����I�I�K�K����r/rBc	���|�d��}|���}|st�d��nR|t	ddd��kr=|�d��r(t
d|j�d|j�d|j	�d	����|j
gd
�t|�����D���|�R�}|r"tj�|���dSdS)N�
playbook_namezCannot parse ansible version��r�diffzAnsible version �.z%doesn't support --diff flag, exiting.c�6�g|]\}}|durd|�d|��nd|����S)T�--�=rNr�s   r-�
<listcomp>z$run_ansible_pull.<locals>.<listcomp>�sR��

�

�

���U�#(�t�"3�"3�����u�����c���

�

�

r/)r4r>�LOG�warningrr+rE�major�minor�patchrBr�r�rbr9�write)rBrxr��vr9s     r-r�r��s<������1�1�M������A������2�3�3�3�3�	
�W�Q��1�
�
�	�	��7�7�6�?�?�	��8�1�7�8�8�Q�W�8�8�q�w�8�8�8���
��T�Y��

�

�)�#�.�.�4�4�6�6�

�

�

��
	����F��&��
���F��%�%�%�%�%�&�&r/c��|�dg��}|st�d|��|D]}|�|���dS)N�actionszInvalid config: %s)r+r�r�r2)rxrr�rHs    r-r�r�s`���g�g�i��$�$�G��/����(�#�.�.�.������
�
�g������r/c��|�dg��D]'}|�dd|d|dg���(|�dg��D]r}|�d��}|�d��}d	|gd
�t|�����D���}|�||����sdS)Nr��git�clone�source�pathr��playbook_dirr�zansible-playbookc�$�g|]
\}}d|�d|����S)r�r�rNr�s   r-r�z&ansible_controller.<locals>.<listcomp>s-��
M�
M�
M�Z�S�%� �3� � �� � �
M�
M�
Mr/)�cwd)r+r2r4r�r�)rxr�
repositoryrAr�r�rHs       r-r�r�s����g�g�n�b�1�1�
�
�
��
�
�
�G�Z��1�:�f�3E�F�	
�	
�	
�	
����
�r�*�*�1�1���x�x��/�/������1�1�
���
�N�
M�;�t�3D�3D�3J�3J�3L�3L�
M�
M�
M�
��
	�
�
�g�<�
�0�0�0�0�1�1r/)2�__doc__rYr'r5rb�copyr�loggingrr�textwrapr�typingr�cloudinit.cloudr�cloudinit.configr	�cloudinit.config.schemar
r�cloudinit.distrosrr
�cloudinit.settingsr�cloudinit.subprr�cloudinit.utilrrr�__annotations__rTr�r��ABCr!r\rurWrXr��dictr�r�r�r�r�rNr/r-�<module>r�s*��?�?�?�
�
�
�
�	�	�	�	�	�	�	�	�
�
�
�
�������%�%�%�%�%�%�%�%�������������!�!�!�!�!�!�#�#�#�#�#�#�<�<�<�<�<�<�<�<�1�1�1�1�1�1�1�1�+�+�+�+�+�+�&�&�&�&�&�&�&�&�3�3�3�3�3�3�3�3���
-���}� )�{��6�		���	��
�	
�	
�	��
�		
�		
��'(�(��j�(�(�(�T�,�t�
�
���i�������+
�+
�+
�+
�+
�#�'�+
�+
�+
�\"#�"#�"#�"#�"#�[�"#�"#�"#�J&�&�&�&�&��&�&�&�$:�

�$:��$:�#(�$:�/5�$:�=A�$:�	�$:�$:�$:�$:�N=��=�=�=�=�8�T��d�����&�;�&�T�&�&�&�&�0���{�����
1�D�
1�;�
1�
1�
1�
1�
1�
1r/