On this page
community.general.lxd – Returns Ansible inventory from lxd host
Note
This plugin is part of the community.general collection (version 3.8.1).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.lxd.
New in version 3.0.0: of community.general
Synopsis
- Get inventory from the lxd.
 - Uses a YAML configuration file that ends with ‘lxd.(yml|yaml)’.
 
Parameters
| Parameter | Choices/Defaults | Configuration | Comments | 
|---|---|---|---|
| client_cert
        
        path
         | 
      Default: 
        "$HOME/.config/lxc/client.crt"
         | 
      
        
        The client certificate file path.
        
       aliases: cert_file  | 
     |
| client_key
        
        path
         | 
      Default: 
        "$HOME/.config/lxc/client.key"
         | 
      
        
        The client certificate key file path.
        
       aliases: key_file  | 
     |
| groupby
        
        dictionary
         | 
      
        
        Create groups by the following keywords  
       location, pattern, network_range, os, release, profile, vlanid.
       
        See example for syntax.
         | 
     ||
| plugin
        
        string / required
         | 
      
       
  | 
      
        
        Token that ensures this is a source file for the 'lxd' plugin.
         | 
     |
| prefered_container_network_family
        
        string
         | 
      
       
  | 
      
        
        If a container has multiple network interfaces, which one is the prefered by family.
        
       
        Specify  inet for IPv4 and inet6 for IPv6.
        | 
     |
| prefered_container_network_interface
        
        string
         | 
      Default: 
        "eth"
         | 
      
        
        If a container has multiple network interfaces, select which one is the prefered as pattern.
        
       
        Combined with the first number that can be found e.g. 'eth' + 0.
         | 
     |
| state
        
        string
         | 
      
       
  | 
      
        
        Filter the container according to the current status.
         | 
     |
| trust_password
        
        string
         | 
      
        
        The client trusted password.
        
       
        You need to set this password on the lxd server before running this module using the following command  
       lxc config set core.trust_password <some random password> See https://www.stgraber.org/2016/04/18/lxd-api-direct-interaction/.
       
        If trust_password is set, this module send a request for authentication before sending any requests.
         | 
     ||
| url
        
        string
         | 
      Default: 
        "unix:/var/snap/lxd/common/lxd/unix.socket"
         | 
      
        
        The unix domain socket path or the https URL for the lxd server.
        
       
        Sockets in filesystem have to start with  
       unix:.
       
        Mostly  unix:/var/lib/lxd/unix.socket or unix:/var/snap/lxd/common/lxd/unix.socket.
        | 
     
Examples
# simple lxd.yml
plugin: community.general.lxd
url: unix:/var/snap/lxd/common/lxd/unix.socket
# simple lxd.yml including filter
plugin: community.general.lxd
url: unix:/var/snap/lxd/common/lxd/unix.socket
state: RUNNING
# grouping lxd.yml
groupby:
  testpattern:
    type: pattern
    attribute: test
  vlan666:
    type: vlanid
    attribute: 666
  locationBerlin:
    type: location
    attribute: Berlin
  osUbuntu:
    type: os
    attribute: ubuntu
  releaseFocal:
    type: release
    attribute: focal
  releaseBionic:
    type: release
    attribute: bionic
  profileDefault:
    type: profile
    attribute: default
  profileX11:
    type: profile
    attribute: x11
  netRangeIPv4:
    type: network_range
    attribute: 10.98.143.0/24
  netRangeIPv6:
    type: network_range
    attribute: fd42:bd00:7b11:2167:216:3eff::/24
  Authors
- Frank Dornheim (@conloos)
 
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
 https://docs.ansible.com/ansible/latest/collections/community/general/lxd_inventory.html