From 7a8f957c3f974d9f48eb0247dba0930e2894097d Mon Sep 17 00:00:00 2001 From: Patrick Toal Date: Thu, 21 May 2020 10:54:19 -0400 Subject: [PATCH] Include information in netbox_inventory --- .gitignore | 2 ++ .vscode/settings.json | 4 +++- netbox.yml | 23 ----------------------- netbox_inventory.yml | 16 +++++++++++++--- switch_config.yml | 23 +++++++++++++++++++++++ 5 files changed, 41 insertions(+), 27 deletions(-) delete mode 100644 netbox.yml create mode 100644 switch_config.yml diff --git a/.gitignore b/.gitignore index 5b0375b..fcaeeea 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,5 @@ roles/ .vscode/ keys/ +collections/ansible_collections/ +.vscode/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 9e26dfe..ed94f44 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1 +1,3 @@ -{} \ No newline at end of file +{ + "git.ignoreLimitWarning": true +} \ No newline at end of file diff --git a/netbox.yml b/netbox.yml deleted file mode 100644 index 5b677ff..0000000 --- a/netbox.yml +++ /dev/null @@ -1,23 +0,0 @@ -plugin: netbox -validate_certs: False -config_context: True -group_by: - - device_roles - - #query_filters: - # - role: core-switch - -#query_filters: -# - role: network-edge-router - -# Query filters are passed directly as an argument to the fetching queries. -# You can repeat tags in the query string. - - #query_filters: - # - role: server - # - tag: web - # - tag: production - - #compose: - # foo: last_updated - # bar: display_name diff --git a/netbox_inventory.yml b/netbox_inventory.yml index 1596fe6..7d73369 100644 --- a/netbox_inventory.yml +++ b/netbox_inventory.yml @@ -3,7 +3,17 @@ plugin: netbox.netbox.nb_inventory api_endpoint: http://netbox.mgmt.toal.ca validate_certs: True config_context: True +interfaces: True +services: True +plurals: False + group_by: - - device_roles - #query_filters: - # - role: network-edge-router + - site + - tag + - role + - platform + - cluster + + +#query_filters: +# - role: network-edge-router diff --git a/switch_config.yml b/switch_config.yml new file mode 100644 index 0000000..9102661 --- /dev/null +++ b/switch_config.yml @@ -0,0 +1,23 @@ +--- +- name: Collect Netbox Data + hosts: role_core-switch + gather_facts: false + collections: + - netbox.netbox + vars: + api_endpoint: "{{ lookup('env','NETBOX_API') }}" + api_token: "{{ lookup('env', 'NETBOX_TOKEN') }}" + + tasks: + # - name: Gather Device Information + # set_fact: + # device_info: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='name=' + inventory_hostname, api_endpoint=api_endpoint, token=api_token )[0] }}" + - debug: + var: interfaces + + # - name: Obtain list of devices from Netbox + # debug: + # var: > + # "Device {{ item.value.display_name }} (ID: {{ item.key }}) was + # manufactured by {{ item.value.device_type.manufacturer.name }}" + # loop: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint=api_endpoint, token=api_token ) }}"