Skip to content

Commit

Permalink
Merge pull request #493 from nautobot/develop
Browse files Browse the repository at this point in the history
Develop to main for release v5.7.0
  • Loading branch information
joewesch authored Jan 28, 2025
2 parents bd0648c + 312454e commit cfcb62e
Show file tree
Hide file tree
Showing 34 changed files with 7,501 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
- name: "Install invoke"
run: "pip install -U pip && pip install invoke"
- name: "Install poetry"
run: "curl -sSL https://install.python-poetry.org | python3 -"
# Pinning poetry to v1 for now to avoid breaking changes
run: "curl -sSL https://install.python-poetry.org | python3 - --version 1.8.5"
- name: "Install ansible-core"
# This ensures that even if the poetry.lock file updates we still test the right version
run: "poetry add ansible-core@~${{ inputs.ansible-version }}"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
python-version:
- "3.12"
nautobot-version:
- "2.3"
- "2.4"
ansible-version:
- "2.17"
- "2.18"
Expand All @@ -77,6 +77,7 @@ jobs:
- "2.1"
- "2.2"
- "2.3"
- "2.4"
ansible-version:
- "2.16"
- "2.17"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/trigger_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
- "2.1"
- "2.2"
- "2.3"
- "2.4"
ansible-version:
- "2.16"
- "2.17"
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# networktocode.nautobot Release Notes

v5.7.0
======

New Modules
-----------

- networktocode.nautobot.controller_managed_device_groups - Creates or removes controller managed device groups within Nautobot
- networktocode.nautobot.software_version - Creates or removes software versions from Nautobot

