From 93e66c13622afc0f57dd31a9d252a24f7b9753de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ne=C4=8Das?= Date: Mon, 10 Feb 2020 23:14:56 +0100 Subject: [PATCH] Backport ovirt job (#67076) * ovirt_job: add when job is detected but in state finished (#66810) * ovirt_job: add when job is detected but in state finished * add docs * add changelog --- ...virt_job-add-when-job-is-detected-but-in-state-finished.yml | 2 ++ lib/ansible/modules/cloud/ovirt/ovirt_job.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/66810-ovirt_job-add-when-job-is-detected-but-in-state-finished.yml diff --git a/changelogs/fragments/66810-ovirt_job-add-when-job-is-detected-but-in-state-finished.yml b/changelogs/fragments/66810-ovirt_job-add-when-job-is-detected-but-in-state-finished.yml new file mode 100644 index 00000000000..094f962bc2f --- /dev/null +++ b/changelogs/fragments/66810-ovirt_job-add-when-job-is-detected-but-in-state-finished.yml @@ -0,0 +1,2 @@ +bugfixes: + - "ovirt_job: add job when job is already existing and is in state finished" diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_job.py b/lib/ansible/modules/cloud/ovirt/ovirt_job.py index 5a96d7f9659..7b6c595ee3f 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_job.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_job.py @@ -36,6 +36,7 @@ options: description: description: - "Description of the job." + - "When task with same description has already finished and you rerun taks it will create new job." required: true state: description: @@ -199,7 +200,7 @@ def main(): job = get_entity(jobs_service, module.params['description']) changed = False if state in ['present', 'started']: - if job is None: + if job is None or job.status in [otypes.JobStatus.FINISHED, otypes.JobStatus.FAILED]: job = jobs_service.add(build_job(module.params['description'])) changed = True changed = attach_steps(module, job.id, jobs_service) or changed