diff --git a/ansible_rulebook/action/run_base.py b/ansible_rulebook/action/run_base.py index 61e357bc..ebb704b5 100644 --- a/ansible_rulebook/action/run_base.py +++ b/ansible_rulebook/action/run_base.py @@ -48,11 +48,11 @@ def _job_data(self) -> dict: return data @property - def _template_id(self) -> str: + def _action_name(self) -> str: raise NotImplementedError def __init__(self, metadata: Metadata, control: Control, **action_args): - self.helper = Helper(metadata, control, self._template_id) + 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"] @@ -75,7 +75,7 @@ async def _run(self): await asyncio.sleep(delay) logger.info( "Previous %s failed. Retry %d of %d", - self._template_id, + self._action_name, i, retries, ) diff --git a/ansible_rulebook/action/run_job_template.py b/ansible_rulebook/action/run_job_template.py index 114d904e..4c5e61d6 100644 --- a/ansible_rulebook/action/run_job_template.py +++ b/ansible_rulebook/action/run_job_template.py @@ -27,6 +27,10 @@ class RunJobTemplate(RunTemplate): the controller. It waits for the job to be complete. """ + @property + def _action_name(self): + return "run_job_template" + @property def _exceptions(self): return super()._exceptions + (JobTemplateNotFoundException,) @@ -35,10 +39,6 @@ def _exceptions(self): def _run_job(self): return job_template_runner.run_job_template - @property - def _template_id(self): - return "run_job_template" - @property def _template_name(self): return "job template" diff --git a/ansible_rulebook/action/run_playbook.py b/ansible_rulebook/action/run_playbook.py index 31f57e3d..f1869011 100644 --- a/ansible_rulebook/action/run_playbook.py +++ b/ansible_rulebook/action/run_playbook.py @@ -51,16 +51,16 @@ class RunPlaybook(RunBase): 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 - @property - def _template_id(self) -> str: - return "run_playbook" - def __init__(self, metadata: Metadata, control: Control, **action_args): super().__init__(metadata, control, **action_args) self.default_copy_files = True diff --git a/ansible_rulebook/action/run_workflow_template.py b/ansible_rulebook/action/run_workflow_template.py index bbd60b16..5a9666f1 100644 --- a/ansible_rulebook/action/run_workflow_template.py +++ b/ansible_rulebook/action/run_workflow_template.py @@ -27,6 +27,10 @@ class RunWorkflowTemplate(RunTemplate): the controller. It waits for the job to be complete. """ + @property + def _action_name(self): + return "run_workflow_template" + @property def _exceptions(self): return super()._exceptions + (WorkflowJobTemplateNotFoundException,) @@ -35,10 +39,6 @@ def _exceptions(self): def _run_job(self): return job_template_runner.run_workflow_job_template - @property - def _template_id(self): - return "run_workflow_template" - @property def _template_name(self): return "workflow template"