ansible-collections / community.zabbix

Zabbix Ansible modules
http://galaxy.ansible.com/community/zabbix
Other
315 stars 265 forks source link

Add Support to Item Modules for setting Master Items by Name #1234

Closed aplathrop closed 1 month ago

aplathrop commented 1 month ago
SUMMARY

This change adds support to the zabbix_item and zabbix_itemprototype modules for setting the master item by name rather by ID

ISSUE TYPE
COMPONENT NAME

zabbix_item zabbix_itemprototype

ADDITIONAL INFORMATION

Currently, if you want to create a dependent item using either the zabbix_item and zabbix_itemprototype module you can do so using the master item's ID, but you can't do it by name:

community.zabbix.zabbix_item:
    name: ExampleItem
    host_name: ExampleHost
    params:
        type: dependent_item
        key: ExampleKey
        value_type: numeric_unsigned
        master_itemid: 12345

This PR adds a new parameter, master_item that you can use to set the master item by name rather than by ID:

community.zabbix.zabbix_item:
    name: ExampleItem
    host_name: ExampleHost
    params:
        type: dependent_item
        key: ExampleKey
        value_type: numeric_unsigned
        master_item:
          item_name: ExampleMasterItem
          host_name: ExampleHost

Note that this PR preserves the previous functionality, if anyone was setting the master item by ID, that will continue to work

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 75.62%. Comparing base (0a689a5) to head (c2f314f). Report is 39 commits behind head on main.

:exclamation: Current head c2f314f differs from pull request most recent head 5450709

Please upload reports for the commit 5450709 to get more accurate results.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1234 +/- ## ========================================== - Coverage 79.57% 75.62% -3.95% ========================================== Files 35 35 Lines 4435 4398 -37 Branches 1166 1154 -12 ========================================== - Hits 3529 3326 -203 - Misses 535 691 +156 - Partials 371 381 +10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

aplathrop commented 1 month ago

I've added the change fragment, fixed the unit tests, added examples

For the argument specs, the new argument I added is a suboption of the params argument. The other sub options for the params argument are not in the argument specs either, so it seems odd to add it for just this particular argument. Note I did add the master_item argument to the documentation

If you still want me to add it to the argument spec, let me know and I will, I just wanted to point out that it seems inconsistent with how the rest of the module currently is.

pyrodie18 commented 1 month ago

Fair point. Thanks for the addition.