­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ ­ """ Manage Linux Containers ======================= """ from salt.exceptions import CommandExecutionError, SaltInvocationError __docformat__ = "restructuredtext en" # Container existence/non-existence def present( name, running=None, clone_from=None, snapshot=False, profile=None, network_profile=None, template=None, options=None, image=None, config=None, fstype=None, size=None, backing=None, vgname=None, lvname=None, thinpool=None, path=None, ): """ .. versionchanged:: 2015.8.0 The :mod:`lxc.created ` state has been renamed to ``lxc.present``, and the :mod:`lxc.cloned ` state has been merged into this state. Create the named container if it does not exist name The name of the container to be created path path to the container parent default: /var/lib/lxc (system default) .. versionadded:: 2015.8.0 running : False * If ``True``, ensure that the container is running * If ``False``, ensure that the container is stopped * If ``None``, do nothing with regards to the running state of the container .. versionadded:: 2015.8.0 clone_from Create named container as a clone of the specified container snapshot : False Use Copy On Write snapshots (LVM). Only supported with ``clone_from``. profile Profile to use in container creation (see the :ref:`LXC Tutorial ` for more information). Values in a profile will be overridden by the parameters listed below. network_profile Network Profile to use in container creation (see the :ref:`LXC Tutorial ` for more information). Values in a profile will be overridden by the parameters listed below. .. versionadded:: 2015.5.2 **Container Creation Arguments** template The template to use. For example, ``ubuntu`` or ``fedora``. For a full list of available templates, check out the :mod:`lxc.templates ` function. Conflicts with the ``image`` argument. .. note:: The ``download`` template requires the following three parameters to be defined in ``options``: * **dist** - The name of the distribution * **release** - Release name/version * **arch** - Architecture of the container The available images can be listed using the :mod:`lxc.images ` function. options .. versionadded:: 2015.5.0 Template-specific options to pass to the lxc-create command. These correspond to the long options (ones beginning with two dashes) that the template script accepts. For example: .. code-block:: yaml web01: lxc.present: - template: download - options: dist: centos release: 6 arch: amd64 Remember to double-indent the options, due to :ref:`how PyYAML works `. For available template options, refer to the lxc template scripts which are usually located under ``/usr/share/lxc/templates``, or run ``lxc-create -t