ansible-collections / community.zabbix

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

Module zabbix_usergroup not idempotent when including rights - permissions for host groups #809

Open vicmunoz opened 1 year ago

vicmunoz commented 1 year ago
SUMMARY

When including rights (permissions) on host groups within usergroup, running multiple times returns 'changed' state for the task.

ISSUE TYPE
COMPONENT NAME

zabbix_usergroup

ANSIBLE VERSION
ansible [core 2.12.6]
  config file = /Users/victorm/Code/Sandbox/automation/ansible.cfg
  configured module search path = ['/Users/victorm/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/victorm/Code/Sandbox/automation/.venv/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/victorm/Code/Sandbox/automation/.collections
  executable location = /Users/victorm/Code/Sandbox/automation/.venv/bin/ansible
  python version = 3.10.3 (main, Apr 22 2022, 11:39:57) [Clang 12.0.5 (clang-1205.0.22.11)]
  jinja version = 3.1.2
  libyaml = True
CONFIGURATION
ANSIBLE_FORCE_COLOR(env: ANSIBLE_FORCE_COLOR) = True
COLLECTIONS_PATHS(/Users/victorm/Code/Sandbox/automation/ansible.cfg) = ['/Users/victorm/Code/Sandbox/automation/.collections']
COLLECTIONS_SCAN_SYS_PATH(/Users/victorm/Code/Sandbox/automation/ansible.cfg) = False
DEFAULT_FILTER_PLUGIN_PATH(/Users/victorm/Code/Sandbox/automation/ansible.cfg) = ['/Users/victorm/Code/Sandbox/automation/plugins/filter_plugins']
DEFAULT_FORKS(/Users/victorm/Code/Sandbox/automation/ansible.cfg) = 24
DEFAULT_HOST_LIST(/Users/victorm/Code/Sandbox/automation/ansible.cfg) = ['/Users/victorm/Code/Sandbox/automation/inventory']
DEFAULT_VARS_PLUGIN_PATH(/Users/victorm/Code/Sandbox/automation/ansible.cfg) = ['/Users/victorm/Code/Sandbox/automation/plugins/vars_plugins']
RETRY_FILES_SAVE_PATH(/Users/victorm/Code/Sandbox/automation/ansible.cfg) = /Users/victorm/Code/Sandbox/automation/retry
OS / ENVIRONMENT / Zabbix Version

Zabbix 6.0 branch.

STEPS TO REPRODUCE

Run multiple times below task

vars:
zabbix_default_host_groups:
  - host_group: Linux servers
    permission: read-write
  - host_group: Hypervisors
    permission: read-write
  - host_group: Docker hosts
    permission: read-write
  - host_group: Database servers
    permission: read-write

tasks:
- name: Add permissions over host groups
  community.zabbix.zabbix_usergroup:
    server_url: 'https://{{ inventory_hostname }}'
    login_user: '{{ zabbix.api_user }}'
    login_password: '{{ zabbix.api_pass }}'
    validate_certs: false
    name: Zabbix administrators
    rights: '{{ zabbix_default_host_groups }}'
EXPECTED RESULTS

First time task is executed, should mark it as changed, next iterations should marked as ok and not changed.

ACTUAL RESULTS

Every time you run the task is displayed with changed result.

andreicornea commented 1 year ago

I encountered more or less the same issue when using this module against Zabbix v5.0.19. It goes like this for me: