Skip to content

Commit e5d248e

Browse files
richbibbyclaude
andcommitted
Add airflow and rack_type field support to netbox_rack module
- Add airflow field with choices: front-to-rear, rear-to-front - Add rack_type field to reference rack type objects - Add NB_RACK_TYPES constant to netbox_dcim.py - Update netbox_utils.py with rack_type mappings - Add changelog fragment for release notes - Add example demonstrating new fields usage Resolves #1450 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent fcf6ff5 commit e5d248e

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- "netbox_rack - Add airflow and rack_type field support (https://github.com/netbox-community/ansible_modules/issues/1450)"

plugins/module_utils/netbox_dcim.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
NB_POWER_PORT_TEMPLATES = "power_port_templates"
4343
NB_RACKS = "racks"
4444
NB_RACK_ROLES = "rack_roles"
45+
NB_RACK_TYPES = "rack_types"
4546
NB_RACK_GROUPS = "rack_groups"
4647
NB_REAR_PORTS = "rear_ports"
4748
NB_REAR_PORT_TEMPLATES = "rear_port_templates"

plugins/module_utils/netbox_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"racks": {},
7474
"rack_groups": {},
7575
"rack_roles": {},
76+
"rack_types": {},
7677
"rear_ports": {},
7778
"rear-ports": {},
7879
"rear_port_templates": {},
@@ -206,6 +207,7 @@
206207
rack="name",
207208
rack_group="slug",
208209
rack_role="slug",
210+
rack_type="slug",
209211
rear_port="name",
210212
rear_port_template="name",
211213
region="slug",
@@ -315,6 +317,7 @@
315317
"rack": "racks",
316318
"rack_group": "rack_groups",
317319
"rack_role": "rack_roles",
320+
"rack_type": "rack_types",
318321
"region": "regions",
319322
"regions": "regions",
320323
"rear_port": "rear_ports",
@@ -416,6 +419,7 @@
416419
"racks": "rack",
417420
"rack_groups": "rack_group",
418421
"rack_roles": "rack_role",
422+
"rack_types": "rack_type",
419423
"rear_ports": "rear_port",
420424
"rear-ports": "rearport",
421425
"rear_port_templates": "rear_port_template",
@@ -561,6 +565,7 @@
561565
"rack": set(["name", "site", "location"]),
562566
"rack_group": set(["slug"]),
563567
"rack_role": set(["slug"]),
568+
"rack_type": set(["slug"]),
564569
"region": set(["slug"]),
565570
"rear_port": set(["name", "device"]),
566571
"rear_port_template": set(["name", "device_type"]),
@@ -646,7 +651,7 @@
646651
"power_outlet_templates": set(["type", "feed_leg"]),
647652
"power_ports": set(["type"]),
648653
"power_port_templates": set(["type"]),
649-
"racks": set(["status", "outer_unit", "type"]),
654+
"racks": set(["status", "outer_unit", "type", "airflow"]),
650655
"rear_ports": set(["type"]),
651656
"rear_port_templates": set(["type"]),
652657
"services": set(["protocol"]),
@@ -710,6 +715,7 @@
710715
"locations",
711716
"rack_groups",
712717
"rack_roles",
718+
"rack_types",
713719
"regions",
714720
"rirs",
715721
"roles",

plugins/modules/netbox_rack.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@
7171
- The rack role the rack will be associated to
7272
required: false
7373
type: raw
74+
rack_type:
75+
description:
76+
- The rack type that defines predefined characteristics like width, u_height, and others
77+
required: false
78+
type: raw
79+
version_added: "3.23.0"
7480
serial:
7581
description:
7682
- Serial number of the rack
@@ -159,6 +165,15 @@
159165
required: false
160166
type: int
161167
version_added: "3.10.0"
168+
airflow:
169+
description:
170+
- Airflow direction of the rack
171+
choices:
172+
- front-to-rear
173+
- rear-to-front
174+
required: false
175+
type: str
176+
version_added: "3.23.0"
162177
description:
163178
description:
164179
- Description of the rack
@@ -220,6 +235,18 @@
220235
location: Test Location
221236
state: present
222237
238+
- name: Create rack with airflow and rack_type
239+
netbox.netbox.netbox_rack:
240+
netbox_url: http://netbox.local
241+
netbox_token: thisIsMyToken
242+
data:
243+
name: Test rack with airflow
244+
site: Test Site
245+
location: Test Location
246+
airflow: front-to-rear
247+
rack_type: Standard 42U Rack
248+
state: present
249+
223250
- name: Delete rack within netbox
224251
netbox.netbox.netbox_rack:
225252
netbox_url: http://netbox.local
@@ -275,6 +302,7 @@ def main():
275302
tenant=dict(required=False, type="raw"),
276303
status=dict(required=False, type="raw"),
277304
rack_role=dict(required=False, type="raw"),
305+
rack_type=dict(required=False, type="raw"),
278306
serial=dict(required=False, type="str"),
279307
asset_tag=dict(required=False, type="str"),
280308
type=dict(
@@ -323,6 +351,14 @@ def main():
323351
),
324352
max_weight=dict(required=False, type="int"),
325353
mounting_depth=dict(required=False, type="int"),
354+
airflow=dict(
355+
required=False,
356+
type="str",
357+
choices=[
358+
"front-to-rear",
359+
"rear-to-front",
360+
],
361+
),
326362
description=dict(required=False, type="str"),
327363
comments=dict(required=False, type="str"),
328364
tags=dict(required=False, type="list", elements="raw"),

0 commit comments

Comments
 (0)