Ansible-rulebook conditionals

I’m trying to clean up a rulebook I put together and am unable to get conditionals to work the way they say they should in the documentation.

I’m using AAP 2.5, and the DE image is the stock ansible-automation-platform-25/de-supported-rhel9:latest
This image contains ansible-rulebook 1.1.3

This works:

    - name: "Run job template for webhook"
      condition: event.payload.changes is select("regex", ".") and event.payload.eventKey != "pr:merged" and event.payload.actor.name != "xxxxxxxxxxxxx"
      action:
        run_job_template:
          name: "my_job_template"
             < . . . >

The below conditional split up into an array does NOT work, though the documentation suggests that it should:

    - name: "Run job template for webhook"
      condition:
        all:
          - event.payload.changes is select("regex", ".")
          - event.payload.eventKey != "pr:merged"
          - event.payload.actor.name != "xxxxxxxxxxxxx"
      action:
        run_job_template:
          name: "my_job_template"
             < . . . >

In the case of the non-working code, the template never gets run, ie, I see nothing in the jobs output in AAP and can find no other logs to indicate an issue.
If I send a test message to the service from bitbucket, I get a 200 back, so I know the service and route in openshift are okay. Am I just missing something simple? If I revert the rulebook code back to the working one, everything suddenly is good again.

Per the documentation these are not interchangeable, so the difference you’re seeing is probably expected.

Note that in this case the engine will consider all the different events until the conditions are met, regardless of whether those events come from one or multiple sources. Multiple conditions with all are not equivalent to a single condition with the and operator.

If you want to match only one event using multiple attributes the rule must use a single condition with the and operator:

1 Like

Hmmm. I guess I figured there’s just one event in my situation… webhook firing from a ref being updated in a repo which should match all the conditions.

But thinking about it now I can see the distinction, since the rulebook is running full time and others will be using this webhook as well, generating events of their own.

I’ll switch it back. Thank you for the quick reply!