Minor Changes
-------------
- (#488) Fixed `module_bay_template` idempotency when duplicate bay names exist for multiple device or module types

v5.6.0
======

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WORKDIR /usr/src/app
RUN python -m pip install -U pip

# Install poetry for dep management
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.8.5
ENV PATH="$PATH:/root/.local/bin"
RUN poetry config virtualenvs.create false

Expand Down
11 changes: 11 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,14 @@ releases:
- (#478) Fixed the `cable` module to properly work with all cable types
- (#480) Fixed environment variable fallback for `url` and `token` in all modules
- (#481) Fixed environment variable fallback for `validate_certs` in all modules
5.7.0:
modules:
- description: Creates or removes controller managed device groups from Nautobot
name: controller_managed_device_group
namespace: ''
- description: Creates or removes software versions from Nautobot
name: software_version
namespace: ''
changes:
minor_changes:
- (#488) Fixed `module_bay_template` idempotency when duplicate bay names exist for multiple device or module types
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace: networktocode
name: nautobot

# The version of the collection. Must be compatible with semantic versioning
version: 5.6.0
version: 5.7.0

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
2 changes: 2 additions & 0 deletions plugins/lookup/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def get_endpoint(nautobot, term):
"circuits": {"endpoint": nautobot.circuits.circuits},
"circuit-providers": {"endpoint": nautobot.circuits.providers},
"cables": {"endpoint": nautobot.dcim.cables},
"controllers": {"endpoint": nautobot.dcim.controllers},
"controller-managed-device-groups": {"endpoint": nautobot.dcim.controller_managed_device_groups},
"cloud-accounts": {"endpoint": nautobot.cloud.cloud_accounts},
"cloud-networks": {"endpoint": nautobot.cloud.cloud_networks},
"cloud-network-prefix-assignments": {"endpoint": nautobot.cloud.cloud_network_prefix_assignments},
Expand Down
5 changes: 5 additions & 0 deletions plugins/module_utils/dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
NB_CONSOLE_SERVER_PORTS = "console_server_ports"
NB_CONSOLE_SERVER_PORT_TEMPLATES = "console_server_port_templates"
NB_CONTROLLERS = "controllers"
NB_CONTROLLER_MANAGED_DEVICE_GROUPS = "controller_managed_device_groups"
NB_DEVICE_BAYS = "device_bays"
NB_DEVICE_BAY_TEMPLATES = "device_bay_templates"
NB_DEVICE_REDUNDANCY_GROUPS = "device_redundancy_groups"
Expand Down Expand Up @@ -48,6 +49,7 @@
NB_RACK_GROUPS = "rack_groups"
NB_REAR_PORTS = "rear_ports"
NB_REAR_PORT_TEMPLATES = "rear_port_templates"
NB_SOFTWARE_VERSIONS = "software_versions"
NB_VIRTUAL_CHASSIS = "virtual_chassis"


Expand All @@ -63,6 +65,7 @@ def run(self):
- console_server_ports
- console_server_port_templates
- controllers
- controller_managed_device_groups
- device_bays
- device_bay_templates
- devices
Expand Down Expand Up @@ -115,6 +118,8 @@ def run(self):
name = self.module.params["data"]["master"]
elif data.get("id"):
name = data["id"]
elif endpoint_name == "software_version":
name = data["version"]
elif endpoint_name == "cable":
if self.module.params["termination_a"].get("name"):
termination_a_name = self.module.params["termination_a"]["name"]
Expand Down
11 changes: 10 additions & 1 deletion plugins/module_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"console_server_ports",
"console_server_port_templates",
"controllers",
"controller_managed_device_groups",
"device_bays",
"device_bay_templates",
"devices",
Expand Down Expand Up @@ -76,6 +77,7 @@
"rack_groups",
"rear_ports",
"rear_port_templates",
"software_versions",
"virtual_chassis",
],
extras=[
Expand Down Expand Up @@ -129,6 +131,7 @@
cluster_group="name",
cluster_type="name",
controller="name",
controller_managed_device_group="name",
device="name",
dynamic_group="name",
role="name",
Expand Down Expand Up @@ -165,6 +168,7 @@
rear_port_template="name",
rir="name",
route_targets="name",
software_version="version",
status="name",
tenant="name",
tenant_group="name",
Expand Down Expand Up @@ -196,6 +200,7 @@
"cluster_group": "cluster_groups",
"cluster_type": "cluster_types",
"contacts": "contacts",
"controller": "controllers",
"dcim.consoleport": "console_ports",
"dcim.consoleserverport": "console_server_ports",
"dcim.frontport": "front_ports",
Expand Down Expand Up @@ -291,6 +296,7 @@
"console_server_port_templates": "console_server_port_template",
"contacts": "contact",
"controllers": "controller",
"controller_managed_device_groups": "controller_managed_device_group",
"custom_fields": "custom_field",
"custom_field_choices": "custom_field_choice",
"device_bays": "device_bay",
Expand Down Expand Up @@ -339,6 +345,7 @@
"route_targets": "route_target",
"services": "services",
"static_group_associations": "static_group_association",
"software_versions": "software_version",
"statuses": "statuses",
"tags": "tags",
"teams": "team",
Expand Down Expand Up @@ -375,6 +382,7 @@
"contact": set(["name", "phone", "email"]),
"contacts": set(["name", "phone", "email"]),
"controller": set(["name"]),
"controller_managed_device_group": set(["name"]),
"custom_field": set(["label"]),
"custom_field_choice": set(["value", "custom_field"]),
"dcim.consoleport": set(["name", "device"]),
Expand Down Expand Up @@ -411,7 +419,7 @@
"master": set(["name"]),
"metadata_choice": set(["value", "metadata_type"]),
"metadata_type": set(["name"]),
"module_bay_template": set(["name"]),
"module_bay_template": set(["name", "device_type", "module_type"]),
"module_bay": set(["name", "parent_device", "parent_module"]),
"module_type": set(["model"]),
"module": set(["module_type", "parent_module_bay", "location"]),
Expand Down Expand Up @@ -444,6 +452,7 @@
"role": set(["name"]),
"route_target": set(["name"]),
"services": set(["device", "virtual_machine", "name", "port", "protocol"]),
"software_version": set(["version", "platform"]),
"static_group_association": set(["dynamic_group", "associated_object_type", "associated_object_id"]),
"statuses": set(["name"]),
"tags": set(["name"]),
Expand Down
123 changes: 123 additions & 0 deletions plugins/modules/controller_managed_device_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2024, Network to Code (@networktocode) <[email protected]>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type

DOCUMENTATION = r"""
---
module: controller_managed_device_group
short_description: Create, update or delete managed device groups within Nautobot
description:
- Creates, updates or removes managed device groups from Nautobot.
notes:
- Tags should be defined as a YAML list
- This should be ran with connection C(local) and hosts C(localhost)
author:
- Sven Winkelmann (@pugnacity)
version_added: "5.7.0"
extends_documentation_fragment:
- networktocode.nautobot.fragments.base
- networktocode.nautobot.fragments.tags
- networktocode.nautobot.fragments.custom_fields
options:
name:
description:
- The name of the controller managed device groups
required: true
type: str
controller:
description:
- The name of the controller for this group
required: true
type: str
weight:
description:
- weight of the managed device group
required: false
type: int
parent_cloud_network:
aliases:
- parent
description:
- The parent cloud network this network should be child to
required: false
type: raw
"""

EXAMPLES = r"""
- name: "Test Nautobot modules"
connection: local
hosts: localhost
gather_facts: False
tasks:
- name: Create controller managed device group within Nautobot with only required information
networktocode.nautobot.controller_managed_device_group:
url: http://nautobot.local
token: thisIsMyToken
name: "group_1"
controller: my_controller
state: present
- name: Delete controller managed device group within nautobot
networktocode.nautobot.controller_managed_device_group:
url: http://nautobot.local
token: thisIsMyToken
name: "group_1"
controller: test_controller_group_3
state: absent
"""

RETURN = r"""
controller_managed_device_group:
description: Serialized object as created or already existent within Nautobot
returned: success (when I(state=present))
type: dict
msg:
description: Message indicating failure or info about what has been achieved
returned: always
type: str
"""

from ansible_collections.networktocode.nautobot.plugins.module_utils.utils import (
NAUTOBOT_ARG_SPEC,
TAGS_ARG_SPEC,
CUSTOM_FIELDS_ARG_SPEC,
)
from ansible_collections.networktocode.nautobot.plugins.module_utils.dcim import (
NautobotDcimModule,
NB_CONTROLLER_MANAGED_DEVICE_GROUPS,
)
from ansible.module_utils.basic import AnsibleModule
from copy import deepcopy


def main():
"""
Main entry point for module execution
"""
argument_spec = deepcopy(NAUTOBOT_ARG_SPEC)
argument_spec.update(deepcopy(TAGS_ARG_SPEC))
argument_spec.update(deepcopy(CUSTOM_FIELDS_ARG_SPEC))
argument_spec.update(
dict(
name=dict(required=True, type="str"),
controller=dict(required=True, type="str"),
weight=dict(required=False, type="int"),
parent_cloud_network=dict(required=False, type="raw", aliases=["parent"]),
)
)

module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)

controller_group = NautobotDcimModule(module, NB_CONTROLLER_MANAGED_DEVICE_GROUPS)
controller_group.run()


if __name__ == "__main__": # pragma: no cover
main()
8 changes: 8 additions & 0 deletions plugins/modules/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@
required: false
type: raw
version_added: "5.1.0"
controller_managed_device_group:
description:
- Device controller_managed_device_group the device will be assigned to
- Requires Nautobot C(v2.2) or later
required: false
type: raw
version_added: "5.7.0"
device_redundancy_group_priority:
description:
- Priority in the assigned device redundancy group
Expand Down Expand Up @@ -290,6 +297,7 @@ def main():
vc_priority=dict(required=False, type="int"),
comments=dict(required=False, type="str"),
local_config_context_data=dict(required=False, type="dict"),
controller_managed_device_group=dict(required=False, type="raw"),
device_redundancy_group=dict(required=False, type="raw"),
device_redundancy_group_priority=dict(required=False, type="int"),
)
Expand Down
Loading

0 comments on commit cfcb62e

Please sign in to comment.