From ab73076c017bfc8abbe62e617292ef7232b630f1 Mon Sep 17 00:00:00 2001 From: Paul Bonaud Date: Mon, 22 Jun 2020 18:34:38 +0200 Subject: feature: add a new 'clever_restart_only' flag to restart an app This new flag will perform a restart on the target clever cloud application instead of deploying it. --- README.md | 3 ++- tasks/main.yml | 9 +++++++++ tasks/restart.yml | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tasks/restart.yml 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: - `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. - `clever_scaling`: an optional object used to configure the runtime instances flavours and numbers. If not defined, it delegates to clever cloud default behaviour. -Variables specific to deployment, default should be fine: +Variables specific to deployment, defaults should be fine: - `clever_cli_version`: Version of clever cli tools, default to `2.6.1`. - `clever_user_path`: Path relative to ansible_user home dir where cli tools and helpers are installed default to `.local/bin`. - `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. - `clever_app_confdir`: Path where to store clever cloud data specific to this application, default to `"{{ clever_app_root }}/.clever_cloud"` - `clever_login_file`: Path to store login information. Default to `"{{ clever_app_confdir }}/login"`. +- `clever_restart_only`: set to `true` to skip any deployment related tasks (domain, scaling, env, deploy, …) and only restart the application. Optional. Variables specific to Haskell applications: 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 @@ - name: Deploy app import_tasks: deploy.yml + when: not clever_restart_only is defined or not clever_restart_only tags: - clever - clever-deploy - name: Post deploy tasks import_tasks: post_deploy.yml + when: not clever_restart_only is defined or not clever_restart_only tags: - clever - clever-deploy - clever-env + +- name: Restart app + import_tasks: restart.yml + when: clever_restart_only is defined and clever_restart_only + tags: + - clever + - 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 @@ +--- +- name: Restart app on Clever-Cloud + shell: "clever restart" + args: + chdir: "{{ clever_app_root }}" + environment: + CONFIGURATION_FILE: "{{ clever_login_file }}" + async: 300 # 5 minutes + poll: 0 + ignore_errors: true + register: clever_deploy + tags: + - skip_ansible_lint + +- name: Wait up to 5 minutes for restart completion + async_status: + jid: "{{ clever_deploy.ansible_job_id }}" + register: job_result + until: job_result.finished + ignore_errors: true + delay: 30 + retries: 10 # 5 minutes (10 * 30 secs delay) -- cgit v1.2.3