Open meyayl opened 2 years ago
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @Ajpantuso @Thulium-Drake @UnderGreen @joshainglis @karmab @tleguern click here for bot help
component name plugins/inventory/proxmox.py
!component =plugins/inventory/proxmox.py
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @ilijamt click here for bot help
@meyayl I found a temporary solution here that requires no code change. Jinja doesn't like dashes in tokens, so using get() allows you to reference the value required to get qemu VM IPs via compose.
ansible_host: proxmox_agent_interfaces[1].get("ip-addresses")[0] | default(proxmox_net0.ip) | ipaddr("address")
Ultimately, I'd call this a workaround as the facts don't conform to proper Ansible fact formatting which uses underscores instead of dashes.
Note that instead of .get(x)
you can also write [x]
, i.e.
ansible_host: proxmox_agent_interfaces[1]["ip-addresses"][0] | default(proxmox_net0.ip) | ipaddr("address")
should also work.
Ultimately, I'd call this a workaround as the facts don't conform to proper Ansible fact formatting which uses underscores instead of dashes.
There's always the discussion how much modules should modify the data returned by services. There is no definite standard on how names should be, and what is better depends a lot on personal taste and use cases.
cc @krauthosting click here for bot help
Summary
When I want the dynamic inventory for my Proxmox host to be created, the vm's and container do not pre_polulate the ansible_host variable.
I want to use the compose feature provided by the dynamic inventory plugin, but it doesn't work because the mac address and ip address in the agent interface section use dashes instead of underscores.
Issue Type
Bug Report
Component Name
inventory/proxmox.py
Ansible Version
Community.general Version
As the list action seems not to be available in my installation, I got the version from here:
Configuration
doesn't apply
OS / Environment
doesn't apply
Steps to Reproduce
Expected Results
I expect the
ansible_host
variable to be filled by expression used in the compose for qemu_vm and lxc hosts.Actual Results
Instead the
ansible_host
entry is no rendered at all..Further notes:
This works for lxc containers only:
If the inventory/proxmox.py file is changed from:
to use underscores instead of dashes for the key names:
following compose expression works:
Code of Conduct