File: //lib/python3.6/site-packages/cloudinit/config/__pycache__/cc_snap.cpython-36.pyc
3
�q�h] �
@ s U d Z ddlZddlZddlmZ ddlmZ ddlmZm Z ddl
mZ ddlm
Z
ddlmZmZ dd lmZ dd
lmZ dgZeZeje�Zdd
ded�eed�ed�ed�ed�gedgd�Zeee�Z dZdd� Zdd� Zee
eedd�dd�Z dS )z<Snap: Install, configure and manage snapd and snap packages.� N)�dedent)�log)�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�PER_INSTANCE)�prepend_base_commandZubuntuZcc_snapZSnapz5Install, configure and manage snapd and snap packagesah This module provides a simple configuration namespace in cloud-init to
both setup snapd and install snaps.
.. note::
Both ``assertions`` and ``commands`` values can be either a
dictionary or a list. If these configs are provided as a
dictionary, the keys are only used to order the execution of the
assertions or commands and the dictionary is merged with any
vendor-data snap configuration provided. If a list is provided by
the user instead of a dict, any vendor-data snap configuration is
ignored.
The ``assertions`` configuration option is a dictionary or list of
properly-signed snap assertions which will run before any snap
``commands``. They will be added to snapd's assertion database by
invoking ``snap ack <aggregate_assertion_file>``.
Snap ``commands`` is a dictionary or list of individual snap
commands to run on the target system. These commands can be used to
create snap users, install snaps and provide snap configuration.
.. note::
If 'side-loading' private/unpublished snaps on an instance, it is
best to create a snap seed directory and seed.yaml manifest in
**/var/lib/snapd/seed/** which snapd automatically installs on
startup.
ax snap:
assertions:
00: |
signed_assertion_blob_here
02: |
signed_assertion_blob_here
commands:
00: snap create-user --sudoer --known <snap-user>@mydomain.com
01: snap install canonical-livepatch
02: canonical-livepatch enable <AUTH_TOKEN>
ay # Convenience: the snap command can be omitted when specifying commands
# as a list and 'snap' will automatically be prepended.
# The following commands are equivalent:
snap:
commands:
00: ['install', 'vlc']
01: ['snap', 'install', 'vlc']
02: snap install vlc
03: 'snap install vlc'
z� # You can use a list of commands
snap:
commands:
- ['install', 'vlc']
- ['snap', 'install', 'vlc']
- snap install vlc
- 'snap install vlc'
z� # You can use a list of assertions
snap:
assertions:
- signed_assertion_blob_here
- |
signed_assertion_blob_here
�snap)�id�name�title�description�distrosZexamples� frequencyZactivate_by_schema_keysc C s� | sdS t jd� t| t�r&| j� } nt| t�s@tdj| d���td|g}dj | �}x&| D ]}t jd|j
d�dd � � qZW tj||j
d
�� tj|dd� dS )
a Import list of assertions.
Import assertions by concatenating each assertion into a
string separated by a '
'. Write this string to a instance file and
then invoke `snap ack /path/to/file` and check for errors.
If snap exits 0, then all assertions are imported.
Nz'Importing user-provided snap assertionsz8assertion parameter was not a list or dict: {assertions})�
assertionsZack�
zSnap acking: %sr � zutf-8T)Zcapture)�LOG�debug�
isinstance�dict�values�list� TypeError�format�SNAP_CMD�join�splitr Z
write_file�encoder )r Zassertions_fileZsnap_cmdZcombinedZasrt� r"