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_write_files.cpython-311.pyc
�

܍~c����UdZddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
dd	lmZmZdd
lmZdZdZd
Zeje��Zddded��dged��ed��ed��ed��ed��gedgd�Zeed<ee��Zdede
dededed dfd!�Zd"�Zd#efd$�Zd%�Z d&�Z!dS)'z"Write Files: write arbitrary files�N)�Logger)�dedent)�log)�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�PER_INSTANCEi�Fz
text/plain�cc_write_fileszWrite Fileszwrite arbitrary filesa<        Write out arbitrary content to files, optionally setting permissions.
        Parent folders in the path are created if absent.
        Content can be specified in plain text or binary. Data encoded with
        either base64 or binary gzip data can be specified and will be decoded
        before being written. For empty file creation, content can be omitted.

    .. note::
        if multiline data is provided, care should be taken to ensure that it
        follows yaml formatting standards. to specify binary data, use the yaml
        option ``!!binary``

    .. note::
        Do not write files under /tmp during boot because of a race with
        systemd-tmpfiles-clean that can cause temp files to get cleaned during
        the early boot process. Use /run/somedir instead to avoid race
        LP:1707222.�alla)        # Write out base64 encoded content to /etc/sysconfig/selinux
        write_files:
        - encoding: b64
          content: CiMgVGhpcyBmaWxlIGNvbnRyb2xzIHRoZSBzdGF0ZSBvZiBTRUxpbnV4...
          owner: root:root
          path: /etc/sysconfig/selinux
          permissions: '0644'
        z�        # Appending content to an existing file
        write_files:
        - content: |
            15 * * * * root ship_logs
          path: /etc/crontab
          append: true
        a        # Provide gziped binary content
        write_files:
        - encoding: gzip
          content: !!binary |
              H4sIAIDb/U8C/1NW1E/KzNMvzuBKTc7IV8hIzcnJVyjPL8pJ4QIA6N+MVxsAAAA=
          path: /usr/bin/hello
          permissions: '0755'
        zt        # Create an empty file on the system
        write_files:
        - path: /root/CLOUD_INIT_WAS_HERE
        a         # Defer writing the file until after the package (Nginx) is
        # installed and its user is created alongside
        write_files:
        - path: /etc/nginx/conf.d/example.com.conf
          content: |
            server {
                server_name example.com;
                listen 80;
                root /var/www;
                location / {
                    try_files $uri $uri/ $uri.html =404;
                }
            }
          owner: 'nginx:nginx'
          permissions: '0640'
          defer: true
        �write_files)�id�name�title�description�distros�examples�	frequency�activate_by_schema_keys�metar�cfg�cloudr�args�returnc��|�dg��}d�|D��}|s|�d|��dSt|||jj��dS)Nrc�H�g|]}tj|dt���|�� S)�defer)r�get_cfg_option_bool�
DEFAULT_DEFER)�.0�fs  �A/usr/lib/python3/dist-packages/cloudinit/config/cc_write_files.py�
<listcomp>zhandle.<locals>.<listcomp>{s=�����
��'��7�M�B�B��	����zESkipping module named %s, no/empty 'write_files' key in configuration)�get�debugr�distro�
default_owner)rrrrr�	file_list�filtered_filess       r#�handler,ws������
�r�*�*�I�������N�
���	�	�
;��	
�	
�	
�
	����n�e�l�&@�A�A�A�A�Ar%c��|sd}|������}|dvrdgS|dvrddgS|dvrdgS|tkrtgS|r!t�d|t��tgS)N�)�gz�gzip�application/x-gzip)z	gz+base64zgzip+base64zgz+b64zgzip+b64�application/base64)�b64�base64z%Unknown encoding type %s, assuming %s)�lower�strip�TEXT_PLAIN_ENC�LOG�warning)�
encoding_types r#�canonicalize_extractionr;�s������
�!�'�'�)�)�/�/�1�1�M���&�&�$�%�%��J�J�J�$�&:�;�;�
�)�)�)�$�%�%���&�&�����
����3���	
�	
�	
�

��r%�ownerc��|sdSt|��D�]<\}}|�d��}|s t�d|dz|���=tj�|��}t|�d����}t|�dd��|��}tj
|�d|����\}}	t|�d��t��}
tj
|d	��rd
nd}tj||||
���tj|||	����>dS)
N�pathz3No path provided to write for entry %s in module %s��encoding�contentr.r<�permissions�append�ab�wb)�omode�mode)�	enumerater&r8r9�osr>�abspathr;�extract_contentsr�extract_usergroup�decode_perms�
DEFAULT_PERMSr�
write_file�chownbyname)r�filesr<�i�f_infor>�extractions�contents�u�g�permsrFs            r#rr�sG������ ��'�'�%�%���F��z�z�&�!�!���	��K�K�E��A���
�
�
�

��w���t�$�$��-�f�j�j��.D�.D�E�E��#�F�J�J�y�"�$=�$=�{�K�K���'��
�
�7�E�(B�(B�C�C���A��V�Z�Z�
�6�6�
�F�F���0���B�B�L��������h�e�%�@�@�@�@����q�!�$�$�$�$�!%�%r%c��|�|S	t|ttf��rt|��Stt|��d��S#tt
f$rag}||fD]C}	|�d|z���#t$r|�d|z��Y�@wxYwtjdg|�R�|cYSwxYw)N�z%oz%rz0Undecodable permissions %s, returning default %s)	�
isinstance�int�float�str�	TypeError�
ValueErrorrCr8r9)�perm�default�reps�rs    r#rMrM�s����|�����d�S�%�L�)�)�	%��t�9�9���s�4�y�y�!�$�$�$���z�"���������	&�	&�A�
&����D�1�H�%�%�%�%���
&�
&�
&����D�1�H�%�%�%�%�%�
&������F�N��N�N�N�N��������s:�*A�A�C�(B�C�"B&�#C�%B&�&C�?Cc��|}|D]G}|dkrtj|dd���}� |dkrtj|��}�;|tkr	�H|S)Nr1F)�quiet�decoder2)r�decomp_gzipr4�	b64decoder7)rU�extraction_types�result�ts    r#rKrK�sm��
�F�
�����$�$�$��%�f�E�%�H�H�H�F�F�
�&�
&�
&��%�f�-�-�F�F�
�.�
 �
 ����Mr%)"�__doc__r4rI�loggingr�textwrapr�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar	r
�cloudinit.settingsrrNr r7�	getLogger�__name__r8r�__annotations__r^�listr,r;rrMrK�r%r#�<module>rzsQ��)�(�(�
�
�
�
�	�	�	�	�������������$�$�$�$�$�$�������!�!�!�!�!�!�#�#�#�#�#�#�<�<�<�<�<�<�<�<�+�+�+�+�+�+��
��
����g���!�!����
$��6�	���&�w���
�
	
�
	
�	��
�		
�		
�	��
�
	
�
	
�	��
�	
�	
�	��
�	
�	
�Q<�z� -��mW�W��j�W�W�W�r�,�t�
�
��B�

�B��B�#(�B�/5�B�=A�B�	�B�B�B�B�&���2%�C�%�%�%�%�.���*	�	�	�	�	r%