Skip to content

Support of object types for netbox_tag module #1415

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

Merged
merged 4 commits into from
May 20, 2025
Merged
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: 2 additions & 0 deletions changelogs/fragments/netbox_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- netbox_tag - Add support for object_types on tags
16 changes: 16 additions & 0 deletions plugins/modules/netbox_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
- Tag description
required: false
type: str
object_types:
description:
- Objects types using the tag
required: false
type: list
elements: raw
required: true
"""

Expand Down Expand Up @@ -80,6 +86,15 @@
loop:
- mgmt
- tun

- name: Restrict object types
netbox.netbox.netbox_tag:
netbox_url: http://netbox.local
netbox_token: thisIsMyToken
data:
name: "MyTag"
object_types:
- dcim.prefix
"""

RETURN = r"""
Expand Down Expand Up @@ -119,6 +134,7 @@ def main():
color=dict(required=False, type="str"),
description=dict(required=False, type="str"),
slug=dict(required=False, type="str"),
object_types=dict(required=False, type="list", elements="raw"),
),
),
)
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/targets/v4.2/tasks/netbox_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
name: Test Tag 1
description: Tag 1 test
color: "0000ff"
object_types:
- ipem.prefix
state: present
register: test_one

Expand All @@ -25,6 +27,7 @@
- test_one['tags']['description'] == "Tag 1 test"
- test_one['tags']['name'] == "Test Tag 1"
- test_one['tags']['slug'] == "test-tag-1"
- test_one['tags']['object_types'][0] = "ipam.prefix"
- test_one['msg'] == "tags Test Tag 1 created"

- name: "TAG 2: Create duplicate"
Expand Down Expand Up @@ -53,6 +56,8 @@
name: Test Tag 1
description: Tag 1 update test
color: "00ff00"
object_types:
- ipam.asn
state: present
register: test_three

Expand All @@ -65,6 +70,7 @@
- test_three['tags']['name'] == "Test Tag 1"
- test_three['tags']['description'] == "Tag 1 update test"
- test_three['tags']['color'] == "00ff00"
-test_three['tags']['object_types'][0] == "ipam.asn"
- test_three['msg'] == "tags Test Tag 1 updated"

- name: "TAG 4: ASSERT - Delete"
Expand Down
Loading