r/LXD • • 18h ago

smcavoy.lxd: 63 Ansible modules for the LXD REST API

2 Upvotes

I generated an Ansible collection for LXD: smcavoy.lxd. It is on Ansible Galaxy.

The LXD modules in community.general manage instances, profiles and projects. This collection also manages networks, storage, images, clusters and identities.

  • 63 modules for LXD 6.10.1 or newer, one for each resource of the LXD API.
  • The modules talk to the REST API directly. They need ansible-core only, not pylxd or the lxc command.
  • They support check mode, and most support diff mode.

Install it with this command:

ansible-galaxy collection install smcavoy.lxd

A small example, which uses the local LXD socket:

- name: Run an Ubuntu VM from the ubuntu image registry
  smcavoy.lxd.lxd_instance:
    name: vm1
    type: virtual-machine
    source:
      image: "26.04"
      image_registry: ubuntu
  • The version is 0.3.0. An interface can change before 1.0.0.
  • It is for LXD only. I did not test it with Incus.
  • I built it with coding agents (Claude Code). The repository shows the method.

Try it on a test server, and tell me what breaks. PRs and issues are welcome.