aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>2021-11-15 15:34:49 +0100
committerGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>2021-11-15 15:34:49 +0100
commit95a202dcbd62d616698aedc7f993f91910b2187d (patch)
treeb7218451255dd98ef7ac1bea70358a19404741a2
parent0f0259c91faa37ec6c7e7d89cc47f41ca065a244 (diff)
downloadansible-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.md3
-rw-r--r--defaults/main.yml1
-rw-r--r--tasks/rundeck.yml12
3 files changed, 15 insertions, 1 deletions
diff --git a/README.md b/README.md
index 5a99be8..cc3a38e 100644
--- a/README.md
+++ b/README.md
@@ -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
22A [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. 23A [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
42License 43License
43------- 44-------
44 45
45TBD 46BSD
46 47
47Author Information 48Author 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---
2rundeck_api_version: 26 2rundeck_api_version: 26
3rundeck_remove_missing: true 3rundeck_remove_missing: true
4rundeck_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) }}"