D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
lib
/
python3.6
/
site-packages
/
cloudinit
/
config
/
__pycache__
/
Filename :
cc_write_files.cpython-36.pyc
back
Copy
3 \�me� � @ s U d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z ddl mZ ddlm Z mZ ddlmZ d Zd ZdZeje�Zdd ded�dged�ed�ed�ed�ed�gedgd�Ze ee�Z eee edd�dd�Zdd� Zed�dd�Zdd � Zd!d"� ZdS )#z"Write Files: write arbitrary files� N)�dedent)�util)�Cloud)�Config)� MetaSchema�get_meta_doc)�PER_INSTANCEi� Fz text/plainZcc_write_fileszWrite Fileszwrite arbitrary filesax 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. .. warning:: Existing files will be overridden.�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�descriptionZdistrosZexamplesZ frequencyZactivate_by_schema_keys)r �cfg�cloud�args�returnc C sB |j dg �}dd� |D �}|s.tjd| � d S t| ||jj� d S )Nr c S s g | ]}t j|d t�s|�qS )Zdefer)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)�get�LOG�debugr ZdistroZ default_owner)r r r r Z file_listZfiltered_filesr r r �handley s r c C sf | sd} | j � j� } | d kr"dgS | dkr2d dgS | dkr@d gS | tkrNtgS | r`tjd| t� tgS )N� �gz�gzipzapplication/x-gzip� gz+base64�gzip+base64�gz+b64�gzip+b64zapplication/base64�b64�base64z%Unknown encoding type %s, assuming %s)r r )r! r"