aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
authorpaulrbr-fl <43074087+paulrbr-fl@users.noreply.github.com>2020-06-17 15:10:45 +0200
committerGitHub <noreply@github.com>2020-06-17 15:10:45 +0200
commitd5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6 (patch)
treeda182d67325ec1b8ce02a600e6c458229772eece /tasks
parent5816bb884149309b6cfcf438feab7265a14d4c0b (diff)
parentb89d0540672614a5d93da43b317015c3ae8554be (diff)
downloadansible-clever-d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6.tar.gz
ansible-clever-d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6.tar.zst
ansible-clever-d5c5bf88290ffb2fbb7835dcfb9c645563cdd3e6.zip
Merge pull request #63 from paulrbr-fl/upgrade-clever-cliv2.5
deploy: remove custom polling script now that the CLI does it for us
Diffstat (limited to 'tasks')
-rw-r--r--tasks/deploy.yml75
-rw-r--r--tasks/redeploy.yml33
-rw-r--r--tasks/setup.yml3
3 files changed, 54 insertions, 57 deletions
diff --git a/tasks/deploy.yml b/tasks/deploy.yml
index d5e5a45..4d4ecaa 100644
--- a/tasks/deploy.yml
+++ b/tasks/deploy.yml
@@ -24,80 +24,45 @@
24 CONFIGURATION_FILE: "{{ clever_login_file }}" 24 CONFIGURATION_FILE: "{{ clever_login_file }}"
25 changed_when: false 25 changed_when: false
26 26
27#TODO: Improve ssh-key validation
28- name: Accept Clever-Cloud servers
29 shell: "ssh-keyscan -H push-par-clevercloud-customers.services.clever-cloud.com >> ~/.ssh/known_hosts"
30 tags:
31 - skip_ansible_lint
32
33- name: Deploy to Clever-Cloud 27- name: Deploy to Clever-Cloud
34 command: "git push --force git+ssh://git@push-par-clevercloud-customers.services.clever-cloud.com/{{ clever_app }}.git HEAD:refs/heads/master" 28 shell: "clever deploy --force"
35 args:
36 chdir: "{{ clever_app_root }}"
37 register: clever_deploy
38 ignore_errors: true
39 tags:
40 - skip_ansible_lint
41
42##################################################################
43# Re-deploy only if its the first clever deploy for that project #
44##################################################################
45
46- name: First time push to Clever-Cloud needs a full git clone
47 command: "git fetch --unshallow"
48 args:
49 chdir: "{{ clever_app_root }}"
50 when:
51 - clever_deploy is failed
52 - clever_deploy.stderr is defined
53 - clever_deploy.stderr is search("Failed to read git object")
54 tags:
55 - skip_ansible_lint
56
57- name: Deploy to Clever-Cloud
58 command: "git push --force git+ssh://git@push-par-clevercloud-customers.services.clever-cloud.com/{{ clever_app }}.git HEAD:refs/heads/master"
59 args:
60 chdir: "{{ clever_app_root }}"
61 when:
62 - clever_deploy is failed
63 - clever_deploy.stderr is defined
64 - clever_deploy.stderr is search("Failed to read git object")
65 register: clever_deploy
66 tags:
67 - skip_ansible_lint
68
69##############################################################################
70# Poll deployment status from 'clever activity' command. #
71# 'clever deploy' command is not yet 100% reliable to get a blocking command #
72# until the deployment is over. Hence the need for a custom waiting script. #
73##############################################################################
74
75- name: Watch deployment status
76 command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-wait-deploy.sh"
77 args: 29 args:
78 chdir: "{{ clever_app_root }}" 30 chdir: "{{ clever_app_root }}"
79 environment: 31 environment:
80 CONFIGURATION_FILE: "{{ clever_login_file }}" 32 CONFIGURATION_FILE: "{{ clever_login_file }}"
81 async: 2400 # 40 minutes 33 async: 2400 # 40 minutes
82 poll: 0 34 poll: 0
83 register: long_command 35 ignore_errors: true
84 changed_when: False 36 register: clever_deploy
37 tags:
38 - skip_ansible_lint
85 39
86- name: Wait 40 minutes for deployment completion 40- name: Wait up to 40 minutes for deployment completion
87 async_status: 41 async_status:
88 jid: "{{ long_command.ansible_job_id }}" 42 jid: "{{ clever_deploy.ansible_job_id }}"
89 register: job_result 43 register: job_result
90 until: job_result.finished 44 until: job_result.finished
91 ignore_errors: true 45 ignore_errors: true
92 delay: 30 46 delay: 30
93 retries: 80 # 40 minutes (80 * 30 secs delay) 47 retries: 80 # 40 minutes (80 * 30 secs delay)
94 48
95- name: Waiting script logs (stdout) 49##################################################################
50# Re-deploy only if its the first clever deploy for that project #
51##################################################################
52
53- name: Retry deploy to clever-cloud
54 include_tasks: redeploy.yml
55 when:
56 - not job_result.rc == 0
57 - job_result.stderr is defined
58 - job_result.stderr is search("Failed to read git object")
59
60- name: Deploy logs (stdout)
96 debug: 61 debug:
97 var: job_result.stdout_lines 62 var: job_result.stdout_lines
98 when: job_result.stdout_lines is defined 63 when: job_result.stdout_lines is defined
99 64
100- name: Waiting script logs (stderr) 65- name: Deploy error logs (stderr)
101 debug: 66 debug:
102 var: job_result.stderr_lines 67 var: job_result.stderr_lines
103 when: job_result.stderr_lines is defined 68 when: job_result.stderr_lines is defined
diff --git a/tasks/redeploy.yml b/tasks/redeploy.yml
new file mode 100644
index 0000000..38068da
--- /dev/null
+++ b/tasks/redeploy.yml
@@ -0,0 +1,33 @@
1---
2##################################################################
3# Re-deploy only if its the first clever deploy for that project #
4##################################################################
5
6- name: First time push to Clever-Cloud needs a full git clone
7 command: "git fetch --unshallow"
8 args:
9 chdir: "{{ clever_app_root }}"
10 tags:
11 - skip_ansible_lint
12
13- name: Deploy to Clever-Cloud
14 shell: "clever deploy --force"
15 args:
16 chdir: "{{ clever_app_root }}"
17 environment:
18 CONFIGURATION_FILE: "{{ clever_login_file }}"
19 async: 2400 # 40 minutes
20 poll: 0
21 ignore_errors: true
22 register: clever_deploy
23 tags:
24 - skip_ansible_lint
25
26- name: Wait up to 40 minutes for deployment completion
27 async_status:
28 jid: "{{ clever_deploy.ansible_job_id }}"
29 register: job_result
30 until: job_result.finished
31 ignore_errors: true
32 delay: 30
33 retries: 80 # 40 minutes (80 * 30 secs delay)
diff --git a/tasks/setup.yml b/tasks/setup.yml
index c5abb81..a2d5b90 100644
--- a/tasks/setup.yml
+++ b/tasks/setup.yml
@@ -17,7 +17,7 @@
17 src: "{{ clever_repo }}/{{ clever_tools_archive }}" 17 src: "{{ clever_repo }}/{{ clever_tools_archive }}"
18 dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}" 18 dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}"
19 vars: 19 vars:
20 clever_repo: https://clever-tools.cellar.services.clever-cloud.com/releases 20 clever_repo: https://clever-tools.clever-cloud.com/releases
21 clever_tools_archive: "{{ clever_cli_version }}/clever-tools-{{ clever_cli_version }}_linux.tar.gz" 21 clever_tools_archive: "{{ clever_cli_version }}/clever-tools-{{ clever_cli_version }}_linux.tar.gz"
22 when: clever_returned_version is failed or clever_returned_version.stdout != clever_cli_version 22 when: clever_returned_version is failed or clever_returned_version.stdout != clever_cli_version
23 23
@@ -27,6 +27,5 @@
27 dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}/{{ item }}" 27 dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}/{{ item }}"
28 mode: 0755 28 mode: 0755
29 with_items: 29 with_items:
30 - clever-wait-deploy.sh
31 - clever-set-domain.sh 30 - clever-set-domain.sh
32 - clever-set-drain.sh 31 - clever-set-drain.sh