Hi,
I’m having trouble getting ansible-inventory to work with community.general.lxd and remote hosts.
FYI, I’m using the latest version of the plugin.
git clone https://github.com/conloos/community.general.git test
I want to use ansible-inventory to list containers from a remote host. I was able to get it working with a localhost setup as a remote but not from a remote host.
Here’s my inventory file, lxd2.yml:
plugin: community.general.lxd
#url: unix:/var/snap/lxd/common/lxd/unix.socket
url: "https://192.168.1.10:8443"
type_filter: both
client_cert: "/home/cm/snap/lxd/19188/.config/lxc/client.crt"
client_key: "/home/cm/snap/lxd/19188/.config/lxc/client.key"
trust_password: "SECRET"
When I attempt to run the play it fails.
(venv) cm@cm:~/Workspace/test$ ansible-inventory -i lxd2.yml --list
[WARNING]: * Failed to parse /home/cm/Workspace/test/lxd2.yml with auto plugin: inventory source '/home/cm/Workspace/test/lxd2.yml' could not be verified by inventory
plugin 'community.general.lxd'
[WARNING]: * Failed to parse /home/cm/Workspace/test/lxd2.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]: * Failed to parse /home/cm/Workspace/test/lxd2.yml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is
reserved to provide a port.
[WARNING]: Unable to parse /home/cm/Workspace/test/lxd2.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
"_meta": {
"hostvars": {}
},
"all": {
"children": [
"ungrouped"
]
}
}
When trying with localhost, using trust password. lxd.yml:
plugin: community.general.lxd
#url: unix:/var/snap/lxd/common/lxd/unix.socket
url: "https://192.168.56.28:8443"
type_filter: both
client_cert: "/home/cm/snap/lxd/19188/.config/lxc/client.crt"
client_key: "/home/cm/snap/lxd/19188/.config/lxc/client.key"
trust_password: "SECRET"
(venv) cm@cm:~/Workspace/test$ ansible-inventory -i lxd.yml --list
{
"_meta": {
"hostvars": {
"test": {
"ansible_connection": "ssh",
"ansible_host": "10.38.46.110",
"ansible_lxd_os": "ubuntu",
"ansible_lxd_profile": [
"default"
],
"ansible_lxd_project": "default",
"ansible_lxd_release": "jammy",
"ansible_lxd_state": "running",
"ansible_lxd_type": "container"
}
}
},
"all": {
"children": [
"ungrouped"
]
},
"ungrouped": {
"hosts": [
"test"
]
}
}
Thanks in advance!