diff options
author | Gaëtan Duchaussois <gaetan.duchaussois@fretlink.com> | 2021-11-15 15:34:49 +0100 |
---|---|---|
committer | Gaëtan Duchaussois <gaetan.duchaussois@fretlink.com> | 2021-11-15 15:34:49 +0100 |
commit | 95a202dcbd62d616698aedc7f993f91910b2187d (patch) | |
tree | b7218451255dd98ef7ac1bea70358a19404741a2 | |
parent | 0f0259c91faa37ec6c7e7d89cc47f41ca065a244 (diff) | |
download | ansible-rundeck-jobs-95a202dcbd62d616698aedc7f993f91910b2187d.tar.gz ansible-rundeck-jobs-95a202dcbd62d616698aedc7f993f91910b2187d.tar.zst ansible-rundeck-jobs-95a202dcbd62d616698aedc7f993f91910b2187d.zip |
Unmask Job creation error
The rundeck job creation api endpoint always return 200 with the result
in the body. The ansible action always succeed. This PR displays the
errors and if `rundeck_ignore_creation_error` is set to false, fails.
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | defaults/main.yml | 1 | ||||
-rw-r--r-- | tasks/rundeck.yml | 12 |
3 files changed, 15 insertions, 1 deletions
@@ -18,6 +18,7 @@ Role Variables | |||
18 | * `rundeck_api_version` api version supported by rundeck server. Default to 26. | 18 | * `rundeck_api_version` api version supported by rundeck server. Default to 26. |
19 | * `rundeck_remove_missing` Whether to delete jobs present in rundeck and not in file. Defaults to true. | 19 | * `rundeck_remove_missing` Whether to delete jobs present in rundeck and not in file. Defaults to true. |
20 | * `rundeck_jobs_group` the group of job to check for removal | 20 | * `rundeck_jobs_group` the group of job to check for removal |
21 | * `rundeck_ignore_creation_errors` whether to ignore job creation error. Default to true to follow the 200 statu given by rundeck API | ||
21 | 22 | ||
22 | A [dhall](https://dhall-lang.org/) Type representing the roles' variables is available in the `./dhall/Config.dhall` file to help you configure your projects with some type checking. | 23 | A [dhall](https://dhall-lang.org/) Type representing the roles' variables is available in the `./dhall/Config.dhall` file to help you configure your projects with some type checking. |
23 | 24 | ||
@@ -42,7 +43,7 @@ Including an example of how to use your role (for instance, with variables passe | |||
42 | License | 43 | License |
43 | ------- | 44 | ------- |
44 | 45 | ||
45 | TBD | 46 | BSD |
46 | 47 | ||
47 | Author Information | 48 | Author Information |
48 | ------------------ | 49 | ------------------ |
diff --git a/defaults/main.yml b/defaults/main.yml index 87958ec..32342aa 100644 --- a/defaults/main.yml +++ b/defaults/main.yml | |||
@@ -1,3 +1,4 @@ | |||
1 | --- | 1 | --- |
2 | rundeck_api_version: 26 | 2 | rundeck_api_version: 26 |
3 | rundeck_remove_missing: true | 3 | rundeck_remove_missing: true |
4 | rundeck_ignore_creation_error: true | ||
diff --git a/tasks/rundeck.yml b/tasks/rundeck.yml index 007b86e..1250d24 100644 --- a/tasks/rundeck.yml +++ b/tasks/rundeck.yml | |||
@@ -19,6 +19,18 @@ | |||
19 | register: rundeck_create_jobs | 19 | register: rundeck_create_jobs |
20 | with_items: "{{ rundeck_jobs_files.files}}" | 20 | with_items: "{{ rundeck_jobs_files.files}}" |
21 | 21 | ||
22 | - name: Check if a job failed | ||
23 | fail: | ||
24 | msg: "Job defined in {{ file }} has failed with message: {{ message }}" | ||
25 | with_items: "{{ rundeck_create_jobs.results }}" | ||
26 | loop_control: | ||
27 | label: "{{ item.item.path }}" | ||
28 | vars: | ||
29 | file: "{{ item.item.path }}" | ||
30 | message: "{{ item.json.failed }}" | ||
31 | when: item.json.failed|length > 0 | ||
32 | ignore_errors: "{{ rundeck_ignore_creation_error }}" | ||
33 | |||
22 | - name: Get all jobs | 34 | - name: Get all jobs |
23 | uri: | 35 | uri: |
24 | url: "{{rundeck_api_url }}/{{rundeck_api_version}}/project/{{ rundeck_project }}/jobs?groupPathExact={{ rundeck_jobs_group | default(rundeck_empty_group_path) }}" | 36 | url: "{{rundeck_api_url }}/{{rundeck_api_version}}/project/{{ rundeck_project }}/jobs?groupPathExact={{ rundeck_jobs_group | default(rundeck_empty_group_path) }}" |