Skip to content

Commit 66a285b

Browse files
Bugfix: Adding assigned_object as allowed query param for ip addresses (#435)
1 parent 9c2704c commit 66a285b

File tree

6 files changed

+85
-10
lines changed

6 files changed

+85
-10
lines changed

.github/workflows/main.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,43 @@ jobs:
5858
uses: actions/setup-python@v2
5959
with:
6060
python-version: ${{ matrix.python-version }}
61-
- name: Clone & Start netbox-docker containers
61+
- name: Clone & Start netbox-docker containers - latest
6262
env:
6363
VERSION: ${{ matrix.VERSION }}
6464
run: |
6565
cd ..
6666
git clone https://github.com/netbox-community/netbox-docker.git
6767
cd netbox-docker
68+
tee docker-compose.override.yml <<EOF
69+
version: '3.4'
70+
services:
71+
netbox:
72+
ports:
73+
- 32768:8080
74+
EOF
6875
docker-compose up -d --quiet-pull
6976
docker container ls
7077
cd ..
78+
if: matrix.VERSION == 'latest'
79+
- name: Clone & Start netbox-docker containers - 2.9
80+
env:
81+
VERSION: ${{ matrix.VERSION }}
82+
run: |
83+
cd ..
84+
git clone https://github.com/netbox-community/netbox-docker.git
85+
cd netbox-docker
86+
git checkout 0.26.2
87+
tee docker-compose.override.yml <<EOF
88+
version: '3.4'
89+
services:
90+
nginx:
91+
ports:
92+
- 32768:8080
93+
EOF
94+
docker-compose up -d --quiet-pull
95+
docker container ls
96+
cd ..
97+
if: matrix.VERSION == 'v2.9'
7198
- name: Install and configure Poetry
7299
uses: snok/install-poetry@v1.1.1
73100
with:

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Deploy collection to Ansible Galaxy
22
on:
3-
create:
4-
tags:
5-
- "v*"
3+
push:
4+
branches:
5+
- "refs/tags/v*"
66
jobs:
77
deploy:
88
runs-on: ubuntu-latest

plugins/module_utils/netbox_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@
293293
"interface": set(["name", "device", "virtual_machine"]),
294294
"interface_template": set(["name", "device_type"]),
295295
"inventory_item": set(["name", "device"]),
296-
"ip_address": set(["address", "vrf", "device", "interface"]),
297-
"ip_addresses": set(["address", "vrf", "device", "interface"]),
298-
"ipaddresses": set(["address", "vrf", "device", "interface"]),
296+
"ip_address": set(["address", "vrf", "device", "interface", "assigned_object"]),
297+
"ip_addresses": set(["address", "vrf", "device", "interface", "assigned_object"]),
298+
"ipaddresses": set(["address", "vrf", "device", "interface", "assigned_object"]),
299299
"lag": set(["name"]),
300300
"manufacturer": set(["slug"]),
301301
"master": set(["name"]),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
- test_eight['msg'] == "ip_address 10.10.1.30/16 created"
172172
- test_eight['ip_address']['address'] == "10.10.1.30/16"
173173
- test_eight['ip_address']['family'] == 4
174-
- test_eight['ip_address']['nat_inside'] == 11
174+
- test_eight['ip_address'].get('nat_inside')
175175
- test_eight['ip_address']['vrf'] == 1
176176

177177
- name: "9 - Create IP address on GigabitEthernet2 - test100 - State: present"
@@ -316,7 +316,7 @@
316316
assigned_object:
317317
name: Eth0
318318
virtual_machine: test101-vm
319-
state: "new"
319+
state: "present"
320320
register: test_fifteen
321321

322322
- name: "15 - ASSERT"

tests/integration/targets/regression-latest/tasks/main.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,51 @@
216216
that:
217217
- test_results is failed
218218
- 'test_results["msg"] == "One or more of the kwargs provided are invalid for circuits.circuittermination, provided kwargs: name. Acceptable kwargs: circuit, term_side"'
219+
220+
- name: "Issue #432 - Make sure same IPs get assigned to different device interfaces"
221+
netbox.netbox.netbox_ip_address:
222+
netbox_url: "http://localhost:32768"
223+
netbox_token: "0123456789abcdef0123456789abcdef01234567"
224+
data: "{{ item }}"
225+
loop: "{{ data }}"
226+
register: "test_results"
227+
vars:
228+
data:
229+
- address: 121.121.121.121/32
230+
assigned_object:
231+
device: "Test Nexus One"
232+
name: "Ethernet1/1"
233+
description: ansible-netbox-1.2.1
234+
dns_name: ansible-netbox-1.2.1
235+
role: HSRP
236+
status: Active
237+
- address: 121.121.121.121/32
238+
assigned_object:
239+
device: "Test Nexus Child One"
240+
name: "Ethernet2/1"
241+
description: ansible-netbox-1.2.1
242+
dns_name: ansible-netbox-1.2.1
243+
role: HSRP
244+
status: Active
245+
- address: 1.121.121.121/32
246+
assigned_object:
247+
device: "Test Nexus One"
248+
name: "Ethernet1/1"
249+
description: ansible-netbox-1.2.1
250+
dns_name: ansible-netbox-1.2.1
251+
role: HSRP
252+
status: Active
253+
- address: 1.121.121.121/32
254+
assigned_object:
255+
device: "Test Nexus Child One"
256+
name: "Ethernet2/1"
257+
description: ansible-netbox-1.2.1
258+
dns_name: ansible-netbox-1.2.1
259+
role: HSRP
260+
status: Active
261+
262+
- name: "ASSERT Issue #432 changes reflect correct device"
263+
assert:
264+
that:
265+
- test_results | json_query('results[?ip_address.address==`1.121.121.121/32`]') | length == 2
266+
- test_results | json_query('results[?ip_address.address==`121.121.121.121/32`]') | length == 2

tests/integration/targets/v2.9/tasks/netbox_ip_address.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
assigned_object:
317317
name: Eth0
318318
virtual_machine: test101-vm
319-
state: "new"
319+
state: "present"
320320
register: test_fifteen
321321

322322
- name: "15 - ASSERT"

0 commit comments

Comments
 (0)