From: Gaƫtan Duchaussois Date: Thu, 4 Nov 2021 16:35:50 +0000 (+0100) Subject: bug: remove only jobs from root when no group specified X-Git-Tag: v0.7^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=refs%2Fpull%2F8%2Fhead;p=github%2Ffretlink%2Fansible-rundeck-jobs.git bug: remove only jobs from root when no group specified --- 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"