community.zabbix
community.zabbix copied to clipboard
Adding action fails on Zabbix 6.4: "/1/operations/1/opcommand": the parameter "scriptid" is missing
SUMMARY
Adding action fails on Zabbix 6.4: "/1/operations/1/opcommand": the parameter "scriptid" is missing
ISSUE TYPE
- Bug Report
COMPONENT NAME
zabbix_action
ANSIBLE VERSION
ansible [core 2.15.6]
config file = /opt/ansible/config/ansible-config-server.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/venv-ansible2023/lib64/python3.9/site-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/venv-ansible2023/bin/ansible
python version = 3.9.16 (main, Sep 22 2023, 17:57:55) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] (/opt/venv-ansible2023/bin/python3.9)
jinja version = 3.1.2
libyaml = True
CONFIGURATION
CONFIG_FILE() = /opt/ansible/config/ansible-config-server.cfg
DEFAULT_FORKS(/opt/ansible/config/ansible-config-server.cfg) = 100
OS / ENVIRONMENT / Zabbix Version
Zabbix 6.4.8. community.zabbix collection git clone from today.
STEPS TO REPRODUCE
Action task, based on examples in https://docs.ansible.com/ansible/latest/collections/community/zabbix/zabbix_action_module.html .
- name: Add Zabbix discovery actions
community.zabbix.zabbix_action:
name: Test action
event_source: 'discovery'
esc_period: '900'
conditions:
- type: 'discovery_object'
operator: '='
value: 'host'
operations:
- type: 'remote_command'
command_type: 'custom_script'
execute_on: 'server'
command: echo
run_on_hosts:
- 0
become: false
vars:
ansible_connection: httpapi
ansible_user: zbx_api_cli
tags: zabbixdiscoaction
What works:
- name: Add Zabbix discovery actions
community.zabbix.zabbix_action:
name: Test action
event_source: 'discovery'
esc_period: '900'
conditions:
- type: 'discovery_object'
operator: '='
value: 'host'
operations:
- type: 'remote_command'
command_type: 'global_script'
execute_on: 'server'
script_name: Add hosts to the segment group
run_on_hosts:
- 0
become: false
vars:
ansible_connection: httpapi
ansible_user: zbx_api_cli
tags: zabbixdiscoaction
Zabbix 5.2 seems to be the last version to have "remote command" operation type, Zabbix 5.4 only has "global script".
Based on this, perhaps "custom_script" should be supported =< 5.2, "global_script" >= 5.4 ? If that is correct, then the examples in the documentation would also need expanding, similar how in other modules there are different examples for different Zabbix versions.
EXPECTED RESULTS
Action created or a meaningful error message.
ACTUAL RESULTS
Fails with:
FAILED! => {"changed": false, "msg": "connection error occurred: REST API returned {'code': -32602, 'message': 'Invalid params.', 'data': 'Invalid parameter \"/1/operations/1/opcommand\": the parameter \"scriptid\" is missing.'} when sending {\"jsonrpc\": \"2.0\", \"method\": \"action.create\", \"id\": \"c871e772-0ef6-4fe3-a9a7-c1385ac9387e\", \"params\": {\"name\": \"Test action\", \"eventsource\": 1, \"filter\": {\"conditions\": [{\"conditiontype\": 21, \"value\": 1, \"operator\": 0}], \"evaltype\": \"0\"}, \"operations\": [{\"operationtype\": 1, \"opcommand\": {}, \"opcommand_hst\": [{\"hostid\": \"0\"}]}], \"status\": 0}, \"auth\": \"...\"}"}