salt.states.lxc
Manage Linux Containers
-
Ensure a container is not present, destroying it if present
- name
-
Name of the container to destroy
- stop
-
stop before destroying default: false
New in version 2015.5.2.
- path
-
path to the container parent default: /var/lib/lxc (system default)
New in version 2015.8.0.
web01: lxc.absent
salt.states.lxc.absent(name, stop=False, path=None)
-
Warning
This state is unsuitable for setting parameters that appear more than once in an LXC config file, or parameters which must appear in a certain order (such as when configuring more than one network interface).
Issue #35523 was opened to track the addition of a suitable replacement or fix.
Edit LXC configuration options
Deprecated since version 2015.5.0.
- path
-
path to the container parent default: /var/lib/lxc (system default)
New in version 2015.8.0.
setconf: lxc.edited_conf: - name: ubuntu - lxc_conf: - network.ipv4.ip: 10.0.3.6 - lxc_conf_unset: - lxc.utsname
salt.states.lxc.edited_conf(name, lxc_conf=None, lxc_conf_unset=None)
-
New in version 2015.5.0.
Ensure that a container is frozen
Note
This state does not enforce the existence of the named container, it just freezes the container if it is running. To ensure that the named container exists, use
lxc.present
.- name
-
The name of the container
- path
-
path to the container parent default: /var/lib/lxc (system default)
New in version 2015.8.0.
- startTrue
-
Start container first, if necessary. If
False
, then this state will fail if the container is not running.
web01: lxc.frozen web02: lxc.frozen: - start: False
salt.states.lxc.frozen(name, start=True, path=None)
-
Changed in version 2015.8.0: The
lxc.created
state has been renamed tolxc.present
, and thelxc.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)
New in version 2015.8.0.
- runningFalse
-
If
True
, ensure that the container is runningIf
False
, ensure that the container is stoppedIf
None
, do nothing with regards to the running state of the container
New in version 2015.8.0.
- clone_from
-
Create named container as a clone of the specified container
- snapshotFalse
-
Use Copy On Write snapshots (LVM). Only supported with
clone_from
. - profile
-
Profile to use in container creation (see the 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 LXC Tutorial for more information). Values in a profile will be overridden by the parameters listed below.
New in version 2015.5.2.
Container Creation Arguments
- template
-
The template to use. For example,
ubuntu
orfedora
. For a full list of available templates, check out thelxc.templates
function.Conflicts with the
image
argument.Note
The
download
template requires the following three parameters to be defined inoptions
:dist - The name of the distribution
release - Release name/version
arch - Architecture of the container
The available images can be listed using the
lxc.images
function.
options
New in version 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:
web01: lxc.present: - template: download - options: dist: centos release: 6 arch: amd64
Remember to double-indent the options, due to how PyYAML works.
For available template options, refer to the lxc template scripts which are usually located under
/usr/share/lxc/templates
, or runlxc-create -t <template> -h
.- image
-
A tar archive to use as the rootfs for the container. Conflicts with the
template
argument. - backing
-
The type of storage to use. Set to
lvm
to use an LVM group. Defaults to filesystem within /var/lib/lxc. - fstype
-
Filesystem type to use on LVM logical volume
- size
-
Size of the volume to create. Only applicable if
backing
is set tolvm
. - vgnamelxc
-
Name of the LVM volume group in which to create the volume for this container. Only applicable if
backing
is set tolvm
. - lvname
-
Name of the LVM logical volume in which to create the volume for this container. Only applicable if
backing
is set tolvm
. - thinpool
-
Name of a pool volume that will be used for thin-provisioning this container. Only applicable if
backing
is set tolvm
.
salt.states.lxc.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)
-
Changed in version 2015.5.0: The
lxc.started
state has been renamed tolxc.running
Ensure that a container is running
Note
This state does not enforce the existence of the named container, it just starts the container if it is not running. To ensure that the named container exists, use
lxc.present
.- name
-
The name of the container
- path
-
path to the container parent default: /var/lib/lxc (system default)
New in version 2015.8.0.
- restartFalse
-
Restart container if it is already running
web01: lxc.running web02: lxc.running: - restart: True
salt.states.lxc.running(name, restart=False, path=None)
-
Deprecated since version 2015.5.0.
This state function has been disabled, as it did not conform to design guidelines. Specifically, due to the fact that
lxc.set_password
useschpasswd(8)
to set the password, there was no method to make this action idempotent (in other words, the password would be changed every time). This makes this state redundant, since the following state will do the same thing:setpass: module.run: - name: set_pass - m_name: root - password: secret
salt.states.lxc.set_pass(name, **kwargs)
-
Ensure that a container is stopped
Note
This state does not enforce the existence of the named container, it just stops the container if it running or frozen. To ensure that the named container exists, use
lxc.present
, or use thelxc.absent
state to ensure that the container does not exist.- name
-
The name of the container
- path
-
path to the container parent default: /var/lib/lxc (system default)
New in version 2015.8.0.
- killFalse
-
Do not wait for the container to stop, kill all tasks in the container. Older LXC versions will stop containers like this irrespective of this argument.
New in version 2015.5.0.
web01: lxc.stopped
salt.states.lxc.stopped(name, kill=False, path=None)
© 2021 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltproject.io/en/latest/ref/states/all/salt.states.lxc.html