Skip to content

Bug Report: Compose not picking up inventory_hostname field #439

@dmavrommatis

Description

@dmavrommatis
ISSUE TYPE
  • Bug Report
SOFTWARE VERSIONS
Ansible:

v2.9.12

Netbox:

v2.9.4

Collection:

v2.1.0

SUMMARY

When using the compose functionality to add a field the inventory_hostname variable is not accessible.

Usually this is needed in cases that you want to add a field based on the inventory_hostname mutations and this is supported by the builtin constructed plugin.

STEPS TO REPRODUCE

Add a compose field in the netbox configuration

compose:
  compose_field: inventory_hostname

Then run ansible-inventory to see if the field is added to the host variables.

ansible-inventory -vvvv --host name-of-host
EXPECTED RESULTS
{
    "ansible_host": "x.x.x.x",
    "compose_field": "name-of-host"
    "custom_fields": {},
    ...
}
ACTUAL RESULTS
{
    "ansible_host": "x.x.x.x",
    "custom_fields": {},
    ...
}
PROPOSED SOLUTION

dmavrommatis@90eaa23

If you think it's the correct approach I can open a PR with the change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions