| Server IP : 23.254.227.96 / Your IP : 216.73.216.183 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3.6/site-packages/cloudinit/config/__pycache__/ |
Upload File : |
3
��b|+ � @ s� U d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
mZmZ ddl
mZ eZdZd Zd
ZdZeje�ZdgZd
dddddddgZddded�eed�ed�ed�ed�ed�ged�Ze
dd d!dd"ed#�d$�d"d%ed&e �d'�d"eed(jed)��d'�d"ee�jd*d%�ed+jee�jd*d%�d,��d'�d"eeed-d.je� �d/�d0d
ed1�d'�d0eed2jed3��d'�d4�d5gd
d6�d7�id8�Zeee�Z d9d:� Zd;d<� Z d=d � Z!d>d?� Z"d@dA� Z#dS )Bz"Write Files: write arbitrary files� N)�dedent)�log)�util)�
MetaSchema�get_meta_doc�validate_cloudconfig_schema)�PER_INSTANCEz root:rooti� Fz
text/plain�all�gz�gzipz gz+base64zgzip+base64zgz+b64zgzip+b64�b64�base64Zcc_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.a) # 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
)�id�name�title�description�distrosZexamples� frequency�object�write_filesZarray�stringz� Path of the file to which ``content`` is decoded
and written
)�typer � a# Optional content to write to the provided ``path``.
When content is present and encoding is not '%s',
decode the content prior to writing. Default:
**''**
)r �defaultr z� Optional owner:group to chown on the file. Default:
**{owner}**
)�owner�oz� Optional file permissions to set on ``path``
represented as an octal string '0###'. Default:
**'{perms}'**
)�permsz� Optional encoding type of the content. Default is
**text/plain** and no content decoding is
performed. Supported encoding types are:
%s.z, )r r �enumr Zbooleanz� Whether to append ``content`` to existing file if
``path`` exists. Default: **false**.
z� Defer writing the file until 'final' stage, after
users were created, and packages were installed.
Default: **{defer}**.
)�defer)�path�contentr �permissions�encoding�appendr r )r �
propertiesZrequiredZadditionalProperties)r �items)r r$ c C sF t |t� |jdg �}dd� |D �}|s8|jd| � d S t| |� d S )Nr c S s g | ]}t j|d t�s|�qS )r )r �get_cfg_option_bool�
DEFAULT_DEFER)�.0�f� r* �$/usr/lib/python3.6/cc_write_files.py�
<listcomp>� s zhandle.<locals>.<listcomp>zESkipping module named %s, no/empty 'write_files' key in configuration)r �schema�get�debugr )r ZcfgZ_cloudr Z_argsZ file_listZfiltered_filesr* r* r+ �handle� s
r0 c C sX | sd} | j � j� } | d
kr"dgS | dkr2d dgS | dkr@d gS | rRtjd| t� tgS )Nr r
r zapplication/x-gzip� gz+base64�gzip+base64�gz+b64�gzip+b64zapplication/base64r r
z%Unknown encoding type %s, assuming %s)r
r )r1 r2 r3 r4 )r r
)�lower�strip�LOG�warning�UNKNOWN_ENC)Z
encoding_typer* r* r+ �canonicalize_extraction s
r: c C s� |sd S x�t |�D ]�\}}|jd�}|s<tjd|d | � qtjj|�}t|jd��}t|jdd�|�}t j
|jdt��\}}t|jd�t
�} t j|d �r�d
nd}
t j|||
| d� t j|||� qW d S )
Nr z3No path provided to write for entry %s in module %s� r"