diff --git a/docs/plugins/netbox_inventory_item_module.rst b/docs/plugins/netbox_inventory_item_module.rst
index af5c321fe..bb3779db1 100644
--- a/docs/plugins/netbox_inventory_item_module.rst
+++ b/docs/plugins/netbox_inventory_item_module.rst
@@ -349,6 +349,155 @@ Parameters
- :ansible-option-choices-entry:`true`
+ .. raw:: html
+
+
+
+ * - .. raw:: html
+
+
+
+
+ .. _ansible_collections.netbox.netbox.netbox_inventory_item_module__parameter-data/component:
+
+ .. rst-class:: ansible-option-title
+
+ **component**
+
+ .. raw:: html
+
+
+
+ .. rst-class:: ansible-option-type-line
+
+ :ansible-option-type:`dictionary`
+
+ .. raw:: html
+
+
+
+ - .. raw:: html
+
+
+
+ The component
+
+
+ .. raw:: html
+
+
+
+ * - .. raw:: html
+
+
+
+
+ .. _ansible_collections.netbox.netbox.netbox_inventory_item_module__parameter-data/component/device:
+
+ .. rst-class:: ansible-option-title
+
+ **device**
+
+ .. raw:: html
+
+
+
+ .. rst-class:: ansible-option-type-line
+
+ :ansible-option-type:`string`
+
+ .. raw:: html
+
+
+
+ - .. raw:: html
+
+
+
+ The device the interface is attached to.
+
+
+ .. raw:: html
+
+
+
+ * - .. raw:: html
+
+
+
+
+ .. _ansible_collections.netbox.netbox.netbox_inventory_item_module__parameter-data/assigned_object/name:
+
+ .. rst-class:: ansible-option-title
+
+ **name**
+
+ .. raw:: html
+
+
+
+ .. rst-class:: ansible-option-type-line
+
+ :ansible-option-type:`string`
+
+ .. raw:: html
+
+
+
+ - .. raw:: html
+
+
+
+ The name of the interface
+
+
+ .. raw:: html
+
+
+
+ * - .. raw:: html
+
+
+
+
+ .. _ansible_collections.netbox.netbox.netbox_inventory_item_module__parameter-data/component_type:
+
+ .. rst-class:: ansible-option-title
+
+ **component_type**
+
+ .. raw:: html
+
+
+
+ .. rst-class:: ansible-option-type-line
+
+ :ansible-option-type:`string`
+
+ .. raw:: html
+
+
+
+ - .. raw:: html
+
+
+
+ The type of the component
+
+
+ .. rst-class:: ansible-option-line
+
+ :ansible-option-choices:`Choices:`
+
+ - :ansible-option-choices-entry:`"dcim.consoleport"`
+ - :ansible-option-choices-entry:`"dcim.consoleserverport"`
+ - :ansible-option-choices-entry:`"dcim.frontport"`
+ - :ansible-option-choices-entry:`"dcim.interface"`
+ - :ansible-option-choices-entry:`"dcim.poweroutlet"`
+ - :ansible-option-choices-entry:`"dcim.powerport"`
+ - :ansible-option-choices-entry:`"dcim.rearport"`
+
+
.. raw:: html
diff --git a/plugins/module_utils/netbox_utils.py b/plugins/module_utils/netbox_utils.py
index b5a5124e9..70484d796 100644
--- a/plugins/module_utils/netbox_utils.py
+++ b/plugins/module_utils/netbox_utils.py
@@ -204,6 +204,7 @@
"cluster_groups": "cluster_groups",
"cluster_type": "cluster_types",
"cluster_types": "cluster_types",
+ "component": "component",
"config_context": "config_contexts",
"contact_groups": "contact_groups",
"dcim.consoleport": "console_ports",
@@ -385,6 +386,7 @@
"cluster": set(["name", "type"]),
"cluster_group": set(["slug"]),
"cluster_type": set(["slug"]),
+ "component": set(["device", "name"]),
"config_context": set(
[
"name",
@@ -436,7 +438,7 @@
"interface_a": set(["name", "device"]),
"interface_b": set(["name", "device"]),
"interface_template": set(["name", "device_type"]),
- "inventory_item": set(["name", "device"]),
+ "inventory_item": set(["name", "device", "component"]),
"inventory_item_role": set(["name"]),
"ip_address": set(["address", "vrf", "device", "interface", "assigned_object"]),
"ip_addresses": set(["address", "vrf", "device", "interface", "assigned_object"]),
@@ -560,6 +562,7 @@
"circuit_type": "type",
"cluster_type": "type",
"cluster_group": "group",
+ "component": "component_id",
"contact_group": "group",
"fhrp_group": "group",
"parent_contact_group": "parent",
@@ -822,7 +825,7 @@ def _convert_identical_keys(self, data):
temp_dict[key] = data[key]
elif key in CONVERT_KEYS:
# This will keep the original key for keys in list, but also convert it.
- if key in ("assigned_object", "scope"):
+ if key in ("assigned_object", "scope", "component"):
temp_dict[key] = data[key]
new_key = CONVERT_KEYS[key]
temp_dict[new_key] = data[key]
@@ -884,6 +887,8 @@ def _build_query_params(
parent = module_data["termination_a_type"]
elif parent == "termination_b" and module_data.get("termination_b_type"):
parent = module_data["termination_b_type"]
+ elif parent == "component" and module_data.get("component_type"):
+ parent = module_data["component_type"]
elif parent == "scope":
parent = ENDPOINT_NAME_MAPPING[SCOPE_TO_ENDPOINT[module_data["scope_type"]]]
@@ -1116,6 +1121,8 @@ def _find_ids(self, data, user_query_params):
endpoint = CONVERT_TO_ID[data.get("termination_b_type")]
elif k == "assigned_object":
endpoint = "interfaces"
+ elif k == "component":
+ endpoint = CONVERT_TO_ID[data.get("component_type")]
elif k == "scope":
# Determine endpoint name for scope ID resolution
endpoint = SCOPE_TO_ENDPOINT[data["scope_type"]]
diff --git a/plugins/modules/netbox_inventory_item.py b/plugins/modules/netbox_inventory_item.py
index 40d915501..95d4b9146 100644
--- a/plugins/modules/netbox_inventory_item.py
+++ b/plugins/modules/netbox_inventory_item.py
@@ -82,6 +82,35 @@
required: false
default: false
type: bool
+ component_type:
+ description:
+ - The type of the component
+ choices:
+ - dcim.consoleport
+ - dcim.consoleserverport
+ - dcim.frontport
+ - dcim.interface
+ - dcim.poweroutlet
+ - dcim.powerport
+ - dcim.rearport
+ required: false
+ type: str
+ component:
+ description:
+ - The component
+ required: false
+ type: dict
+ suboptions:
+ name:
+ description:
+ - The name of the interface
+ type: str
+ required: False
+ device:
+ description:
+ - The device the interface is attached to.
+ type: str
+ required: False
tags:
description:
- Any tags that the device may need to be associated with
@@ -191,6 +220,27 @@ def main():
asset_tag=dict(required=False, type="str"),
description=dict(required=False, type="str"),
discovered=dict(required=False, type="bool", default=False),
+ component_type=dict(
+ required=False,
+ choices=[
+ "dcim.consoleport",
+ "dcim.consoleserverport",
+ "dcim.frontport",
+ "dcim.interface",
+ "dcim.poweroutlet",
+ "dcim.powerport",
+ "dcim.rearport",
+ ],
+ type="str",
+ ),
+ component=dict(
+ required=False,
+ type="dict",
+ options=dict(
+ name=dict(required=False, type="str"),
+ device=dict(required=False, type="str"),
+ ),
+ ),
tags=dict(required=False, type="list", elements="raw"),
custom_fields=dict(required=False, type="dict"),
),