Skip to content

Commit 960aebe

Browse files
committed
feat: Add support for tunnel groups and IPsec profiles in netbox_utils.py
1 parent 75a3e68 commit 960aebe

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

plugins/module_utils/netbox_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@
132132
"l2vpns": {"introduced": "3.7"},
133133
"l2vpn_terminations": {"introduced": "3.7"},
134134
"tunnels": {"introduced": "3.7"},
135+
"tunnel_groups": {"introduced": "3.7"},
136+
"ipsec_profiles": {"introduced": "3.7"},
135137
},
136138
)
137139

@@ -258,6 +260,7 @@
258260
"inventory_item_role": "inventory_item_roles",
259261
"ip_addresses": "ip_addresses",
260262
"ipaddresses": "ip_addresses",
263+
"ipsec_profile": "ipsec_profiles",
261264
"location": "locations",
262265
"lag": "interfaces",
263266
"manufacturer": "manufacturers",
@@ -314,6 +317,7 @@
314317
"tenant_groups": "tenant_groups",
315318
"termination_a": "interfaces",
316319
"termination_b": "interfaces",
320+
"tunnel_group": "tunnel_groups",
317321
"untagged_vlan": "vlans",
318322
"virtual_chassis": "virtual_chassis",
319323
"virtual_machine": "virtual_machines",

plugins/modules/netbox_tunnel.py

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,53 +39,52 @@
3939
- Status of the tunnel
4040
required: false
4141
type: raw
42-
version_added: "3.20.0"
43-
slug:
42+
tunnel_group:
4443
description:
45-
- The slugified version of the name or custom slug.
46-
- This is auto-generated following NetBox rules if not provided
44+
- The VLAN group the VLAN will be associated to
4745
required: false
48-
type: str
49-
site:
46+
type: raw
47+
encapsulation:
5048
description:
51-
- Required if I(state=present) and the tunnel does not exist yet
49+
- The encapsulation protocol or technique employed to effect the tunnel
5250
required: false
5351
type: raw
54-
parent_tunnel:
52+
ipsec_profile:
5553
description:
56-
- The parent tunnel the tunnel will be associated with
54+
- The IPSec Profile employed to negotiate security associations
5755
required: false
5856
type: raw
5957
tenant:
6058
description:
6159
- The tenant that the tunnel will be associated with
6260
required: false
6361
type: raw
64-
version_added: "3.8.0"
65-
facility:
62+
tunnel_id:
6663
description:
67-
- Data center provider or facility, ex. Equinix NY7
64+
- The ID of the tunnel
6865
required: false
69-
type: str
70-
version_added: "3.20.0"
66+
type: int
7167
description:
7268
description:
7369
- The description of the tunnel
7470
required: false
7571
type: str
72+
comments:
73+
description:
74+
- Comments that may include additional information in regards to the tunnel
75+
required: false
76+
type: str
7677
tags:
7778
description:
78-
- The tags to add/update
79+
- Any tags that the tunnel may need to be associated with
7980
required: false
8081
type: list
8182
elements: raw
82-
version_added: "3.6.0"
8383
custom_fields:
8484
description:
8585
- Must exist in NetBox
8686
required: false
8787
type: dict
88-
version_added: "3.6.0"
8988
required: true
9089
"""
9190

@@ -101,29 +100,35 @@
101100
netbox_url: http://netbox.local
102101
netbox_token: thisIsMyToken
103102
data:
104-
name: Test tunnel
105-
site: Test Site
103+
name: Test Tunnel
104+
status: active
105+
encapsulation: ipsec-tunnel
106106
state: present
107107
108-
- name: Create tunnel within NetBox with a parent tunnel, status and facility
108+
- name: Delete tunnel within NetBox
109109
netbox.netbox.netbox_tunnel:
110110
netbox_url: http://netbox.local
111111
netbox_token: thisIsMyToken
112112
data:
113-
name: Child tunnel
114-
site: Test Site
115-
parent_tunnel: Test tunnel
116-
status: planned
117-
facility: Test Facility
118-
state: present
113+
name: Test Tunnel
114+
state: absent
119115
120-
- name: Delete tunnel within NetBox
116+
- name: Create tunnel with all information
121117
netbox.netbox.netbox_tunnel:
122118
netbox_url: http://netbox.local
123119
netbox_token: thisIsMyToken
124120
data:
125-
name: Test tunnel
126-
state: absent
121+
name: Test Tunnel
122+
status: planned
123+
tunnel_group: Test Tunnel Group
124+
encapsulation: ipsec-tunnel
125+
ipsec_profile: ipsec-profile
126+
description: Test Description
127+
tenant: Test Tenant
128+
tunnel_id: 200
129+
tags:
130+
- test
131+
state: present
127132
"""
128133

129134
RETURN = r"""
@@ -161,9 +166,13 @@ def main():
161166
options=dict(
162167
name=dict(required=True, type="str"),
163168
status=dict(required=False, type="raw"),
169+
tunnel_group=dict(required=False, type="raw"),
164170
encapsulation=dict(required=False, type="raw"),
171+
ipsec_profile=dict(required=False, type="raw"),
165172
tenant=dict(required=False, type="raw"),
173+
tunnel_id=dict(required=False, type="int"),
166174
description=dict(required=False, type="str"),
175+
comments=dict(required=False, type="str"),
167176
tags=dict(required=False, type="list", elements="raw"),
168177
custom_fields=dict(required=False, type="dict"),
169178
),

0 commit comments

Comments
 (0)