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

Adding action fails on Zabbix 6.4: "/1/operations/1/opcommand": the parameter "scriptid" is missing #1140

Open
richlv opened this issue Nov 28, 2023 · 3 comments
Labels
bug Something isn't working module The issue or pull request is related to Zabbix module
Projects

Comments

@richlv
Copy link
Contributor

richlv commented Nov 28, 2023

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\": \"...\"}"}
@pyrodie18 pyrodie18 added bug Something isn't working module The issue or pull request is related to Zabbix module labels Nov 30, 2023
@BGmot
Copy link
Collaborator

BGmot commented Dec 28, 2023

@richlv
Copy link
Contributor Author

richlv commented Dec 29, 2023

Sorry about the confusion, I meant the fact that the only script example currently is "# Trigger action with multiple conditions and operations", and it would only work for Zabbix < 5.4.0. It might be useful to mention this, and have another example for >= 5.4.0 with "script_name".

Looking at the parameter table, it is possible that "script_name" would need a note that it's supported for >= 5.4.0, and "command" for > 5.4.0.
I guess the same thing for "custom_script" and maybe for "global_script"... if their usage is also version-restriced like that.

@pyrodie18 pyrodie18 added this to To do in Zabbix 3.0 via automation Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module The issue or pull request is related to Zabbix module
Projects
Development

No branches or pull requests

3 participants