Skip to content

Commit 20714cd

Browse files
authored
Fixes #583: Move to Ansible-core for CI tests (#591)
* Update modules and CI to satisfy ansible-core 2.11 ansible-test requirements
1 parent 706d105 commit 20714cd

File tree

14 files changed

+84
-78
lines changed

14 files changed

+84
-78
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
uses: actions/setup-python@v2
1414
with:
1515
python-version: 3.6
16-
- name: Install ansible-base to deploy collection
17-
run: pip install ansible-base
16+
- name: Install ansible-core to deploy collection
17+
run: pip install ansible-core
1818
- name: Build and Deploy Collection
1919
uses: artis3n/ansible_galaxy_collection@v2
2020
with:

plugins/lookup/nb_lookup.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,22 @@
1919
from ansible.plugins.lookup import LookupBase
2020
from ansible.parsing.splitter import parse_kv, split_args
2121
from ansible.utils.display import Display
22+
from ansible.module_utils.six import raise_from
23+
24+
try:
25+
import pynetbox
26+
except ImportError as imp_exc:
27+
PYNETBOX_LIBRARY_IMPORT_ERROR = imp_exc
28+
else:
29+
PYNETBOX_LIBRARY_IMPORT_ERROR = None
30+
31+
try:
32+
import requests
33+
except ImportError as imp_exc:
34+
REQUESTS_LIBRARY_IMPORT_ERROR = imp_exc
35+
else:
36+
REQUESTS_LIBRARY_IMPORT_ERROR = None
2237

23-
import pynetbox
24-
import requests
2538

2639
__metaclass__ = type
2740

