Skip to content
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

Add the ability to rename objects #1447

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

aplathrop
Copy link
Contributor

SUMMARY

Adds the ability to rename objects in Zabbix

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • zabbix_item
  • zabbix_trigger
  • zabbix_discoveryrule
  • zabbix_itemprototype
  • zabbix_triggerprototype
ADDITIONAL INFORMATION

Currently the only way to rename resources using the Ansible modules is to delete the resource under the old name and recreate it under the new name, despite that the Zabbix API supports renaming these types of resources.
The UID for these resources from the API's point of view is a number, not the name. As that's not very user friendly, when I wrote the modules, I use the resource name and the host/template name to lookup the ID. Unfortunately, the side effect of this is if you try to rename a resource, the module will try to create a duplicate resource with the new name
I've been using the above work around of deleting and recreating, but that has its own unfortunate side-effect that you lose the historical data
This PR adds a new_name parameter like below:

- name: Rename Zabbix item
  community.zabbix.zabbix_item:
    name: agent_ping
    template_name: example_template
    params:
      new_name: new_agent_ping
    state: present

In this example, the module lookup the itemid for a Zabbix item with the name agent_ping in the template example_template. It will then set the name field for the item with the id to new_agent_ping

Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.54%. Comparing base (a0f5d37) to head (ee85b59).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1447      +/-   ##
==========================================
+ Coverage   78.40%   78.54%   +0.14%     
==========================================
  Files          47       47              
  Lines        5848     5873      +25     
  Branches     1491     1501      +10     
==========================================
+ Hits         4585     4613      +28     
  Misses        780      780              
+ Partials      483      480       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aplathrop aplathrop marked this pull request as ready for review January 24, 2025 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant