From e43aa9af82046d06c4c9b93eaa23dfba44f62781 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ga=C3=ABtan=20Duchaussois?= Date: Thu, 4 Nov 2021 17:35:50 +0100 Subject: [PATCH] bug: remove only jobs from root when no group specified --- tasks/rundeck.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tasks/rundeck.yml b/tasks/rundeck.yml index 4396552..007b86e 100644 --- a/tasks/rundeck.yml +++ b/tasks/rundeck.yml @@ -27,14 +27,17 @@ Accept: application/json X-Rundeck-Auth-Token: "{{ rundeck_api_token }}" vars: - rundeck_empty_group_path: '""' + rundeck_empty_group_path: '' register: rundeck_existing_jobs when: rundeck_remove_missing - name: "Prepare list of jobs to remove" set_fact: rundeck_created_ids: "{{ rundeck_create_jobs.results | map(attribute='json') | map('json_query','succeeded[*].id') | flatten | list }}" - rundeck_jobs_ids: "{{ rundeck_existing_jobs.json | map(attribute='id') | list }}" + rundeck_jobs_ids: "{{ rundeck_existing_jobs_list | map(attribute='id') | list }}" + vars: + rundeck_existing_jobs_list_null: "{{ rundeck_existing_jobs.json | selectattr('group', 'none') | list }}" + rundeck_existing_jobs_list: "{{ rundeck_jobs_group | default(false) | ternary(rundeck_existing_jobs.json, rundeck_existing_jobs_list_null) }}" when: rundeck_remove_missing - name: "Remove jobs not in the directory" -- 2.41.0