Skip to content

Commit 7d1c4d7

Browse files
authored
Add label and custom fields to inventory item module (#632)
1 parent c8a5988 commit 7d1c4d7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

plugins/modules/netbox_inventory_item.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
- Name of the inventory item to be created
5959
required: true
6060
type: str
61+
label:
62+
description:
63+
- The physical label of the inventory item
64+
required: false
65+
type: str
66+
version_added: "3.4.0"
6167
manufacturer:
6268
description:
6369
- The manufacturer of the inventory item
@@ -95,6 +101,12 @@
95101
required: false
96102
type: list
97103
elements: raw
104+
custom_fields:
105+
description:
106+
- must exist in Netbox
107+
required: false
108+
type: dict
109+
version_added: "3.4.0"
98110
required: true
99111
state:
100112
description:
@@ -193,13 +205,15 @@ def main():
193205
options=dict(
194206
device=dict(required=False, type="raw"),
195207
name=dict(required=True, type="str"),
208+
label=dict(required=False, type="str"),
196209
manufacturer=dict(required=False, type="raw"),
197210
part_id=dict(required=False, type="str"),
198211
serial=dict(required=False, type="str"),
199212
asset_tag=dict(required=False, type="str"),
200213
description=dict(required=False, type="str"),
201214
discovered=dict(required=False, type="bool", default=False),
202215
tags=dict(required=False, type="list", elements="raw"),
216+
custom_fields=dict(required=False, type="dict"),
203217
),
204218
),
205219
)

tests/integration/targets/v2.11/tasks/netbox_inventory_item.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
data:
5050
device: "test100"
5151
name: "10G-SFP+"
52+
label: "PHY test100"
5253
manufacturer: "Cisco"
5354
part_id: "10G-SFP+"
5455
serial: "1234"
@@ -69,9 +70,11 @@
6970
- test_three['diff']['after']['description'] == "New SFP"
7071
- test_three['diff']['after']['manufacturer'] == 1
7172
- test_three['diff']['after']['part_id'] == "10G-SFP+"
73+
- test_three['diff']['after']['label'] == "PHY test100"
7274
- test_three['diff']['after']['tags'][0] == 4
7375
- test_three['diff']['after']['discovered'] == True
7476
- test_three['inventory_item']['name'] == "10G-SFP+"
77+
- test_three['inventory_item']['label'] == "PHY test100"
7578
- test_three['inventory_item']['device'] == 1
7679
- test_three['inventory_item']['asset_tag'] == "1234"
7780
- test_three['inventory_item']['serial'] == "1234"
@@ -97,6 +100,7 @@
97100
that:
98101
- test_four is changed
99102
- test_four['inventory_item']['name'] == "10G-SFP+"
103+
- test_four['inventory_item']['label'] == "PHY test100"
100104
- test_four['inventory_item']['device'] == 1
101105
- test_four['inventory_item']['asset_tag'] == "1234"
102106
- test_four['inventory_item']['serial'] == "1234"

0 commit comments

Comments
 (0)