Skip to content

gliech/lxd-client-ansible-role

Repository files navigation

test & release

This Ansible role installs LXD and configures one or more other hosts from the Ansible inventory as remotes.

Requirements

This role requires the LXD remotes to be defined in the same inventory as the clients that are being configured. That is because it uses the ansible connections with the servers as trusted channel to transfer the users client certificates to the remotes.

This also means that, if the LXD servers are provisioned in the same playbook as the clients, the installation of the servers is a prerequisite step for this role to run.

Role Variables

NameRequiredType / ChoicesDescription
lxd_client_remotes yes list(string)

List of Ansible inventory hostnames of machines that should be configured as LXD remotes. The ansible user on these machines should be a member of the lxd group so that it can configure client certificates on the server.

Example: "{{ groups.lxd_servers }}"

lxd_client_default_remote no string

Name of an LXD remote that will be configured as default-remote in the lxc client config. Defaults to the first entry in the lxd_client_remotes variable.

Default: lxd_client_remotes[0]

lxd_client_users no list(string)

List of OS users, on the client machines which should be configured to access the LXD remotes. If no list is supplied, only the Ansible user will be set up to reach the remotes.

Default: ["{{ ansible_user_id }}"]

Dependencies

None.

Example Playbook

- hosts: lxd_servers
  tasks:
    - name: Configure LXD servers
      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

- hosts: localhost
  tasks:
    - name: Configure LXD client
      ansible.builtin.import_role:
        name: gliech.lxd_client
      vars:
        lxd_client_remotes: "{{ groups.lxd_servers }}"

License

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

About

Install LXD and configure one or more other hosts from the Ansible inventory as remotes

Resources

License

Stars

Watchers

Forks

Languages