salt.states.lxc

lxc / Spin up and control LXC containers

salt.states.lxc.absent(name)

Destroy a container

name
id of the container to destroy
destroyer:
  lxc.absent:
    - name: my_instance_name2
salt.states.lxc.cloned(name, orig, snapshot=True, size=None, vgname=None, profile=None)

Clone a container

name
id of the container to clone to
orig
id of the container to clone from
snapshot
do we use snapshots
size
Which size
vgname
If LVM, which volume group
profile
pillar lxc profile
myclone:
  lxc.cloned:
    - name: my_instance_name2
    - orig: ubuntu
    - vgname: lxc
    - snapshot: true
salt.states.lxc.created(name, template='ubuntu', profile=None, fstype=None, size=None, backing=None, vgname=None, lvname=None)

Create a container using a template

name
id of the container to act on
template
template to create from
profile
pillar lxc profile
fstype
fstype to use
size
Which size
backing

Which backing

None
Filesystem
lvm
lv
brtfs
brtfs
vgname
If LVM, which volume group
lvname
If LVM, which lv
mycreation:
  lxc.created:
    - name: my_instance_name2
    - backing: lvm
    - size: 1G
    - template: ubuntu
salt.states.lxc.edited_conf(name, lxc_conf=None, lxc_conf_unset=None)

Edit LXC configuration options

setconf:
  lxc.edited_conf:
    - name: ubuntu
    - lxc_conf:
        - network.ipv4.ip: 10.0.3.6
- lxc_conf_unset:
        - lxc.utsname
salt.states.lxc.set_pass(name, password=None, user=None, users=None)

Set the password of system users inside containers

name
id of the container to act on
user
user to set password
users
users to set password to
setpass:
  lxc.stopped:
    - name: my_instance_name2
    - password: s3cret
    - user: foo
setpass2:
  lxc.stopped:
    - name: my_instance_name2
    - password: s3cret
    - users:
      - foo
      - bar
salt.states.lxc.started(name, restart=False)

Start a container

name
id of the container to start
force
force reboot
destroyer:
  lxc.started:
    - name: my_instance_name2
salt.states.lxc.stopped(name)

Stop a container

name
id of the container to stop
sleepingcontainer:
  lxc.stopped:
    - name: my_instance_name2