Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
cd ..
if: matrix.VERSION == 'v3.4'
- name: Install and configure Poetry
uses: snok/install-poetry@v1.1.1
uses: snok/install-poetry@v1.3.3
with:
virtualenvs-create: false
- name: Install Python packages
Expand Down
16 changes: 13 additions & 3 deletions plugins/inventory/nb_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
__metaclass__ = type

DOCUMENTATION = """
name: nb_inventory
plugin_type: inventory
name: nb_inventory
author:
- Remy Leone (@sieben)
- Anthony Ruhier (@Anthony25)
Expand Down Expand Up @@ -139,6 +138,7 @@
- I(rack_group) is supported on NetBox versions 2.10 or lower only
- I(location) is supported on NetBox versions 2.11 or higher only
type: list
elements: str
choices:
- sites
- site
Expand Down Expand Up @@ -180,18 +180,21 @@
- List of parameters passed to the query string for both devices and VMs (Multiple values may be separated by commas).
- You can also use Jinja2 templates.
type: list
elements: str
default: []
device_query_filters:
description:
- List of parameters passed to the query string for devices (Multiple values may be separated by commas).
- You can also use Jinja2 templates.
type: list
elements: str
default: []
vm_query_filters:
description:
- List of parameters passed to the query string for VMs (Multiple values may be separated by commas).
- You can also use Jinja2 templates.
type: list
elements: str
default: []
timeout:
description: Timeout for NetBox requests in seconds
Expand Down Expand Up @@ -348,7 +351,7 @@
from itertools import chain
from collections import defaultdict
from ipaddress import ip_interface
from packaging import specifiers, version


from ansible.constants import DEFAULT_LOCAL_TMP
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
Expand All @@ -360,6 +363,13 @@
from ansible.module_utils.six.moves.urllib.parse import urlencode
from ansible.module_utils.six import raise_from

try:
from packaging import specifiers, version
except ImportError as imp_exc:
PACKAGING_IMPORT_ERROR = imp_exc
else:
PACKAGING_IMPORT_ERROR = None

try:
import pytz
except ImportError as imp_exc:
Expand Down
51 changes: 25 additions & 26 deletions plugins/lookup/nb_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,11 @@

from __future__ import absolute_import, division, print_function

import os
import functools
from pprint import pformat

from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase
from ansible.parsing.splitter import parse_kv, split_args
from ansible.utils.display import Display
from ansible.module_utils.six import raise_from

try:
import pynetbox
except ImportError as imp_exc:
PYNETBOX_LIBRARY_IMPORT_ERROR = imp_exc
else:
PYNETBOX_LIBRARY_IMPORT_ERROR = None

try:
import requests
except ImportError as imp_exc:
REQUESTS_LIBRARY_IMPORT_ERROR = imp_exc
else:
REQUESTS_LIBRARY_IMPORT_ERROR = None


__metaclass__ = type

DOCUMENTATION = """
lookup: nb_lookup
author: Chris Mills (@cpmills1975)
name: nb_lookup
version_added: "0.1.0"
short_description: Queries and returns elements from NetBox
description:
Expand Down Expand Up @@ -151,6 +126,30 @@
type: list
"""

import os
import functools
from pprint import pformat

from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase
from ansible.parsing.splitter import parse_kv, split_args
from ansible.utils.display import Display
from ansible.module_utils.six import raise_from

try:
import pynetbox
except ImportError as imp_exc:
PYNETBOX_LIBRARY_IMPORT_ERROR = imp_exc
else:
PYNETBOX_LIBRARY_IMPORT_ERROR = None

try:
import requests
except ImportError as imp_exc:
REQUESTS_LIBRARY_IMPORT_ERROR = imp_exc
else:
REQUESTS_LIBRARY_IMPORT_ERROR = None


def get_endpoint(netbox, term):
"""
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/netbox_dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from packaging.version import Version

HAS_PACKAGING = True
PACKAGING_IMPORT_ERROR = ""
except ImportError as imp_exc:
PACKAGING_IMPORT_ERROR = imp_exc
HAS_PACKAGING = False
Expand Down
39 changes: 21 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "GPLv3"

[tool.poetry.dependencies]
python = "^3.8"
ansible-core = "2.12.*"
ansible-core = "2.13.*"
black = "*"
codecov = "*"
coverage = "^4.0"
Expand Down