Skip to content

Commit

Permalink
Merge branch 'main' into file_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Izquierdo authored Sep 2, 2024
2 parents c90f1d3 + 23ca54b commit 071d2ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

## [Unreleased]
### Changed
- Fixed documentation on matching events in multi condition
### Added
- Support for switching slugs to connect to controller via gateway
- Support passing in controller job id to server so it can build Job URL
Expand Down
12 changes: 7 additions & 5 deletions docs/conditions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The data type is of great importance for the rules engine. The following types a
Navigate structured data
************************

You can navigate strutured event, fact, var data objects using either dot notation or bracket notation:
You can navigate structured event, fact, var data objects using either dot notation or bracket notation:

.. code-block:: yaml
Expand Down Expand Up @@ -79,7 +79,7 @@ or other special characters:
You can find more information about dot notation and bracket notation also in the Ansible playbook documentation for `Referencing key:value dictionary variables <https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#referencing-key-value-dictionary-variables>`_.

You can access list in strutured event, fact, var data objects using bracket notation too.
You can access list in structured event, fact, var data objects using bracket notation too.
The first item in a list is item 0, the second item is item 1.
Like Python, you can access the `n`-to-last item in the list by supplying a negative index.
For example:
Expand Down Expand Up @@ -484,6 +484,8 @@ Multiple conditions with assignment

When a condition is evaluated if the condition passes the matching event
it is stored in well known attribute(s) called **m_0**, **m_1**, **m_2**.....
The first condition will be stored in **m_0** and the second condition in **m_1** ...
Its based on the position of the condition in the list so you can predictably use it in other conditions.
You can optionally alias these attribute(s) using the **<<** operator. For example:

.. code-block:: yaml
Expand Down Expand Up @@ -535,15 +537,15 @@ Multiple condition with default assignments
all:
- event.i == 1
- event.i == 2
- event.i == events.m.i + 3
- event.i == events.m_0.i + 3
action:
debug:
msg:
- "first: {{ events.m_0 }}"
- "second: {{ events.m_1 }}"
- "third: {{ events.m_2 }}"
The first match is stored as **m**, and the subsequent ones are stored as **m_1**, **m_2** ...
The first match is stored as **m_0**, and the subsequent ones are stored as **m_1**, **m_2** ...

Single condition assignment (Not supported)
-------------------------------------------
Expand Down Expand Up @@ -991,7 +993,7 @@ Example:
| **Ans:** During the rulebook parsing you would see this error message:
| ERROR - Terminating mapping values are not allowed here.
| To resove this eror you would have to quote the whole condition string or use the > or | and
| To resolve this error you would have to quote the whole condition string or use the > or | and
| move the entire condition to a separate line.
Example:
Expand Down
2 changes: 1 addition & 1 deletion docs/rulebooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ A ruleset has the following properties:
- The list of one or more rule. See :doc:`rules`
- Yes
* - hosts
- Similar to hosts in an Ansible playbook
- Similar to hosts in an Ansible playbook. This value is used for actions that require an inventory (eg: run_playbook, or run_module). It is not used for controller actions (eg: run_job_template, run_workflow_template)
- Yes
* - gather_facts
- Collect artifacts from hosts at startup to be used in rules (default: false)
Expand Down

0 comments on commit 071d2ad

Please sign in to comment.