community.zabbix icon indicating copy to clipboard operation
community.zabbix copied to clipboard

zabbix_action: condition value considered required when it should not be

Open sky-joker opened this issue 4 years ago • 3 comments

From @richlv on 10 Jan

SUMMARY

According to the Zabbix manual, the condition type "Problem is suppressed" has: "No value required".

ISSUE TYPE
  • Bug Report
COMPONENT NAME

zabbix_action

ANSIBLE VERSION

latest

STEPS TO REPRODUCE

"Problem is suppressed" matches maintenance_status in zabbix_action (value 16).

Try an action with a condition like so:

      - type: 'maintenance_status'
        operator: 'No'
EXPECTED RESULTS

Action created.

ACTUAL RESULTS

Fails with:

missing required arguments: value found in conditions

Copied from original issue: https://github.com/ansible/ansible/issues/66343

sky-joker avatar May 02 '20 15:05 sky-joker

@richlv commented:

Workaround: value: ''.

D3DeFi avatar May 04 '20 13:05 D3DeFi

Only way I see this fixed is by changing modules.argument_spec.conditions.options.value from required=True to required=False and then specifying that it is required for almost every condition type:

            conditions=dict(
                type='list',
                required=False,
                default=[],
                elements='dict',
                options=dict(
                    formulaid=dict(type='str', required=False),
                    operator=dict(type='str', required=True),
                    type=dict(type='str', required=True),
                    value=dict(type='str', required=False),
                    value2=dict(type='str', required=False)
                ),
                required_if=[
                    ['type', 'host_group', ['value']],
                    ['type', 'host', ['value']],
                    # and so on ....
                ]
            ),

required_if entry would need to be specified for every condition type, except type 16 (Maintenance status/Problem is suppressed). That means 25 times...

This module is unfortunately too complex and would probably needs some more love in the future when 3.0LTS gets deprecated as it is using old naming for a few things.

D3DeFi avatar May 09 '20 08:05 D3DeFi

#774 seems to drop support for Zabbix 3.0, does that make this issue any easier?

richlv avatar Nov 28 '23 12:11 richlv