@@ -296,6 +309,17 @@ class LookupModule(LookupBase):
296309
"""
297310

298311
def run(self, terms, variables=None, **kwargs):
312+
if PYNETBOX_LIBRARY_IMPORT_ERROR:
313+
raise_from(
314+
AnsibleError("pynetbox must be installed to use this plugin"),
315+
PYNETBOX_LIBRARY_IMPORT_ERROR,
316+
)
317+
318+
if REQUESTS_LIBRARY_IMPORT_ERROR:
319+
raise_from(
320+
AnsibleError("requests must be installed to use this plugin"),
321+
REQUESTS_LIBRARY_IMPORT_ERROR,
322+
)
299323

300324
netbox_api_token = (
301325
kwargs.get("token")

plugins/module_utils/netbox_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ def _fetch_choice_value(self, search, endpoint):
833833
msg="Failed to fetch endpoint choices to validate against. This requires a write-enabled token. Make sure the token is write-enabled. If looking to fetch only information, use either the inventory or lookup plugin."
834834
)
835835

836-
choices = [x for x in chain.from_iterable(endpoint_choices.values())]
836+
choices = list(chain.from_iterable(endpoint_choices.values()))
837837

838838
for item in choices:
839839
if item["display_name"].lower() == search.lower():

plugins/modules/netbox_device_interface.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@
6464
required: false
6565
type: str
6666
form_factor:
67-
description:
68-
- |
69-
Form factor of the interface:
70-
ex. 1000Base-T (1GE), Virtual, 10GBASE-T (10GE)
71-
This has to be specified exactly as what is found within UI
72-
required: false
73-
type: raw
67+
description:
68+
- |
69+
Form factor of the interface:
70+
ex. 1000Base-T (1GE), Virtual, 10GBASE-T (10GE)
71+
This has to be specified exactly as what is found within UI
72+
required: false
73+
type: raw
7474
type:
7575
description:
7676
- |
@@ -299,7 +299,10 @@ def main():
299299
device=dict(required=False, type="raw"),
300300
name=dict(required=True, type="str"),
301301
form_factor=dict(
302-
required=False, type="raw", removed_in_version="0.3.0"
302+
required=False,
303+
type="raw",
304+
removed_in_version="4.0.0",
305+
removed_from_collection="netbox.netbox",
303306
),
304307
label=dict(required=False, type="str"),
305308
type=dict(required=False, type="str"),

plugins/modules/netbox_ip_address.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@
5151
- Defines the IP address configuration
5252
suboptions:
5353
family:
54-
description:
55-
- (DEPRECATED) - NetBox now handles determining the IP family natively.
56-
- Specifies with address family the IP address belongs to
57-
choices:
58-
- 4
59-
- 6
60-
required: false
61-
type: int
54+
description:
55+
- (DEPRECATED) - NetBox now handles determining the IP family natively.
56+
- Specifies with address family the IP address belongs to
57+
choices:
58+
- 4
59+
- 6
60+
required: false
61+
type: int
6262
address:
6363
description:
6464
- Required if state is C(present)
@@ -227,7 +227,6 @@
227227
netbox_url: http://netbox.local
228228
netbox_token: thisIsMyToken
229229
data:
230-
family: 4
231230
address: 192.168.1.20
232231
vrf: Test
233232
tenant: Test Tenant
@@ -242,7 +241,6 @@
242241
netbox_url: http://netbox.local
243242
netbox_token: thisIsMyToken
244243
data:
245-
family: 4
246244
address: 192.168.1.30
247245
vrf: Test
248246
nat_inside:
@@ -323,13 +321,14 @@ def main():
323321
type="dict",
324322
required=True,
325323
options=dict(
324+
address=dict(required=False, type="str"),
326325
family=dict(
327326
required=False,
328327
type="int",
329328
choices=[4, 6],
330-
removed_in_version="0.3.0",
329+
removed_in_version="4.0.0",
330+
removed_from_collection="netbox.netbox",
331331
),
332-
address=dict(required=False, type="str"),
333332
prefix=dict(required=False, type="raw"),
334333
vrf=dict(required=False, type="raw"),
335334
tenant=dict(required=False, type="raw"),

poetry.lock

Lines changed: 30 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "GPLv3"
77

88
[tool.poetry.dependencies]
99
python = "^3.6"
10-
ansible-base = "^2.10.0"
10+
ansible-core = "^2.11.0"
1111
black = "19.10b0"
1212
codecov = "*"
1313
coverage = "^4.0"
@@ -23,7 +23,7 @@ pyyaml = "*"
2323
mock = "^4.0.2"
2424
antsibull = "^0.25.0"
2525
importlib-metadata = "1.7.0"
26-
pylint = "^2.6.0"
26+
pylint = "^2.8.0"
2727
packaging = "^20.9"
2828

2929
[tool.poetry.dev-dependencies]

tests/integration/targets/v2.10/tasks/netbox_aggregate.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
- test_one['diff']['before']['state'] == "absent"
2222
- test_one['diff']['after']['state'] == "present"
2323
- test_one['aggregate']['prefix'] == "10.0.0.0/8"
24-
- test_one['aggregate']['family'] == 4
2524
- test_one['aggregate']['rir'] == 1
2625
- test_one['msg'] == "aggregate 10.0.0.0/8 created"
2726

@@ -39,7 +38,6 @@
3938
that:
4039
- not test_two['changed']
4140
- test_two['aggregate']['prefix'] == "10.0.0.0/8"
42-
- test_two['aggregate']['family'] == 4
4341
- test_two['aggregate']['rir'] == 1
4442
- test_two['msg'] == "aggregate 10.0.0.0/8 already exists"
4543

@@ -65,7 +63,6 @@
6563
- test_three['diff']['after']['description'] == "Test Description"
6664
- test_three['diff']['after']['tags'][0] == 4
6765
- test_three['aggregate']['prefix'] == "10.0.0.0/8"
68-
- test_three['aggregate']['family'] == 4
6966
- test_three['aggregate']['rir'] == 1
7067
- test_three['aggregate']['date_added'] == "1989-01-18"
7168
- test_three['aggregate']['description'] == "Test Description"
@@ -86,7 +83,6 @@
8683
that:
8784
- test_four is changed
8885
- test_four['aggregate']['prefix'] == "10.0.0.0/8"
89-
- test_four['aggregate']['family'] == 4
9086
- test_four['aggregate']['rir'] == 1
9187
- test_four['aggregate']['date_added'] == "1989-01-18"
9288
- test_four['aggregate']['description'] == "Test Description"
@@ -110,6 +106,5 @@
110106
- test_five['diff']['before']['state'] == "absent"
111107
- test_five['diff']['after']['state'] == "present"
112108
- test_five['aggregate']['prefix'] == "2001::/32"
113-
- test_five['aggregate']['family'] == 6
114109
- test_five['aggregate']['rir'] == 1
115110
- test_five['msg'] == "aggregate 2001::/32 created"

0 commit comments

Comments
 (0)