aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--tasks/main.yml9
-rw-r--r--tasks/restart.yml22
3 files changed, 33 insertions, 1 deletions
diff --git a/README.md b/README.md
index 22c70b4..51b9e3d 100644
--- a/README.md
+++ b/README.md
@@ -35,13 +35,14 @@ Variables for the application:
35- `clever_build_flavor`: an optional text value used to configure the size of the dedicated build instance (for instance `S` or `XL`). If not defined, it delegates to clever cloud default behaviour. Setting `disabled` disables the dedicated build instance altogether. 35- `clever_build_flavor`: an optional text value used to configure the size of the dedicated build instance (for instance `S` or `XL`). If not defined, it delegates to clever cloud default behaviour. Setting `disabled` disables the dedicated build instance altogether.
36- `clever_scaling`: an optional object used to configure the runtime instances flavours and numbers. If not defined, it delegates to clever cloud default behaviour. 36- `clever_scaling`: an optional object used to configure the runtime instances flavours and numbers. If not defined, it delegates to clever cloud default behaviour.
37 37
38Variables specific to deployment, default should be fine: 38Variables specific to deployment, defaults should be fine:
39 39
40- `clever_cli_version`: Version of clever cli tools, default to `2.6.1`. 40- `clever_cli_version`: Version of clever cli tools, default to `2.6.1`.
41- `clever_user_path`: Path relative to ansible_user home dir where cli tools and helpers are installed default to `.local/bin`. 41- `clever_user_path`: Path relative to ansible_user home dir where cli tools and helpers are installed default to `.local/bin`.
42- `clever_app_root`: Path of the application to deploy, default to `app_root` if defined or `"{{ playbook_dir }}/.."` otherwise. I.e. the default behavior will work fine if you define a playbook using this role in a one level deep directory (e.g. `deployment/`) of the root of the application. 42- `clever_app_root`: Path of the application to deploy, default to `app_root` if defined or `"{{ playbook_dir }}/.."` otherwise. I.e. the default behavior will work fine if you define a playbook using this role in a one level deep directory (e.g. `deployment/`) of the root of the application.
43- `clever_app_confdir`: Path where to store clever cloud data specific to this application, default to `"{{ clever_app_root }}/.clever_cloud"` 43- `clever_app_confdir`: Path where to store clever cloud data specific to this application, default to `"{{ clever_app_root }}/.clever_cloud"`
44- `clever_login_file`: Path to store login information. Default to `"{{ clever_app_confdir }}/login"`. 44- `clever_login_file`: Path to store login information. Default to `"{{ clever_app_confdir }}/login"`.
45- `clever_restart_only`: set to `true` to skip any deployment related tasks (domain, scaling, env, deploy, …) and only restart the application. Optional.
45 46
46Variables specific to Haskell applications: 47Variables specific to Haskell applications:
47 48
diff --git a/tasks/main.yml b/tasks/main.yml
index 3c59c90..002dc9c 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -24,13 +24,22 @@
24 24
25- name: Deploy app 25- name: Deploy app
26 import_tasks: deploy.yml 26 import_tasks: deploy.yml
27 when: not clever_restart_only is defined or not clever_restart_only
27 tags: 28 tags:
28 - clever 29 - clever
29 - clever-deploy 30 - clever-deploy
30 31
31- name: Post deploy tasks 32- name: Post deploy tasks
32 import_tasks: post_deploy.yml 33 import_tasks: post_deploy.yml
34 when: not clever_restart_only is defined or not clever_restart_only
33 tags: 35 tags:
34 - clever 36 - clever
35 - clever-deploy 37 - clever-deploy
36 - clever-env 38 - clever-env
39
40- name: Restart app
41 import_tasks: restart.yml
42 when: clever_restart_only is defined and clever_restart_only
43 tags:
44 - clever
45 - clever-restart
diff --git a/tasks/restart.yml b/tasks/restart.yml
new file mode 100644
index 0000000..e2a8891
--- /dev/null
+++ b/tasks/restart.yml
@@ -0,0 +1,22 @@
1---
2- name: Restart app on Clever-Cloud
3 shell: "clever restart"
4 args:
5 chdir: "{{ clever_app_root }}"
6 environment:
7 CONFIGURATION_FILE: "{{ clever_login_file }}"
8 async: 300 # 5 minutes
9 poll: 0
10 ignore_errors: true
11 register: clever_deploy
12 tags:
13 - skip_ansible_lint
14
15- name: Wait up to 5 minutes for restart completion
16 async_status:
17 jid: "{{ clever_deploy.ansible_job_id }}"
18 register: job_result
19 until: job_result.finished
20 ignore_errors: true
21 delay: 30
22 retries: 10 # 5 minutes (10 * 30 secs delay)