diff --git a/ansible_rulebook/action/run_base.py b/ansible_rulebook/action/run_base.py new file mode 100644 index 00000000..42f5e244 --- /dev/null +++ b/ansible_rulebook/action/run_base.py @@ -0,0 +1,230 @@ +# Copyright 2023 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import asyncio +import logging +import uuid +from typing import Callable +from urllib.parse import urljoin + +import drools + +from ansible_rulebook.conf import settings +from ansible_rulebook.exception import ControllerApiException +from ansible_rulebook.job_template_runner import job_template_runner +from ansible_rulebook.util import run_at + +from .control import Control +from .helper import Helper +from .metadata import Metadata + +logger = logging.getLogger(__name__) + + +class RunBase: + """Common superclass for "run" actions.""" + + @property + def _job_data(self) -> dict: + data = { + "run_at": run_at(), + "matching_events": self.helper.get_events(), + "action": self.helper.action, + "name": self.name, + "job_id": self.job_id, + "ansible_rulebook_id": settings.identifier, + } + return data + + @property + def _action_name(self) -> str: + raise NotImplementedError + + def __init__(self, metadata: Metadata, control: Control, **action_args): + self.helper = Helper(metadata, control, self._action_name) + self.action_args = action_args + self.job_id = str(uuid.uuid4()) + self.name = self.action_args["name"] + + async def __call__(self): + await self._pre_process() + await self._job_start_event() + await self._run() + await self._post_process() + + async def _do_run(self): + """Performs a standalone single attempt to effect the requested + operation. In the event of success or non-retriable error raises + StopAsyncIteration exception. + """ + raise NotImplementedError + + async def _run(self): + retries = self.action_args.get("retries", 0) + if self.action_args.get("retry", False): + retries = max(self.action_args.get("retries", 0), 1) + delay = self.action_args.get("delay", 0) + + for i in range(retries + 1): + if i > 0: + if delay > 0: + await asyncio.sleep(delay) + logger.info( + "Previous %s failed. Retry %d of %d", + self._action_name, + i, + retries, + ) + + try: + await self._do_run() + except StopAsyncIteration: + break + + async def _pre_process(self) -> None: + pass + + async def _post_process(self) -> None: + pass + + async def _job_start_event(self): + await self.helper.send_status( + self._job_data, + obj_type="Job", + ) + + +class RunTemplate(RunBase): + """Superclass for template-based run actions. Launches the appropriate + specified template on the controller. It waits for the job to be complete. + """ + + @property + def _exceptions(self) -> tuple: + return (ControllerApiException,) + + @property + def _job_data(self) -> dict: + data = super()._job_data + data["hosts"] = ",".join(self.helper.control.hosts) + return data + + @property + def _run_job(self) -> Callable: + raise NotImplementedError + + @property + def _template_name(self) -> str: + raise NotImplementedError + + @property + def _url_path(self) -> str: + return self._url_prefix + f"{self.controller_job['id']}/" + "details" + + @property + def _url_prefix(self) -> str: + return "/#/" + + def _make_log(self) -> dict: + log = { + "organization": self.organization, + "job_id": self.job_id, + "status": self.controller_job["status"], + "run_at": self.controller_job["created"], + "url": self._controller_job_url(), + "matching_events": self.helper.get_events(), + } + if "error" in self.controller_job: + log["message"] = self.controller_job["error"] + log["reason"] = {"error": self.controller_job["error"]} + return log + + def __init__(self, metadata: Metadata, control: Control, **action_args): + super().__init__(metadata, control, **action_args) + self.organization = self.action_args["organization"] + self.job_args = self.action_args.get("job_args", {}) + self.job_args["limit"] = ",".join(self.helper.control.hosts) + self.controller_job = {} + + async def __call__(self): + logger.info( + "running %s: %s, organization: %s", + self._template_name, + self.name, + self.organization, + ) + logger.info( + "ruleset: %s, rule %s", + self.helper.metadata.rule_set, + self.helper.metadata.rule, + ) + + self.job_args["extra_vars"] = self.helper.collect_extra_vars( + self.job_args.get("extra_vars", {}) + ) + await super().__call__() + + async def _do_run(self): + exception = False + try: + controller_job = await self._run_job( + self.name, + self.organization, + self.job_args, + ) + except self._exceptions as ex: + exception = True + logger.error(ex) + controller_job = {} + controller_job["status"] = "failed" + controller_job["created"] = run_at() + controller_job["error"] = str(ex) + + self.controller_job = controller_job + + if exception or (self.controller_job["status"] != "failed"): + raise StopAsyncIteration + + async def _post_process(self) -> None: + a_log = self._make_log() + + await self.helper.send_status(a_log) + set_facts = self.action_args.get("set_facts", False) + post_events = self.action_args.get("post_events", False) + + if set_facts or post_events: + ruleset = self.action_args.get( + "ruleset", self.helper.metadata.rule_set + ) + logger.debug("set_facts") + facts = self.controller_job.get("artifacts", {}) + if facts: + facts = self.helper.embellish_internal_event(facts) + logger.debug("facts %s", facts) + if set_facts: + drools.ruleset.assert_fact(ruleset, facts) + if post_events: + drools.ruleset.post(ruleset, facts) + else: + logger.debug("Empty facts are not set") + + await super()._post_process() + + def _controller_job_url(self) -> str: + if "id" in self.controller_job: + return urljoin( + job_template_runner.host, + self._url_path, + ) + return "" diff --git a/ansible_rulebook/action/run_job_template.py b/ansible_rulebook/action/run_job_template.py index 72a95d06..4c5e61d6 100644 --- a/ansible_rulebook/action/run_job_template.py +++ b/ansible_rulebook/action/run_job_template.py @@ -12,146 +12,42 @@ # See the License for the specific language governing permissions and # limitations under the License. -import asyncio import logging -import uuid -from urllib.parse import urljoin -from drools import ruleset as lang - -from ansible_rulebook.conf import settings -from ansible_rulebook.exception import ( - ControllerApiException, - JobTemplateNotFoundException, -) +from ansible_rulebook.exception import JobTemplateNotFoundException from ansible_rulebook.job_template_runner import job_template_runner -from ansible_rulebook.util import run_at -from .control import Control -from .helper import Helper -from .metadata import Metadata +from .run_base import RunTemplate logger = logging.getLogger(__name__) -class RunJobTemplate: +class RunJobTemplate(RunTemplate): """run_job_template action launches a specified job template on the controller. It waits for the job to be complete. """ - def __init__(self, metadata: Metadata, control: Control, **action_args): - self.helper = Helper(metadata, control, "run_job_template") - self.action_args = action_args - self.name = self.action_args["name"] - self.organization = self.action_args["organization"] - self.job_id = str(uuid.uuid4()) - self.job_args = self.action_args.get("job_args", {}) - self.job_args["limit"] = ",".join(self.helper.control.hosts) - self.controller_job = {} - - async def __call__(self): - logger.info( - "running job template: %s, organization: %s", - self.name, - self.organization, - ) - logger.info( - "ruleset: %s, rule %s", - self.helper.metadata.rule_set, - self.helper.metadata.rule, - ) - - self.job_args["extra_vars"] = self.helper.collect_extra_vars( - self.job_args.get("extra_vars", {}) - ) - await self._job_start_event() - await self._run() - - async def _run(self): - retries = self.action_args.get("retries", 0) - if self.action_args.get("retry", False): - retries = max(self.action_args.get("retries", 0), 1) - delay = self.action_args.get("delay", 0) - - try: - for i in range(retries + 1): - if i > 0: - if delay > 0: - await asyncio.sleep(delay) - logger.info( - "Previous run_job_template failed. Retry %d of %d", - i, - retries, - ) - controller_job = await job_template_runner.run_job_template( - self.name, - self.organization, - self.job_args, - ) - if controller_job["status"] != "failed": - break - except (ControllerApiException, JobTemplateNotFoundException) as ex: - logger.error(ex) - controller_job = {} - controller_job["status"] = "failed" - controller_job["created"] = run_at() - controller_job["error"] = str(ex) - - self.controller_job = controller_job - await self._post_process() + @property + def _action_name(self): + return "run_job_template" - async def _post_process(self) -> None: - a_log = { - "job_template_name": self.name, - "organization": self.organization, - "job_id": self.job_id, - "status": self.controller_job["status"], - "run_at": self.controller_job["created"], - "url": self._controller_job_url(), - "matching_events": self.helper.get_events(), - } - if "error" in self.controller_job: - a_log["message"] = self.controller_job["error"] - a_log["reason"] = {"error": self.controller_job["error"]} + @property + def _exceptions(self): + return super()._exceptions + (JobTemplateNotFoundException,) - await self.helper.send_status(a_log) - set_facts = self.action_args.get("set_facts", False) - post_events = self.action_args.get("post_events", False) + @property + def _run_job(self): + return job_template_runner.run_job_template - if set_facts or post_events: - ruleset = self.action_args.get( - "ruleset", self.helper.metadata.rule_set - ) - logger.debug("set_facts") - facts = self.controller_job.get("artifacts", {}) - if facts: - facts = self.helper.embellish_internal_event(facts) - logger.debug("facts %s", facts) - if set_facts: - lang.assert_fact(ruleset, facts) - if post_events: - lang.post(ruleset, facts) - else: - logger.debug("Empty facts are not set") + @property + def _template_name(self): + return "job template" - async def _job_start_event(self): - await self.helper.send_status( - { - "run_at": run_at(), - "matching_events": self.helper.get_events(), - "action": self.helper.action, - "hosts": ",".join(self.helper.control.hosts), - "name": self.name, - "job_id": self.job_id, - "ansible_rulebook_id": settings.identifier, - }, - obj_type="Job", - ) + @property + def _url_prefix(self): + return super()._url_prefix + "jobs/" - def _controller_job_url(self) -> str: - if "id" in self.controller_job: - return urljoin( - job_template_runner.host, - "/#/jobs/" f"{self.controller_job['id']}/" "details", - ) - return "" + def _make_log(self): + log = super()._make_log() + log["job_template_name"] = self.name + return log diff --git a/ansible_rulebook/action/run_playbook.py b/ansible_rulebook/action/run_playbook.py index 2325daab..c98fdfc1 100644 --- a/ansible_rulebook/action/run_playbook.py +++ b/ansible_rulebook/action/run_playbook.py @@ -19,17 +19,16 @@ import os import shutil import tempfile -import uuid +from typing import Any +import drools import yaml -from drools import ruleset as lang from ansible_rulebook.collection import ( find_playbook, has_playbook, split_collection_name, ) -from ansible_rulebook.conf import settings from ansible_rulebook.exception import ( MissingArtifactKeyException, PlaybookNotFoundException, @@ -38,8 +37,8 @@ from ansible_rulebook.util import create_inventory, run_at from .control import Control -from .helper import Helper from .metadata import Metadata +from .run_base import RunBase from .runner import Runner logger = logging.getLogger(__name__) @@ -47,18 +46,25 @@ tar = shutil.which("tar") -class RunPlaybook: +class RunPlaybook(RunBase): """run_playbook action runs an ansible playbook using the ansible-runner """ + @property + def _action_name(self) -> str: + return "run_playbook" + + @property + def _job_data(self) -> dict: + data = super()._job_data + data["hosts"] = self.host_limit + return data + def __init__(self, metadata: Metadata, control: Control, **action_args): - self.helper = Helper(metadata, control, "run_playbook") - self.action_args = action_args - self.job_id = str(uuid.uuid4()) + super().__init__(metadata, control, **action_args) self.default_copy_files = True self.default_check_files = True - self.name = self.action_args["name"] self.verbosity = self.action_args.get("verbosity", 0) self.json_mode = self.action_args.get("json_mode", False) self.host_limit = ",".join(self.helper.control.hosts) @@ -73,61 +79,34 @@ async def __call__(self): f"rule: {self.helper.metadata.rule}" ) logger.debug("private data dir %s", self.private_data_dir) - await self._pre_process() - await self._job_start_event() - logger.info("Calling Ansible runner") - await self._run() + await super().__call__() finally: if os.path.exists(self.private_data_dir): shutil.rmtree(self.private_data_dir) - async def _job_start_event(self): - await self.helper.send_status( - { - "run_at": run_at(), - "matching_events": self.helper.get_events(), - "action": self.helper.action, - "hosts": self.host_limit, - "name": self.name, - "job_id": self.job_id, - "ansible_rulebook_id": settings.identifier, - }, - obj_type="Job", - ) - async def _run(self): - retries = self.action_args.get("retries", 0) - if self.action_args.get("retry", False): - retries = max(self.action_args.get("retries", 0), 1) - - delay = self.action_args.get("delay", 0) - - for i in range(retries + 1): - if i > 0: - if delay > 0: - await asyncio.sleep(delay) - logger.info( - "Previous run_playbook failed. Retry %d of %d", i, retries - ) - - await Runner( - self.private_data_dir, - self.host_limit, - self.verbosity, - self.job_id, - self.json_mode, - self.helper, - self._runner_args(), - )() - if self._get_latest_artifact("status") != "failed": - break - - await self._post_process() - - def _runner_args(self): + logger.info("Calling Ansible runner") + await super()._run() + + async def _do_run(self): + await Runner( + self.private_data_dir, + self.host_limit, + self.verbosity, + self.job_id, + self.json_mode, + self.helper, + self._runner_args(), + )() + if self._get_latest_artifact("status") != "failed": + raise StopAsyncIteration + + def _runner_args(self) -> dict: return {"playbook": self.name, "inventory": self.inventory} async def _pre_process(self) -> None: + await super()._pre_process() + playbook_extra_vars = self.helper.collect_extra_vars( self.action_args.get("extra_vars", {}) ) @@ -159,32 +138,7 @@ async def _pre_process(self) -> None: return self._copy_playbook_files(project_dir) - def _copy_playbook_files(self, project_dir): - if self.action_args.get("check_files", self.default_check_files): - if os.path.exists(self.name): - tail_name = os.path.basename(self.name) - shutil.copy(self.name, os.path.join(project_dir, tail_name)) - if self.action_args.get("copy_files", self.default_copy_files): - shutil.copytree( - os.path.dirname(os.path.abspath(self.name)), - project_dir, - dirs_exist_ok=True, - ) - self.name = tail_name - elif has_playbook(*split_collection_name(self.name)): - shutil.copy( - find_playbook(*split_collection_name(self.name)), - os.path.join(project_dir, self.name), - ) - else: - msg = ( - f"Could not find a playbook for {self.name} " - f"from {os.getcwd()}" - ) - logger.error(msg) - raise PlaybookNotFoundException(msg) - - async def _post_process(self): + async def _post_process(self) -> None: rc = int(self._get_latest_artifact("rc")) status = self._get_latest_artifact("status") logger.info("Ansible runner rc: %d, status: %s", rc, status) @@ -230,11 +184,40 @@ async def _post_process(self): fact = self.helper.embellish_internal_event(fact) logger.debug("fact %s", fact) if set_facts: - lang.assert_fact(ruleset, fact) + drools.ruleset.assert_fact(ruleset, fact) if post_events: - lang.post(ruleset, fact) + drools.ruleset.post(ruleset, fact) + + await super()._post_process() + + def _copy_playbook_files(self, project_dir) -> None: + if self.action_args.get("check_files", self.default_check_files): + if os.path.exists(self.name): + tail_name = os.path.basename(self.name) + shutil.copy(self.name, os.path.join(project_dir, tail_name)) + if self.action_args.get("copy_files", self.default_copy_files): + shutil.copytree( + os.path.dirname(os.path.abspath(self.name)), + project_dir, + dirs_exist_ok=True, + ) + self.name = tail_name + elif has_playbook(*split_collection_name(self.name)): + shutil.copy( + find_playbook(*split_collection_name(self.name)), + os.path.join(project_dir, self.name), + ) + else: + msg = ( + f"Could not find a playbook for {self.name} " + f"from {os.getcwd()}" + ) + logger.error(msg) + raise PlaybookNotFoundException(msg) - def _get_latest_artifact(self, component: str, content: bool = True): + def _get_latest_artifact( + self, component: str, content: bool = True + ) -> Any: files = glob.glob( os.path.join(self.private_data_dir, "artifacts", "*", component) ) @@ -247,7 +230,7 @@ def _get_latest_artifact(self, component: str, content: bool = True): return content return files[0] - async def _untar_project(self, output_dir, project_data_file): + async def _untar_project(self, output_dir, project_data_file) -> None: cmd = [tar, "zxvf", project_data_file] proc = await asyncio.create_subprocess_exec( diff --git a/ansible_rulebook/action/run_workflow_template.py b/ansible_rulebook/action/run_workflow_template.py index 072628da..5a9666f1 100644 --- a/ansible_rulebook/action/run_workflow_template.py +++ b/ansible_rulebook/action/run_workflow_template.py @@ -12,152 +12,42 @@ # See the License for the specific language governing permissions and # limitations under the License. -import asyncio import logging -import uuid -from urllib.parse import urljoin -from drools import ruleset as lang - -from ansible_rulebook.conf import settings -from ansible_rulebook.exception import ( - ControllerApiException, - WorkflowJobTemplateNotFoundException, -) +from ansible_rulebook.exception import WorkflowJobTemplateNotFoundException from ansible_rulebook.job_template_runner import job_template_runner -from ansible_rulebook.util import run_at -from .control import Control -from .helper import Helper -from .metadata import Metadata +from .run_base import RunTemplate logger = logging.getLogger(__name__) -class RunWorkflowTemplate: +class RunWorkflowTemplate(RunTemplate): """run_workflow_template action launches a specified workflow template on the controller. It waits for the job to be complete. """ - def __init__(self, metadata: Metadata, control: Control, **action_args): - self.helper = Helper(metadata, control, "run_workflow_template") - self.action_args = action_args - self.name = self.action_args["name"] - self.organization = self.action_args["organization"] - self.job_id = str(uuid.uuid4()) - self.job_args = self.action_args.get("job_args", {}) - self.job_args["limit"] = ",".join(self.helper.control.hosts) - self.controller_job = {} - - async def __call__(self): - logger.info( - "running workflow template: %s, organization: %s", - self.name, - self.organization, - ) - logger.info( - "ruleset: %s, rule %s", - self.helper.metadata.rule_set, - self.helper.metadata.rule, - ) - - self.job_args["extra_vars"] = self.helper.collect_extra_vars( - self.job_args.get("extra_vars", {}) - ) - await self._job_start_event() - await self._run() - - async def _run(self): - retries = self.action_args.get("retries", 0) - if self.action_args.get("retry", False): - retries = max(self.action_args.get("retries", 0), 1) - delay = self.action_args.get("delay", 0) - - try: - for i in range(retries + 1): - if i > 0: - if delay > 0: - await asyncio.sleep(delay) - logger.info( - "Previous run_workflow_template failed. " - "Retry %d of %d", - i, - retries, - ) - controller_job = ( - await job_template_runner.run_workflow_job_template( - self.name, - self.organization, - self.job_args, - ) - ) - if controller_job["status"] != "failed": - break - except ( - ControllerApiException, - WorkflowJobTemplateNotFoundException, - ) as ex: - logger.error(ex) - controller_job = {} - controller_job["status"] = "failed" - controller_job["created"] = run_at() - controller_job["error"] = str(ex) - - self.controller_job = controller_job - await self._post_process() + @property + def _action_name(self): + return "run_workflow_template" - async def _post_process(self) -> None: - a_log = { - "name": self.name, - "organization": self.organization, - "job_id": self.job_id, - "status": self.controller_job["status"], - "run_at": self.controller_job["created"], - "url": self._controller_job_url(), - "matching_events": self.helper.get_events(), - } - if "error" in self.controller_job: - a_log["message"] = self.controller_job["error"] - a_log["reason"] = {"error": self.controller_job["error"]} + @property + def _exceptions(self): + return super()._exceptions + (WorkflowJobTemplateNotFoundException,) - await self.helper.send_status(a_log) - set_facts = self.action_args.get("set_facts", False) - post_events = self.action_args.get("post_events", False) + @property + def _run_job(self): + return job_template_runner.run_workflow_job_template - if set_facts or post_events: - ruleset = self.action_args.get( - "ruleset", self.helper.metadata.rule_set - ) - logger.debug("set_facts") - facts = self.controller_job.get("artifacts", {}) - if facts: - facts = self.helper.embellish_internal_event(facts) - logger.debug("facts %s", facts) - if set_facts: - lang.assert_fact(ruleset, facts) - if post_events: - lang.post(ruleset, facts) - else: - logger.debug("Empty facts are not set") + @property + def _template_name(self): + return "workflow template" - async def _job_start_event(self): - await self.helper.send_status( - { - "run_at": run_at(), - "matching_events": self.helper.get_events(), - "action": self.helper.action, - "hosts": ",".join(self.helper.control.hosts), - "name": self.name, - "job_id": self.job_id, - "ansible_rulebook_id": settings.identifier, - }, - obj_type="Job", - ) + @property + def _url_prefix(self): + return super()._url_prefix + "jobs/workflow/" - def _controller_job_url(self) -> str: - if "id" in self.controller_job: - return urljoin( - job_template_runner.host, - "/#/jobs/workflow/" f"{self.controller_job['id']}/" "details", - ) - return "" + def _make_log(self): + log = super()._make_log() + log["name"] = self.name + return log diff --git a/tests/unit/action/test_debug.py b/tests/unit/action/test_debug.py index 91dbee97..0c1f5009 100644 --- a/tests/unit/action/test_debug.py +++ b/tests/unit/action/test_debug.py @@ -89,7 +89,7 @@ async def test_debug(): with patch("uuid.uuid4", return_value=DUMMY_UUID): with patch( - "ansible_rulebook.action.run_job_template.lang.get_facts", + "drools.ruleset.get_facts", return_value={"a": 1}, ) as drools_mock: await Debug(metadata, control, **action_args)() diff --git a/tests/unit/action/test_post_event.py b/tests/unit/action/test_post_event.py index f2d0b3be..86bb4b03 100644 --- a/tests/unit/action/test_post_event.py +++ b/tests/unit/action/test_post_event.py @@ -52,7 +52,7 @@ async def test_noop(): with patch("uuid.uuid4", return_value=DUMMY_UUID): with patch( - "ansible_rulebook.action.run_job_template.lang.post" + "drools.ruleset.post", ) as drools_mock: await PostEvent(metadata, control, **action_args)() drools_mock.assert_called_once_with( diff --git a/tests/unit/action/test_retract_fact.py b/tests/unit/action/test_retract_fact.py index 8fc69422..84d07f92 100644 --- a/tests/unit/action/test_retract_fact.py +++ b/tests/unit/action/test_retract_fact.py @@ -58,10 +58,7 @@ async def test_retract_fact(partial, keys_excluded): } with patch("uuid.uuid4", return_value=DUMMY_UUID): - with patch( - "ansible_rulebook.action.run_job_template." - "lang.retract_matching_facts" - ) as drools_mock: + with patch("drools.ruleset.retract_matching_facts") as drools_mock: await RetractFact(metadata, control, **action_args)() drools_mock.assert_called_once_with( action_args["ruleset"], diff --git a/tests/unit/action/test_run_job_template.py b/tests/unit/action/test_run_job_template.py index 8646729e..557eb695 100644 --- a/tests/unit/action/test_run_job_template.py +++ b/tests/unit/action/test_run_job_template.py @@ -106,11 +106,11 @@ async def test_run_job_template_exception(err_msg, err): DROOLS_CALLS = [ ( - "ansible_rulebook.action.run_job_template.lang.assert_fact", + "drools.ruleset.assert_fact", dict(set_facts=True), ), ( - "ansible_rulebook.action.run_job_template.lang.post", + "drools.ruleset.post", dict(post_events=True), ), ] @@ -209,7 +209,7 @@ async def test_run_job_template_retries(): side_effect=controller_job, ): with patch( - "ansible_rulebook.action.run_job_template.lang.assert_fact" + "drools.ruleset.assert_fact", ) as drools_mock: await RunJobTemplate(metadata, control, **action_args)() drools_mock.assert_called_once() diff --git a/tests/unit/action/test_run_playbook.py b/tests/unit/action/test_run_playbook.py index d4d888ec..82adf576 100644 --- a/tests/unit/action/test_run_playbook.py +++ b/tests/unit/action/test_run_playbook.py @@ -80,11 +80,11 @@ def _validate(queue, metadata, status, rc): DROOLS_CALLS = [ ( - "ansible_rulebook.action.run_job_template.lang.assert_fact", + "drools.ruleset.assert_fact", dict(set_facts=True), ), ( - "ansible_rulebook.action.run_job_template.lang.post", + "drools.ruleset.post", dict(post_events=True), ), ] diff --git a/tests/unit/action/test_run_workflow_template.py b/tests/unit/action/test_run_workflow_template.py index c780fe17..cc40ca98 100644 --- a/tests/unit/action/test_run_workflow_template.py +++ b/tests/unit/action/test_run_workflow_template.py @@ -109,11 +109,11 @@ async def test_run_workflow_template_exception(err_msg, err): DROOLS_CALLS = [ ( - "ansible_rulebook.action.run_workflow_template.lang.assert_fact", + "drools.ruleset.assert_fact", dict(set_facts=True), ), ( - "ansible_rulebook.action.run_workflow_template.lang.post", + "drools.ruleset.post", dict(post_events=True), ), ] @@ -212,7 +212,7 @@ async def test_run_workflow_template_retries(): side_effect=controller_job, ): with patch( - "ansible_rulebook.action.run_workflow_template.lang.assert_fact" + "drools.ruleset.assert_fact", ) as drools_mock: await RunWorkflowTemplate(metadata, control, **action_args)() drools_mock.assert_called_once() diff --git a/tests/unit/action/test_set_fact.py b/tests/unit/action/test_set_fact.py index f06c7dfb..7c4dd309 100644 --- a/tests/unit/action/test_set_fact.py +++ b/tests/unit/action/test_set_fact.py @@ -52,7 +52,7 @@ async def test_noop(): with patch("uuid.uuid4", return_value=DUMMY_UUID): with patch( - "ansible_rulebook.action.run_job_template.lang.assert_fact" + "drools.ruleset.assert_fact", ) as drools_mock: await SetFact(metadata, control, **action_args)() drools_mock.assert_called_once_with(