lxd

LXD Server Ansible Role

test & release

This Ansible role installs LXD from the OS package manager and configures it using a preseed object.

Requirements

None.

Role Variables

NameRequiredType / ChoicesDescription
lxd_config yes object

LXD preseed configuration object. See the LXD documentation for details. If you want idempotency checks to work correctly, you have to make sure not to ommit any values which are output by lxd init --dump, as the role uses the difference between that and this variable to detect changes.

Example:

config: {}
networks:
  - config:
      ipv4.address: none
      ipv4.nat: "true"
      ipv6.address: none
      ipv6.nat: "true"
    description: ""
    name: lxdbr0
    type: bridge
    project: default
storage_pools:
  - config:
      source: /var/lib/lxd/storage-pools/default
    description: ""
    name: default
    driver: dir
profiles:
  - config:
      security.idmap.isolated: "true"
    description: Default LXD profile
    devices:
      eth0:
        name: eth0
        network: lxdbr0
        type: nic
      root:
        path: /
        pool: default
        type: disk
    name: default
projects:
  - config:
      features.images: "true"
      features.networks: "true"
      features.networks.zones: "true"
      features.profiles: "true"
      features.storage.buckets: "true"
      features.storage.volumes: "true"
    description: Default LXD project
    name: default
lxd_extra_users no list(string)

This role will always add the ansible user to the lxd group, so that it can communicate with the lxd unix socket to perform some of the tasks in this role. You can optionally use this variable to specify additional user names to add to the group.

Default: []

lxd_subid_offset no integer

Offset configured for the subordinate user IDs and subordinate group IDs in /etc/subuid and /etc/subgid respectively.

Default: 1000000

lxd_subid_range no integer

Range configured for the subordinate user IDs and subordinate group IDs in /etc/subuid and /etc/subgid respectively.

Default: 6553600

Dependencies

None.

Example Playbook

- hosts: container_host
  tasks:
    - ansible.builtin.import_role:
        name: gliech.lxd
      vars:
        lxd_config:
          config: {}
          networks: []
          storage_pools:
            - config:
                source: /var/lib/lxd/storage-pools/default
              description: ""
              name: default
              driver: dir
          profiles:
            - config:
                security.privileged: "true"
              description: Default LXD profile
              devices:
                root:
                  path: /
                  pool: default
                  type: disk
              name: default
          projects:
            - config:
                features.images: "true"
                features.networks: "true"
                features.networks.zones: "true"
                features.profiles: "true"
                features.storage.buckets: "true"
                features.storage.volumes: "true"
              description: Default LXD project
              name: default

License

This project is licensed under the terms of the GNU General Public License v3.0

About

Install lxd from the os package manager and configure it using a preseed object.

Install
ansible-galaxy install gliech/lxd-ansible-role
GitHub repository
License
gpl-3.0
Downloads
267
Owner