aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
authorPaul Bonaud <paul.bonaud@fretlink.com>2020-08-06 11:44:26 +0200
committerPaul Bonaud <paul.bonaud@fretlink.com>2020-08-06 15:54:27 +0200
commitc3e2ff5e0f31c61eae330a1a41d7a8a83435d9bd (patch)
treef03e1db57031f574657838a8a15c41319b1c18be /tasks
parent315c7f51af48b54719bd793d9d28a4bb396a926a (diff)
downloadansible-clever-c3e2ff5e0f31c61eae330a1a41d7a8a83435d9bd.tar.gz
ansible-clever-c3e2ff5e0f31c61eae330a1a41d7a8a83435d9bd.tar.zst
ansible-clever-c3e2ff5e0f31c61eae330a1a41d7a8a83435d9bd.zip
deploy: try to restart the app when the CLI asks to do it
In some cases (rollback or deployment errored on clever side), clever-tools will fail when calling `clever deploy` because it thinks the currently being deployed commit is already deployed. However in some cases the git pushed commit is not the currently running commit. Leading to a failure in our deployment process. The proposed solution from the clever tools error is to launch `clever restart`. Until we wait for https://github.com/CleverCloud/clever-tools/issues/422 to be fixed, let's do what the error message say: try to restart in case of a deployment failure.
Diffstat (limited to 'tasks')
-rw-r--r--tasks/deploy.yml7
-rw-r--r--tasks/restart.yml9
2 files changed, 15 insertions, 1 deletions
diff --git a/tasks/deploy.yml b/tasks/deploy.yml
index 8dda5e0..39b5845 100644
--- a/tasks/deploy.yml
+++ b/tasks/deploy.yml
@@ -85,6 +85,13 @@
85 - job_result.stderr is defined 85 - job_result.stderr is defined
86 - job_result.stderr is search("Failed to read git object") 86 - job_result.stderr is search("Failed to read git object")
87 87
88- name: Restart app on clever-cloud when error asks to restart
89 include_tasks: restart.yml
90 when:
91 - not job_result.finished or not job_result.rc == 0
92 - job_result.stderr is defined
93 - job_result.stderr is search("clever restart")
94
88- name: Deploy logs (stdout) 95- name: Deploy logs (stdout)
89 debug: 96 debug:
90 var: job_result.stdout_lines 97 var: job_result.stdout_lines
diff --git a/tasks/restart.yml b/tasks/restart.yml
index e2a8891..1c52032 100644
--- a/tasks/restart.yml
+++ b/tasks/restart.yml
@@ -1,6 +1,13 @@
1--- 1---
2- name: Get current HEAD commit revision
3 command: "git rev-parse HEAD" # noqa 303
4 register: git_head_revision
5 args:
6 chdir: "{{ clever_app_root }}"
7 changed_when: false
8
2- name: Restart app on Clever-Cloud 9- name: Restart app on Clever-Cloud
3 shell: "clever restart" 10 shell: "clever restart --commit {{ git_head_revision.stdout_lines | first }}"
4 args: 11 args:
5 chdir: "{{ clever_app_root }}" 12 chdir: "{{ clever_app_root }}"
6 environment: 13 environment: