Skip to content

Commit

Permalink
Honor limit set in run_job_template's job_args.limit field
Browse files Browse the repository at this point in the history
hosts defined in this field should overwrite rulebook's hosts field
but yield to hosts in event's meta field

Resolves AAP-9218
  • Loading branch information
bzwei committed Feb 10, 2023
1 parent bdd3a4f commit fbdb00c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ansible_rulebook/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pprint import PrettyPrinter, pformat
from typing import Any, Dict, List, Optional, cast

import dpath
from drools import ruleset as lang
from drools.dispatch import establish_async_channel, handle_async_messages
from drools.exceptions import (
Expand Down Expand Up @@ -362,6 +363,17 @@ async def _call_action(
result = None
if action in builtin_actions:
try:
if action == "run_job_template":
limit = dpath.get(
action_args,
"job_args.limit",
separator=".",
default=None,
)
if isinstance(limit, list):
hosts = limit
elif isinstance(limit, str):
hosts = [limit]
single_match = None
keys = list(rules_engine_result.data.keys())
if len(keys) == 0:
Expand Down

0 comments on commit fbdb00c

Please sign in to comment.