Setting connection vars in LXD Inventory

dkettman
Fri, 24 Oct 2025 14:50:55 +0000
Get Help

Hello,

I am working on some lab building Ansible playbooks and using Incus/LXD for the “hypervisor”. Some of my VMs are Windows machines which I want to use the psrp module to connect to them. This requires setting some variables for these hosts. What I have attempted is this for my inventory:

---
plugin: community.general.lxd
url: unix:/var/lib/incus/unix.socket
type_filter: both
state: RUNNING
groupby:
  windows:
    type: profile
    attribute: windows
    ansible_connection: psrp
    ansible_user: ansible
    ansible_password: --ReDaCtEd--
  ubuntu:
    type: os
    attribute: ubuntu

As you can see, I’m specifying the Incus socket to use rather than the LXD as there is currently no Incus-specific Inventory plugin at this time. Essentially, if they have the ‘windows’ profile added to their container/vm, then they need to have the following defined:

    ansible_connection: psrp
    ansible_user: ansible
    ansible_password: --ReDaCtEd--

Is there another way to make sure the systems in the ‘windows’ group have these defined prior to connection time?

tags

Inventory

LXC/LXD

Incus

Hostvars (? maybe?)

3 posts - 2 participants