Skip to content

Commit 8f67d74

Browse files
update lookup docs (#51)
1 parent 5d36aec commit 8f67d74

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ env:
1313

1414
matrix:
1515
include:
16-
- name: "Python 3.6 - Netbox 2.5 - Ansible 2.9"
16+
- name: "Python 3.6 - Netbox 2.5 - Latest PyPi Ansible"
1717
python: 3.6
18-
env: PYTHON_VER=3.6 VERSION=v2.5 ANSIBLE_VER=2.9.0
18+
env: PYTHON_VER=3.6 VERSION=v2.5
1919
install:
2020
- cd ..
2121
# Setup netbox container for integration testing
@@ -27,15 +27,15 @@ matrix:
2727
- cd ..
2828
- pip install -U pip
2929
- pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0
30-
- pip install pynetbox==4.0.6 cryptography codecov jmespath ansible==$ANSIBLE_VER
30+
- pip install pynetbox==4.0.6 cryptography codecov jmespath ansible
3131

3232
- name: "Python 3.6 - Netbox Latest - Ansible Devel"
3333
python: 3.6
34-
env: PYTHON_VER=3.6 VERSION=v2.6.6
34+
env: PYTHON_VER=3.6 VERSION=v2.6
3535
install:
3636
- cd ..
3737
# Setup netbox container for integration testing
38-
- git clone https://github.com/netbox-community/netbox-docker.git
38+
- git clone https://github.com/FragmentedPacket/netbox-docker.git
3939
- cd netbox-docker
4040
- docker-compose pull
4141
- docker-compose up -d

plugins/lookup/netbox.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
description:
3131
- Queries Netbox via its API to return virtually any information
3232
capable of being held in Netbox.
33-
- While secrets can be queried, the plugin doesn't yet support
34-
decrypting them.
33+
- If wanting to obtain the plaintext attribute of a secret, key_file must be provided.
3534
options:
3635
_terms:
3736
description:
@@ -49,6 +48,10 @@
4948
description:
5049
- The API token created through Netbox
5150
required: True
51+
key_file:
52+
description:
53+
- The location of the private key tied to user account.
54+
required: False
5255
requirements:
5356
- pynetbox
5457
"""
@@ -78,6 +81,12 @@
7881
api_endpoint='http://localhost/',
7982
api_filter='role=management tag=Dell'),
8083
token='<redacted>') }}"
84+
85+
# Obtain a secret for R1-device
86+
tasks:
87+
- name: "Obtain secrets for R1-Device"
88+
debug:
89+
msg: "{{ query('netbox', 'secrets', api_filter='device=R1-Device', api_endpoint='http://localhost/', token='<redacted>', key_file='~/.ssh/id_rsa') }}"
8190
"""
8291

8392
RETURN = """
@@ -149,9 +158,6 @@ def get_endpoint(netbox, term):
149158
"rirs": {"endpoint": netbox.ipam.rirs},
150159
"roles": {"endpoint": netbox.ipam.roles},
151160
"secret-roles": {"endpoint": netbox.secrets.secret_roles},
152-
# Note: Currently unable to decrypt secrets as key wizardry needs to
153-
# take place first but term will return unencrypted elements of secrets
154-
# i.e. that they exist etc.
155161
"secrets": {"endpoint": netbox.secrets.secrets},
156162
"services": {"endpoint": netbox.ipam.services},
157163
"sites": {"endpoint": netbox.dcim.sites},

0 commit comments

Comments
 (0)