diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 209f3b96..f2352cfa 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -117,7 +117,7 @@ jobs: - name: "Upload binaries to release" uses: "svenstaro/upload-release-action@v2" with: - repo_token: "${{ secrets.NTC_GITHUB_TOKEN }}" + repo_token: "${{ secrets.GH_NAUTOBOT_BOT_TOKEN }}" file: "build/*" tag: "${{ github.ref }}" overwrite: true diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 082e5faa..ab25b2eb 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -356,7 +356,7 @@ releases: - (#172) Add description to manufacturer 4.3.0: - changes: + changes: minor_changes: - (#185) Updated Doc Fragments - (#187) Updated Tag documentation @@ -373,3 +373,15 @@ releases: - (#211) Removes codecov from dev dependencies - (#203) Adds plugin module - (#209) Catches HTTPError for GraphQL query and enables Ansible retries + + 4.5.0: + changes: + bugfixes: + - (#223) Inventory Hosts Empty On Error + - (#209) Catches HTTPError for `query_graphql` and fails to enable ansible retries + - (#228) Fixes graphql inventory grouping by tags + minor_changes: + - (#211) Removes codecov from dev dependencies + - (#220) Adds status option to device_interface module + - (#217) Fixes and enables testing for Nautobot 1.5 + release_summary: "Fixes error handling in inventory to not erase inventories, minor bug fixes, and introduces Plugin module" diff --git a/docs/plugins/aggregate_module.rst b/docs/plugins/aggregate_module.rst index 1abefcfa..642252e3 100644 --- a/docs/plugins/aggregate_module.rst +++ b/docs/plugins/aggregate_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.aggregate module -- Creates or removes aggregates from Na .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/cable_module.rst b/docs/plugins/cable_module.rst index 488e840a..b98c591a 100644 --- a/docs/plugins/cable_module.rst +++ b/docs/plugins/cable_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.cable module -- Create, update or delete cables within Na .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/circuit_module.rst b/docs/plugins/circuit_module.rst index 74353431..e1b2a979 100644 --- a/docs/plugins/circuit_module.rst +++ b/docs/plugins/circuit_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.circuit module -- Create, update or delete circuits withi .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/circuit_termination_module.rst b/docs/plugins/circuit_termination_module.rst index fb14ef2a..cb93d309 100644 --- a/docs/plugins/circuit_termination_module.rst +++ b/docs/plugins/circuit_termination_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.circuit_termination module -- Create, update or delete ci .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/circuit_type_module.rst b/docs/plugins/circuit_type_module.rst index e75cfd11..64957ac9 100644 --- a/docs/plugins/circuit_type_module.rst +++ b/docs/plugins/circuit_type_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.circuit_type module -- Create, update or delete circuit t .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/cluster_group_module.rst b/docs/plugins/cluster_group_module.rst index b404444f..fbd7fec6 100644 --- a/docs/plugins/cluster_group_module.rst +++ b/docs/plugins/cluster_group_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.cluster_group module -- Create, update or delete cluster .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/cluster_module.rst b/docs/plugins/cluster_module.rst index 240d1530..89528620 100644 --- a/docs/plugins/cluster_module.rst +++ b/docs/plugins/cluster_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.cluster module -- Create, update or delete clusters withi .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/cluster_type_module.rst b/docs/plugins/cluster_type_module.rst index 0f248365..ded0db52 100644 --- a/docs/plugins/cluster_type_module.rst +++ b/docs/plugins/cluster_type_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.cluster_type module -- Create, update or delete cluster t .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/console_port_module.rst b/docs/plugins/console_port_module.rst index 630fc8c4..30a3a067 100644 --- a/docs/plugins/console_port_module.rst +++ b/docs/plugins/console_port_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.console_port module -- Create, update or delete console p .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/console_port_template_module.rst b/docs/plugins/console_port_template_module.rst index 660f2090..a4cfae02 100644 --- a/docs/plugins/console_port_template_module.rst +++ b/docs/plugins/console_port_template_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.console_port_template module -- Create, update or delete .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/console_server_port_module.rst b/docs/plugins/console_server_port_module.rst index 33b74110..4d1eeeec 100644 --- a/docs/plugins/console_server_port_module.rst +++ b/docs/plugins/console_server_port_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.console_server_port module -- Create, update or delete co .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/console_server_port_template_module.rst b/docs/plugins/console_server_port_template_module.rst index 5ad428f4..0040b617 100644 --- a/docs/plugins/console_server_port_template_module.rst +++ b/docs/plugins/console_server_port_template_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.console_server_port_template module -- Create, update or .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/device_bay_module.rst b/docs/plugins/device_bay_module.rst index e9b1b137..fa301a98 100644 --- a/docs/plugins/device_bay_module.rst +++ b/docs/plugins/device_bay_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.device_bay module -- Create, update or delete device bays .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/device_bay_template_module.rst b/docs/plugins/device_bay_template_module.rst index 96214af6..f4c8ef3f 100644 --- a/docs/plugins/device_bay_template_module.rst +++ b/docs/plugins/device_bay_template_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.device_bay_template module -- Create, update or delete de .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/device_interface_module.rst b/docs/plugins/device_interface_module.rst index ece0fca6..0e530645 100644 --- a/docs/plugins/device_interface_module.rst +++ b/docs/plugins/device_interface_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.device_interface module -- Creates or removes interfaces .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, @@ -138,6 +138,43 @@ Parameters API Version Nautobot REST API + .. raw:: html + + + + * - .. raw:: html + +
+
+ + .. _ansible_collections.networktocode.nautobot.device_interface_module__parameter-bridge: + + .. rst-class:: ansible-option-title + + **bridge** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`any` + + :ansible-option-versionadded:`added in networktocode.nautobot 4.5.0` + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Interface that will be the bridge of the interface being created + + .. raw:: html
@@ -561,6 +598,43 @@ Parameters Name of the interface to be created + .. raw:: html + + + + * - .. raw:: html + +
+
+ + .. _ansible_collections.networktocode.nautobot.device_interface_module__parameter-parent_interface: + + .. rst-class:: ansible-option-title + + **parent_interface** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`any` + + :ansible-option-versionadded:`added in networktocode.nautobot 4.5.0` + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Interface that will be the parent of the interface being created + + .. raw:: html
@@ -644,6 +718,45 @@ Parameters - :ansible-option-choices-entry-default:`"present"` :ansible-option-choices-default-mark:`← (default)` + .. raw:: html + + + + * - .. raw:: html + +
+
+ + .. _ansible_collections.networktocode.nautobot.device_interface_module__parameter-status: + + .. rst-class:: ansible-option-title + + **status** + + .. raw:: html + + + + .. rst-class:: ansible-option-type-line + + :ansible-option-type:`any` + + :ansible-option-versionadded:`added in networktocode.nautobot 4.4.0` + + + .. raw:: html + +
+ + - .. raw:: html + +
+ + The status of the interface + + Required if \ :emphasis:`state=present`\ and using \ :emphasis:`api\_version`\ 1.4+ + + .. raw:: html
@@ -1059,6 +1172,23 @@ Examples enabled: false custom_fields: monitored: True + - name: Create child interface + networktocode.nautobot.device_interface: + url: http://nautobot.local + token: thisIsMyToken + device: test100 + name: GigabitEthernet1/1/1 + type: Virtual + parent_interface: + name: GigabitEthernet1/1 + - name: Create bridge interface + networktocode.nautobot.device_interface: + url: http://nautobot.local + token: thisIsMyToken + device: test100 + name: Bridge1 + bridge: + name: GigabitEthernet1/1 diff --git a/docs/plugins/device_interface_template_module.rst b/docs/plugins/device_interface_template_module.rst index 547031a0..18306d42 100644 --- a/docs/plugins/device_interface_template_module.rst +++ b/docs/plugins/device_interface_template_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.device_interface_template module -- Creates or removes in .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/device_module.rst b/docs/plugins/device_module.rst index 66658ec2..8a216ee5 100644 --- a/docs/plugins/device_module.rst +++ b/docs/plugins/device_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.device module -- Create, update or delete devices within .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/device_role_module.rst b/docs/plugins/device_role_module.rst index 7829ba97..42659d4e 100644 --- a/docs/plugins/device_role_module.rst +++ b/docs/plugins/device_role_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.device_role module -- Create, update or delete devices ro .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/device_type_module.rst b/docs/plugins/device_type_module.rst index 079de222..cc01924a 100644 --- a/docs/plugins/device_type_module.rst +++ b/docs/plugins/device_type_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.device_type module -- Create, update or delete device typ .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/front_port_module.rst b/docs/plugins/front_port_module.rst index 42e22646..f7786dd2 100644 --- a/docs/plugins/front_port_module.rst +++ b/docs/plugins/front_port_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.front_port module -- Create, update or delete front ports .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/front_port_template_module.rst b/docs/plugins/front_port_template_module.rst index 5d87e252..18f72ee6 100644 --- a/docs/plugins/front_port_template_module.rst +++ b/docs/plugins/front_port_template_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.front_port_template module -- Create, update or delete fr .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/gql_inventory_inventory.rst b/docs/plugins/gql_inventory_inventory.rst index 48aacfb7..17c44712 100644 --- a/docs/plugins/gql_inventory_inventory.rst +++ b/docs/plugins/gql_inventory_inventory.rst @@ -42,7 +42,7 @@ networktocode.nautobot.gql_inventory inventory -- Nautobot inventory source usin .. Collection note .. note:: - This inventory plugin is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This inventory plugin is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this inventory plugin, diff --git a/docs/plugins/index.rst b/docs/plugins/index.rst index 51e312c6..1a9ff8be 100644 --- a/docs/plugins/index.rst +++ b/docs/plugins/index.rst @@ -6,7 +6,7 @@ Networktocode.Nautobot ====================== -Collection version 4.3.1 +Collection version 4.5.0 .. contents:: :local: diff --git a/docs/plugins/inventory_inventory.rst b/docs/plugins/inventory_inventory.rst index 8726535c..ee51c202 100644 --- a/docs/plugins/inventory_inventory.rst +++ b/docs/plugins/inventory_inventory.rst @@ -42,7 +42,7 @@ networktocode.nautobot.inventory inventory -- Nautobot inventory source .. Collection note .. note:: - This inventory plugin is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This inventory plugin is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. diff --git a/docs/plugins/inventory_item_module.rst b/docs/plugins/inventory_item_module.rst index c13a27cb..c640f987 100644 --- a/docs/plugins/inventory_item_module.rst +++ b/docs/plugins/inventory_item_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.inventory_item module -- Creates or removes inventory ite .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/ip_address_module.rst b/docs/plugins/ip_address_module.rst index 5a677c74..a2e7b0de 100644 --- a/docs/plugins/ip_address_module.rst +++ b/docs/plugins/ip_address_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.ip_address module -- Creates or removes IP addresses from .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/ipam_role_module.rst b/docs/plugins/ipam_role_module.rst index ad2feddd..3bfc143d 100644 --- a/docs/plugins/ipam_role_module.rst +++ b/docs/plugins/ipam_role_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.ipam_role module -- Creates or removes ipam roles from Na .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/location_module.rst b/docs/plugins/location_module.rst index 139b1ddc..5254fc66 100644 --- a/docs/plugins/location_module.rst +++ b/docs/plugins/location_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.location module -- Creates or removes locations from Naut .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/location_type_module.rst b/docs/plugins/location_type_module.rst index 415cac3d..1a49357f 100644 --- a/docs/plugins/location_type_module.rst +++ b/docs/plugins/location_type_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.location_type module -- Creates or removes location types .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/lookup_graphql_lookup.rst b/docs/plugins/lookup_graphql_lookup.rst index f7467c6f..f1353651 100644 --- a/docs/plugins/lookup_graphql_lookup.rst +++ b/docs/plugins/lookup_graphql_lookup.rst @@ -42,7 +42,7 @@ networktocode.nautobot.lookup_graphql lookup -- Queries and returns elements fro .. Collection note .. note:: - This lookup plugin is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This lookup plugin is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this lookup plugin, diff --git a/docs/plugins/lookup_lookup.rst b/docs/plugins/lookup_lookup.rst index b381fe21..9ece553e 100644 --- a/docs/plugins/lookup_lookup.rst +++ b/docs/plugins/lookup_lookup.rst @@ -42,7 +42,7 @@ networktocode.nautobot.lookup lookup -- Queries and returns elements from Nautob .. Collection note .. note:: - This lookup plugin is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This lookup plugin is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this lookup plugin, diff --git a/docs/plugins/manufacturer_module.rst b/docs/plugins/manufacturer_module.rst index 355f8eae..7e1181cb 100644 --- a/docs/plugins/manufacturer_module.rst +++ b/docs/plugins/manufacturer_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.manufacturer module -- Create or delete manufacturers wit .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/nautobot_server_module.rst b/docs/plugins/nautobot_server_module.rst index e3761285..10a6bf00 100644 --- a/docs/plugins/nautobot_server_module.rst +++ b/docs/plugins/nautobot_server_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.nautobot_server module -- Manages Nautobot Server applica .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/platform_module.rst b/docs/plugins/platform_module.rst index 26e543ea..3480a9ce 100644 --- a/docs/plugins/platform_module.rst +++ b/docs/plugins/platform_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.platform module -- Create or delete platforms within Naut .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/plugin_module.rst b/docs/plugins/plugin_module.rst index cc7fc99a..f7985648 100644 --- a/docs/plugins/plugin_module.rst +++ b/docs/plugins/plugin_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.plugin module -- CRUD operation on plugin objects .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/power_feed_module.rst b/docs/plugins/power_feed_module.rst index f6a3a716..876e9480 100644 --- a/docs/plugins/power_feed_module.rst +++ b/docs/plugins/power_feed_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.power_feed module -- Create, update or delete power feeds .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/power_outlet_module.rst b/docs/plugins/power_outlet_module.rst index 3b488add..65e6ae56 100644 --- a/docs/plugins/power_outlet_module.rst +++ b/docs/plugins/power_outlet_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.power_outlet module -- Create, update or delete power out .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/power_outlet_template_module.rst b/docs/plugins/power_outlet_template_module.rst index 93fa7c8a..55240586 100644 --- a/docs/plugins/power_outlet_template_module.rst +++ b/docs/plugins/power_outlet_template_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.power_outlet_template module -- Create, update or delete .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/power_panel_module.rst b/docs/plugins/power_panel_module.rst index 9a72bccb..f92ef9ad 100644 --- a/docs/plugins/power_panel_module.rst +++ b/docs/plugins/power_panel_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.power_panel module -- Create, update or delete power pane .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/power_port_module.rst b/docs/plugins/power_port_module.rst index dd3b03e6..2da52aae 100644 --- a/docs/plugins/power_port_module.rst +++ b/docs/plugins/power_port_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.power_port module -- Create, update or delete power ports .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/power_port_template_module.rst b/docs/plugins/power_port_template_module.rst index 5b019011..5c9b38e3 100644 --- a/docs/plugins/power_port_template_module.rst +++ b/docs/plugins/power_port_template_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.power_port_template module -- Create, update or delete po .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/prefix_module.rst b/docs/plugins/prefix_module.rst index 37d2ab52..c38812dc 100644 --- a/docs/plugins/prefix_module.rst +++ b/docs/plugins/prefix_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.prefix module -- Creates or removes prefixes from Nautobo .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/provider_module.rst b/docs/plugins/provider_module.rst index 6a401832..9a8eeb84 100644 --- a/docs/plugins/provider_module.rst +++ b/docs/plugins/provider_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.provider module -- Create, update or delete providers wit .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/query_graphql_module.rst b/docs/plugins/query_graphql_module.rst index 43bd4f4c..b5e2d71d 100644 --- a/docs/plugins/query_graphql_module.rst +++ b/docs/plugins/query_graphql_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.query_graphql module -- Queries and returns elements from .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/rack_group_module.rst b/docs/plugins/rack_group_module.rst index a51b230a..58b0988f 100644 --- a/docs/plugins/rack_group_module.rst +++ b/docs/plugins/rack_group_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.rack_group module -- Create, update or delete racks group .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/rack_module.rst b/docs/plugins/rack_module.rst index b1bfa78a..40c63831 100644 --- a/docs/plugins/rack_module.rst +++ b/docs/plugins/rack_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.rack module -- Create, update or delete racks within Naut .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/rack_role_module.rst b/docs/plugins/rack_role_module.rst index 6ba07096..c7c6be94 100644 --- a/docs/plugins/rack_role_module.rst +++ b/docs/plugins/rack_role_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.rack_role module -- Create, update or delete racks roles .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/rear_port_module.rst b/docs/plugins/rear_port_module.rst index e5ac4891..f9681150 100644 --- a/docs/plugins/rear_port_module.rst +++ b/docs/plugins/rear_port_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.rear_port module -- Create, update or delete rear ports w .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/rear_port_template_module.rst b/docs/plugins/rear_port_template_module.rst index fe1a1757..81a6bd5a 100644 --- a/docs/plugins/rear_port_template_module.rst +++ b/docs/plugins/rear_port_template_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.rear_port_template module -- Create, update or delete rea .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/region_module.rst b/docs/plugins/region_module.rst index f8727bfe..c41480d7 100644 --- a/docs/plugins/region_module.rst +++ b/docs/plugins/region_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.region module -- Creates or removes regions from Nautobot .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/relationship_association_module.rst b/docs/plugins/relationship_association_module.rst index b4a3f97d..e96ad529 100644 --- a/docs/plugins/relationship_association_module.rst +++ b/docs/plugins/relationship_association_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.relationship_association module -- Creates or removes a r .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, @@ -268,7 +268,7 @@ Parameters .. rst-class:: ansible-option-type-line - :ansible-option-type:`string` / :ansible-option-required:`required` + :ansible-option-type:`any` / :ansible-option-required:`required` .. raw:: html diff --git a/docs/plugins/rir_module.rst b/docs/plugins/rir_module.rst index c52bb972..b699eb0d 100644 --- a/docs/plugins/rir_module.rst +++ b/docs/plugins/rir_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.rir module -- Create, update or delete RIRs within Nautob .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/route_target_module.rst b/docs/plugins/route_target_module.rst index 96bb717a..a30d20f5 100644 --- a/docs/plugins/route_target_module.rst +++ b/docs/plugins/route_target_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.route_target module -- Creates or removes route targets f .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/service_module.rst b/docs/plugins/service_module.rst index af380b4c..72f9ae6b 100644 --- a/docs/plugins/service_module.rst +++ b/docs/plugins/service_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.service module -- Creates or removes service from Nautobo .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/site_module.rst b/docs/plugins/site_module.rst index 8ef70f3f..5652c794 100644 --- a/docs/plugins/site_module.rst +++ b/docs/plugins/site_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.site module -- Creates or removes sites from Nautobot .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/status_module.rst b/docs/plugins/status_module.rst index c2c7e070..069215c6 100644 --- a/docs/plugins/status_module.rst +++ b/docs/plugins/status_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.status module -- Creates or removes status from Nautobot .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/tag_module.rst b/docs/plugins/tag_module.rst index 292bff4c..01812f4a 100644 --- a/docs/plugins/tag_module.rst +++ b/docs/plugins/tag_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.tag module -- Creates or removes tags from Nautobot .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/tenant_group_module.rst b/docs/plugins/tenant_group_module.rst index 06e8d2f8..970d85e3 100644 --- a/docs/plugins/tenant_group_module.rst +++ b/docs/plugins/tenant_group_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.tenant_group module -- Creates or removes tenant groups f .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/tenant_module.rst b/docs/plugins/tenant_module.rst index 07ee3d4d..f4005f5a 100644 --- a/docs/plugins/tenant_module.rst +++ b/docs/plugins/tenant_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.tenant module -- Creates or removes tenants from Nautobot .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/virtual_chassis_module.rst b/docs/plugins/virtual_chassis_module.rst index 0f427ba0..685465d3 100644 --- a/docs/plugins/virtual_chassis_module.rst +++ b/docs/plugins/virtual_chassis_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.virtual_chassis module -- Create, update or delete virtua .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/virtual_machine_module.rst b/docs/plugins/virtual_machine_module.rst index fcd66541..4c1259d2 100644 --- a/docs/plugins/virtual_machine_module.rst +++ b/docs/plugins/virtual_machine_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.virtual_machine module -- Create, update or delete virtua .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/vlan_group_module.rst b/docs/plugins/vlan_group_module.rst index d9e5fc5c..0821a7cc 100644 --- a/docs/plugins/vlan_group_module.rst +++ b/docs/plugins/vlan_group_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.vlan_group module -- Create, update or delete vlans group .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/vlan_module.rst b/docs/plugins/vlan_module.rst index 7a8fa804..d3871313 100644 --- a/docs/plugins/vlan_module.rst +++ b/docs/plugins/vlan_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.vlan module -- Create, update or delete vlans within Naut .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/vm_interface_module.rst b/docs/plugins/vm_interface_module.rst index 8f342407..0750a073 100644 --- a/docs/plugins/vm_interface_module.rst +++ b/docs/plugins/vm_interface_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.vm_interface module -- Creates or removes interfaces from .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/docs/plugins/vrf_module.rst b/docs/plugins/vrf_module.rst index d3fb3d34..e084d64c 100644 --- a/docs/plugins/vrf_module.rst +++ b/docs/plugins/vrf_module.rst @@ -42,7 +42,7 @@ networktocode.nautobot.vrf module -- Create, update or delete vrfs within Nautob .. Collection note .. note:: - This module is part of the `networktocode.nautobot collection `_ (version 4.3.1). + This module is part of the `networktocode.nautobot collection `_ (version 4.5.0). To install it, use: :code:`ansible-galaxy collection install networktocode.nautobot`. You need further requirements to be able to use this module, diff --git a/galaxy.yml b/galaxy.yml index 68bdf9a4..82a4d5b9 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -9,7 +9,7 @@ namespace: networktocode name: nautobot # The version of the collection. Must be compatible with semantic versioning -version: 4.4.0 +version: 4.5.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md diff --git a/plugins/inventory/gql_inventory.py b/plugins/inventory/gql_inventory.py index 26963b18..3fa289e5 100644 --- a/plugins/inventory/gql_inventory.py +++ b/plugins/inventory/gql_inventory.py @@ -195,10 +195,11 @@ from sys import version as python_version from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable from ansible.module_utils.ansible_release import __version__ as ansible_version -from ansible.errors import AnsibleError +from ansible.errors import AnsibleError, AnsibleParserError from ansible.module_utils.urls import open_url from ansible.module_utils.six.moves.urllib import error as urllib_error +from ansible.module_utils.common.text.converters import to_native from ansible_collections.networktocode.nautobot.plugins.filter.graphql import convert_to_graphql_string @@ -276,6 +277,13 @@ def create_groups(self, device): self.display.display(f"Could not find value for {parent_attr} on device {device_name}") continue + if parent_attr == "tags": + if not chain or len(chain) > 1: + self.display.display(f"Tags must be grouped by name or slug. {group_by_path} is not a valid path.") + continue + self.create_tag_groups(device, chain[0]) + continue + if not chain: group_name = device_attr @@ -312,6 +320,17 @@ def create_groups(self, device): f"Groups must be a string. {group_name} is not a string. Please make sure your group_by path specified resolves to a string value." ) + def create_tag_groups(self, device, tag_attr): + """Create groups based on tags.""" + device_name = device["name"] + for tag in device.get("tags", []): + if tag.get(tag_attr): + group_name = f"tags_{tag[tag_attr]}" + group = self.inventory.add_group(group_name) + self.inventory.add_child(group, device_name) + else: + self.display.display(f"Could not find value for tags.{tag_attr} on device {device_name}") + def main(self): """Main function.""" if not HAS_NETUTILS: @@ -349,40 +368,14 @@ def main(self): validate_certs=self.validate_certs, follow_redirects=self.follow_redirects, ) - except urllib_error.HTTPError as e: - """This will return the response body when we encounter an error. - This is to help determine what might be the issue when encountering an error. - Please check issue #294 for more info. - """ - # Prevent inventory from failing completely if the token does not have the proper permissions for specific URLs - if e.code == 403: - self.display.display( - "Permission denied: {0}. This may impair functionality of the inventory plugin.".format(self.api_endpoint + "/"), - color="red", - ) - # Need to return mock response data that is empty to prevent any failures downstream - return {"results": [], "next": None} - else: - self.display.display(f"{e.code}", color="red") - self.display.display( - "Something went wrong while executing the query.\nReason: {reason}".format( - reason=json.loads(e.fp.read().decode())["errors"][0]["message"], - ), - color="red", - ) - # Need to return mock response data that is empty to prevent any failures downstream - return {"results": [], "next": None} + except urllib_error.HTTPError as err: + raise AnsibleParserError(to_native(err.fp.read())) json_data = json.loads(response.read()) self.display.vvvv(f"JSON response: {json_data}") # Error handling in case of a malformed query if "errors" in json_data: - self.display.display( - "Query returned an error.\nReason: {0}".format(json_data["errors"][0]["message"]), - color="red", - ) - # Need to return mock response data that is empty to prevent any failures downstream - return {"results": [], "next": None} + raise AnsibleParserError(to_native(json_data["errors"][0]["message"])) for device in json_data["data"].get("devices", []) + json_data["data"].get("virtual_machines", []): self.inventory.add_host(device["name"]) diff --git a/plugins/inventory/inventory.py b/plugins/inventory/inventory.py index d0d2df9b..dc921b10 100644 --- a/plugins/inventory/inventory.py +++ b/plugins/inventory/inventory.py @@ -260,7 +260,7 @@ from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable from ansible.module_utils.ansible_release import __version__ as ansible_version -from ansible.errors import AnsibleError +from ansible.errors import AnsibleError, AnsibleParserError from ansible.module_utils._text import to_text, to_native from ansible.module_utils.urls import open_url from ansible.module_utils.six.moves.urllib import error as urllib_error @@ -303,21 +303,8 @@ def _fetch_information(self, url): validate_certs=self.validate_certs, follow_redirects=self.follow_redirects, ) - except urllib_error.HTTPError as e: - """This will return the response body when we encounter an error. - This is to help determine what might be the issue when encountering an error. - Please check issue #294 for more info. - """ - # Prevent inventory from failing completely if the token does not have the proper permissions for specific URLs - if e.code == 403: - self.display.display( - "Permission denied: {0}. This may impair functionality of the inventory plugin.".format(url), - color="red", - ) - # Need to return mock response data that is empty to prevent any failures downstream - return {"results": [], "next": None} - - raise AnsibleError(to_native(e.fp.read())) + except urllib_error.HTTPError as err: + raise AnsibleParserError(to_native(err.fp.read())) try: raw_data = to_text(response.read(), errors="surrogate_or_strict") diff --git a/plugins/modules/device_interface.py b/plugins/modules/device_interface.py index 34d64f65..53a5d883 100644 --- a/plugins/modules/device_interface.py +++ b/plugins/modules/device_interface.py @@ -30,6 +30,13 @@ required: true type: raw version_added: "3.0.0" + status: + description: + - The status of the interface + - Required if I(state=present) and using I(api_version) 1.4+ + required: false + type: raw + version_added: "4.5.0" name: description: - Name of the interface to be created @@ -63,6 +70,18 @@ required: false type: raw version_added: "3.0.0" + parent_interface: + description: + - Interface that will be the parent of the interface being created + required: false + type: raw + version_added: "4.5.0" + bridge: + description: + - Interface that will be the bridge of the interface being created + required: false + type: raw + version_added: "4.5.0" mtu: description: - The MTU of the interface @@ -199,6 +218,23 @@ enabled: false custom_fields: monitored: True + - name: Create child interface + networktocode.nautobot.device_interface: + url: http://nautobot.local + token: thisIsMyToken + device: test100 + name: GigabitEthernet1/1/1 + type: Virtual + parent_interface: + name: GigabitEthernet1/1 + - name: Create bridge interface + networktocode.nautobot.device_interface: + url: http://nautobot.local + token: thisIsMyToken + device: test100 + name: Bridge1 + bridge: + name: GigabitEthernet1/1 """ RETURN = r""" @@ -230,11 +266,14 @@ def main(): dict( update_vc_child=dict(type="bool", required=False, default=False), device=dict(required=True, type="raw"), + status=dict(required=False, type="raw"), name=dict(required=True, type="str"), label=dict(required=False, type="str"), type=dict(required=False, type="str"), enabled=dict(required=False, type="bool"), lag=dict(required=False, type="raw"), + parent_interface=dict(required=False, type="raw"), + bridge=dict(required=False, type="raw"), mtu=dict(required=False, type="int"), mac_address=dict(required=False, type="str"), mgmt_only=dict(required=False, type="bool"), diff --git a/plugins/modules/relationship_association.py b/plugins/modules/relationship_association.py index bffcd4a3..395d4fba 100644 --- a/plugins/modules/relationship_association.py +++ b/plugins/modules/relationship_association.py @@ -24,7 +24,7 @@ description: - The Relationship UUID to add the association to required: true - type: str + type: raw source_type: description: - The app_label.model for the source of the relationship @@ -102,7 +102,7 @@ def main(): argument_spec = deepcopy(NAUTOBOT_ARG_SPEC) argument_spec.update( dict( - relationship=dict(required=True, type="str"), + relationship=dict(required=True, type="raw"), source_type=dict(required=True, type="str"), source_id=dict(required=True, type="str"), destination_type=dict(required=True, type="str"), diff --git a/pyproject.toml b/pyproject.toml index fd126ca6..cc28a1b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nautobot_ansible_modules" -version = "4.4.0" +version = "4.5.0" description = "Ansible collection to interact with Nautobot's API" authors = ["Network to Code =')" diff --git a/tests/unit/inventory/test_data/graphql_groups/device_data.json b/tests/unit/inventory/test_data/graphql_groups/device_data.json index bd347709..e71f3b0c 100644 --- a/tests/unit/inventory/test_data/graphql_groups/device_data.json +++ b/tests/unit/inventory/test_data/graphql_groups/device_data.json @@ -21,5 +21,15 @@ "tenant": { "slug": "mytenant", "type": "local" - } + }, + "tags": [ + { + "name": "MyTag", + "slug": "mytag" + }, + { + "name": "MyTag2", + "slug": "mytag2" + } + ] } \ No newline at end of file diff --git a/tests/unit/inventory/test_graphql.py b/tests/unit/inventory/test_graphql.py index 433b2915..e7c0efb8 100644 --- a/tests/unit/inventory/test_graphql.py +++ b/tests/unit/inventory/test_graphql.py @@ -150,3 +150,46 @@ def test_ansible_platform(inventory_fixture, device_data): inventory_fixture.add_ansible_platform(device_data) mydevice_host = inventory_fixture.inventory.get_host("mydevice") assert mydevice_host.vars.get("ansible_network_os") == "cisco.asa.asa" + + +def test_ansible_group_by_tags_slug(inventory_fixture, device_data): + inventory_fixture.group_by = ["tags.slug"] + inventory_fixture.create_groups(device_data) + inventory_groups = list(inventory_fixture.inventory.groups.keys()) + mytag_inventory_hosts = inventory_fixture.inventory.get_groups_dict().get("tags_mytag") + mytag2_inventory_hosts = inventory_fixture.inventory.get_groups_dict().get("tags_mytag2") + assert ["all", "ungrouped", "tags_mytag", "tags_mytag2"] == inventory_groups + assert ["mydevice"] == mytag_inventory_hosts + assert ["mydevice"] == mytag2_inventory_hosts + + +def test_ansible_group_by_tags_name(inventory_fixture, device_data): + inventory_fixture.group_by = ["tags.name"] + inventory_fixture.create_groups(device_data) + inventory_groups = list(inventory_fixture.inventory.groups.keys()) + mytag_inventory_hosts = inventory_fixture.inventory.get_groups_dict().get("tags_MyTag") + mytag2_inventory_hosts = inventory_fixture.inventory.get_groups_dict().get("tags_MyTag2") + assert ["all", "ungrouped", "tags_MyTag", "tags_MyTag2"] == inventory_groups + assert ["mydevice"] == mytag_inventory_hosts + assert ["mydevice"] == mytag2_inventory_hosts + + +@patch.object(Display, "display") +def test_ansible_group_by_tags_invalid(mock_display, inventory_fixture, device_data): + inventory_fixture.group_by = ["tags"] + inventory_fixture.create_groups(device_data) + mock_display.assert_any_call("Tags must be grouped by name or slug. tags is not a valid path.") + + +@patch.object(Display, "display") +def test_ansible_group_by_tags_invalid_path(mock_display, inventory_fixture, device_data): + inventory_fixture.group_by = ["tags.foo"] + inventory_fixture.create_groups(device_data) + mock_display.assert_any_call("Could not find value for tags.foo on device mydevice") + + +@patch.object(Display, "display") +def test_ansible_group_by_tags_invalid_nested_path(mock_display, inventory_fixture, device_data): + inventory_fixture.group_by = ["tags.slug.name"] + inventory_fixture.create_groups(device_data) + mock_display.assert_any_call("Tags must be grouped by name or slug. tags.slug.name is not a valid path.")