Skip to content

Commit bebddd3

Browse files
Bugfix: Made ip addresses query params to include interface (#209)
1 parent 8ab1f6f commit bebddd3

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

plugins/module_utils/netbox_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@
199199
"installed_device": set(["name"]),
200200
"interface": set(["name", "device", "virtual_machine"]),
201201
"inventory_item": set(["name", "device"]),
202-
"ip_address": set(["address", "vrf"]),
203-
"ip_addresses": set(["address", "vrf", "device"]),
204-
"ipaddresses": set(["address", "vrf", "device"]),
202+
"ip_address": set(["address", "vrf", "interface"]),
203+
"ip_addresses": set(["address", "vrf", "device", "interface"]),
204+
"ipaddresses": set(["address", "vrf", "device", "interface"]),
205205
"lag": set(["name"]),
206206
"manufacturer": set(["slug"]),
207207
"nat_inside": set(["vrf", "address"]),
@@ -235,6 +235,7 @@
235235
"cluster",
236236
"device",
237237
"group",
238+
"interface",
238239
"rir",
239240
"vrf",
240241
"site",

tests/integration/targets/latest/tasks/netbox_ip_address.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,17 @@
306306
- test_fourteen['ip_address']['family'] == 4
307307
- test_fourteen['ip_address']['interface'] == 5
308308

309-
- name: "15 - Create IP address with no mask - State: Present"
309+
- name: "15 - Create same IP address on Eth0 - test101-vm - State: present"
310310
netbox.netbox.netbox_ip_address:
311311
netbox_url: http://localhost.org:32768
312312
netbox_token: 0123456789abcdef0123456789abcdef01234567
313313
data:
314-
address: 10.120.10.1
315-
state: present
314+
family: 4
315+
address: 10.188.1.100/24
316+
interface:
317+
name: Eth0
318+
virtual_machine: test101-vm
319+
state: "present"
316320
register: test_fifteen
317321

318322
- name: "15 - ASSERT"
@@ -321,5 +325,25 @@
321325
- test_fifteen is changed
322326
- test_fifteen['diff']['before']['state'] == "absent"
323327
- test_fifteen['diff']['after']['state'] == "present"
324-
- test_fifteen['msg'] == "ip_address 10.120.10.1/32 created"
325-
- test_fifteen['ip_address']['address'] == "10.120.10.1/32"
328+
- test_fifteen['msg'] == "ip_address 10.188.1.100/24 created"
329+
- test_fifteen['ip_address']['address'] == "10.188.1.100/24"
330+
- test_fifteen['ip_address']['family'] == 4
331+
- test_fifteen['ip_address']['interface'] == 10
332+
333+
- name: "16 - Create IP address with no mask - State: Present"
334+
netbox.netbox.netbox_ip_address:
335+
netbox_url: http://localhost.org:32768
336+
netbox_token: 0123456789abcdef0123456789abcdef01234567
337+
data:
338+
address: 10.120.10.1
339+
state: present
340+
register: test_sixteen
341+
342+
- name: "16 - ASSERT"
343+
assert:
344+
that:
345+
- test_sixteen is changed
346+
- test_sixteen['diff']['before']['state'] == "absent"
347+
- test_sixteen['diff']['after']['state'] == "present"
348+
- test_sixteen['msg'] == "ip_address 10.120.10.1/32 created"
349+
- test_sixteen['ip_address']['address'] == "10.120.10.1/32"

0 commit comments

Comments
 (0)