Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pre-NetBox 3.3 features #928

Closed
wants to merge 1 commit into from
Closed
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: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ nb.circuits
nb.dcim
nb.extras
nb.ipam
nb.secrets
nb.tenancy
nb.virtualization

Expand Down Expand Up @@ -87,7 +86,6 @@ API_APPS_ENDPOINTS = dict(
],
extras=[],
ipam=["ip_addresses", "prefixes", "roles", "vlans", "vlan_groups", "vrfs"],
secrets=[],
tenancy=["tenants", "tenant_groups"],
virtualization=["clusters"],
)
Expand Down
1 change: 0 additions & 1 deletion docs/getting_started/contributing/modules/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Let's take a look at the output of the ``tree`` command within the ``plugins/``
│ │ ├── netbox_dcim.py
│ │ ├── netbox_extras.py
│ │ ├── netbox_ipam.py
│ │ ├── netbox_secrets.py
│ │ ├── netbox_tenancy.py
│ │ ├── netbox_utils.py
│ │ └── netbox_virtualization.py
Expand Down
10 changes: 0 additions & 10 deletions docs/module_utils/netbox_secrets/index.rst

This file was deleted.

82 changes: 0 additions & 82 deletions docs/plugins/nb_lookup_lookup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,43 +239,6 @@ Parameters
The api\_filter to use. Filters should be key value pairs separated by a space.


.. raw:: html

</div>

* - .. raw:: html

<div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-key_file"></div>

.. _ansible_collections.netbox.netbox.nb_lookup_lookup__parameter-key_file:

.. rst-class:: ansible-option-title

**key_file**

.. raw:: html

<a class="ansibleOptionLink" href="#parameter-key_file" title="Permalink to this option"></a>

.. rst-class:: ansible-option-type-line

:ansible-option-type:`string`




.. raw:: html

</div>

- .. raw:: html

<div class="ansible-option-cell">

The location of the private key tied to user account. Mutually exclusive with \ :emphasis:`private\_key`\ .


.. raw:: html

</div>
Expand Down Expand Up @@ -313,43 +276,6 @@ Parameters
The NetBox plugin to query


.. raw:: html

</div>

* - .. raw:: html

<div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-private_key"></div>

.. _ansible_collections.netbox.netbox.nb_lookup_lookup__parameter-private_key:

.. rst-class:: ansible-option-title

**private_key**

.. raw:: html

<a class="ansibleOptionLink" href="#parameter-private_key" title="Permalink to this option"></a>

.. rst-class:: ansible-option-type-line

:ansible-option-type:`string`




.. raw:: html

</div>

- .. raw:: html

<div class="ansible-option-cell">

The private key as a string. Mutually exclusive with \ :emphasis:`key\_file`\ .


.. raw:: html

</div>
Expand Down Expand Up @@ -531,12 +457,6 @@ Examples
api_filter='role=management tag=Dell'),
token='<redacted>') }}"

# Obtain a secret for R1-device
tasks:
- name: "Obtain secrets for R1-Device"
debug:
msg: "{{ query('netbox.netbox.nb_lookup', 'secrets', api_filter='device=R1-Device', api_endpoint='http://localhost/', token='<redacted>', key_file='~/.ssh/id_rsa') }}"

# Fetch bgp sessions for R1-device
tasks:
- name: "Obtain bgp sessions for R1-Device"
Expand All @@ -547,8 +467,6 @@ Examples
token='<redacted>',
plugin='mycustomstuff') }}"

msg: "{{ query('netbox.netbox.nb_lookup', 'secrets', api_filter='device=R1-Device', api_endpoint='http://localhost/', token='<redacted>', key_file='~/.ssh/id_rsa') }}"




Expand Down
43 changes: 7 additions & 36 deletions plugins/lookup/nb_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
description:
- Queries NetBox via its API to return virtually any information
capable of being held in NetBox.
- If wanting to obtain the plaintext attribute of a secret, I(private_key) or I(key_file) must be provided.
options:
_terms:
description:
Expand Down Expand Up @@ -57,14 +56,6 @@
- Whether or not to validate SSL of the NetBox instance
required: False
default: True
private_key:
description:
- The private key as a string. Mutually exclusive with I(key_file).
required: False
key_file:
description:
- The location of the private key tied to user account. Mutually exclusive with I(private_key).
required: False
raw_data:
type: bool
description:
Expand Down Expand Up @@ -100,12 +91,6 @@
api_filter='role=management tag=Dell'),
token='<redacted>') }}"

# Obtain a secret for R1-device
tasks:
- name: "Obtain secrets for R1-Device"
debug:
msg: "{{ query('netbox.netbox.nb_lookup', 'secrets', api_filter='device=R1-Device', api_endpoint='http://localhost/', token='<redacted>', key_file='~/.ssh/id_rsa') }}"

# Fetch bgp sessions for R1-device
tasks:
- name: "Obtain bgp sessions for R1-Device"
Expand All @@ -115,8 +100,6 @@
api_endpoint='http://localhost/',
token='<redacted>',
plugin='mycustomstuff') }}"

msg: "{{ query('netbox.netbox.nb_lookup', 'secrets', api_filter='device=R1-Device', api_endpoint='http://localhost/', token='<redacted>', key_file='~/.ssh/id_rsa') }}"
"""

RETURN = """
Expand Down Expand Up @@ -244,8 +227,6 @@ def get_endpoint(netbox, term):
"rirs": {"endpoint": netbox.ipam.rirs},
"roles": {"endpoint": netbox.ipam.roles},
"route-targets": {"endpoint": netbox.ipam.route_targets},
"secret-roles": {"endpoint": netbox.secrets.secret_roles},
"secrets": {"endpoint": netbox.secrets.secrets},
"services": {"endpoint": netbox.ipam.services},
"service-templates": {"endpoint": netbox.ipam.service_templates},
"site-groups": {"endpoint": netbox.dcim.site_groups},
Expand Down Expand Up @@ -392,31 +373,21 @@ def run(self, terms, variables=None, **kwargs):
or os.getenv("NETBOX_URL")
)
netbox_ssl_verify = kwargs.get("validate_certs", True)
netbox_private_key = kwargs.get("private_key")
netbox_private_key_file = kwargs.get("key_file")
netbox_api_filter = kwargs.get("api_filter")
netbox_raw_return = kwargs.get("raw_data")
netbox_plugin = kwargs.get("plugin")

if not isinstance(terms, list):
terms = [terms]

try:
session = requests.Session()
session.verify = netbox_ssl_verify
session = requests.Session()
session.verify = netbox_ssl_verify

netbox = pynetbox.api(
netbox_api_endpoint,
token=netbox_api_token if netbox_api_token else None,
private_key=netbox_private_key,
private_key_file=netbox_private_key_file,
)
netbox.http_session = session
except FileNotFoundError:
raise AnsibleError(
"%s cannot be found. Please make sure file exists."
% netbox_private_key_file
)
netbox = pynetbox.api(
netbox_api_endpoint,
token=netbox_api_token if netbox_api_token else None,
)
netbox.http_session = session

results = []
for term in terms:
Expand Down
58 changes: 0 additions & 58 deletions plugins/module_utils/netbox_secrets.py

This file was deleted.

1 change: 0 additions & 1 deletion plugins/module_utils/netbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"vrfs",
"services",
],
secrets=[],
tenancy=["tenants", "tenant_groups", "contacts", "contact_groups", "contact_roles"],
virtualization=[
"cluster_groups",
Expand Down