Ad Widget

Collapse

Question regarding template yaml syntax and macros

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • schoeppi
    Member
    • Jan 2024
    • 31

    #1

    Question regarding template yaml syntax and macros

    I try to create a template for web scenarios and I want to enable or disable scenarios using a user macro. Unfortunatly this does not work.

    If I create the template via the webinterface, disable a scenario and export this template, I can see that is done like this:

    -----
    ...
    httptests:
    - uuid: 2d7322201d98448d8849e4a61d0c006f
    name: 'Website Health Check 1: {$WEB_FQDN}'
    verify_peer: 'YES'
    verify_host: 'YES'
    status: DISABLED
    steps:
    ...
    -----

    This way I can import and export the template.

    Now I've created a macro called {$STEP1.STATUS} and set its value to DISABLED:

    -----
    ...
    macros:
    - macro: '{$WEB_FQDN}' value: '<Put WEB_FQDN here'
    description: 'The FQDN part of the URL to monitor.'
    - macro: '{$STEP1.STATUS}'
    description: 'DISABLED or ENABLED'
    value: 'DISABLED'
    ...
    -----

    Now I try to use this macro in the step definition:

    -----
    ...
    httptests:
    - uuid: 2d7322201d98448d8849e4a61d0c006f
    name: 'Website Health Check 1: {$WEB_FQDN}'
    verify_peer: 'YES'
    verify_host: 'YES'
    status: '{$STEP1.STATUS}'
    steps:
    ...
    -----

    But no matter what I try, with or without quotes and so on, it does not work and I can not import the template.

    Is this working at all or is setting the enabled or disabled status of a web scenario via a yaml based template not possible? Or is it a syntax issue?

    I get the following error if I try to import the template:

    "Invalid tag "/zabbix_export/templates/template(1)/httptests/httptest(1)/status": unexpected constant "{$STEP1.STATUS}"."

    Because we configure Zabbix with ansible setting the status of several elements would be interesting using hostbased macros. It would be nice to do this also for e.g. hosts.

    Do you have an idea how this can be done?

  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2

    I don't see "status" being a place, where you can use a macro... I don't think you can replace a "checkbox" with a macro...

    Comment

    Working...