]>
Commit | Line | Data |
---|---|---|
f7dd5848 | 1 | - name: Configure Drain |
23c0fc8a | 2 | when: syslog_server is defined or clever_syslog_server is defined |
51b4b3fd | 3 | command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-set-drain.sh" |
1dc8c620 PB |
4 | args: |
5 | chdir: "{{ clever_app_root }}" | |
f7dd5848 | 6 | environment: |
23c0fc8a | 7 | SYSLOG_UDP_SERVER: "{{ clever_syslog_server | default(syslog_server) }}" |
f7dd5848 GD |
8 | CONFIGURATION_FILE: "{{ clever_login_file }}" |
9 | ||
10 | - name: Configure Domain | |
1157a45f | 11 | when: domain is defined or clever_domain is defined |
fee73e81 | 12 | command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-set-domain.sh" |
1dc8c620 PB |
13 | args: |
14 | chdir: "{{ clever_app_root }}" | |
f7dd5848 | 15 | environment: |
1157a45f | 16 | DOMAIN: "{{ clever_domain | default(domain) }}" |
f7dd5848 GD |
17 | CONFIGURATION_FILE: "{{ clever_login_file }}" |
18 | ||
1c139365 CD |
19 | - name: Configure Build Instance |
20 | when: clever_build_flavor is defined | |
b1536bd4 | 21 | command: "clever scale --build-flavor {{ clever_build_flavor }}" |
1c139365 CD |
22 | args: |
23 | chdir: "{{ clever_app_root }}" | |
24 | environment: | |
1c139365 CD |
25 | CONFIGURATION_FILE: "{{ clever_login_file }}" |
26 | ||
96f02eb1 CD |
27 | - name: Configure Scalability |
28 | when: clever_scaling is defined | |
29 | command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-set-scalability.sh" | |
30 | args: | |
31 | chdir: "{{ clever_app_root }}" | |
32 | environment: | |
33 | CONFIGURATION_FILE: "{{ clever_login_file }}" | |
34 | INSTANCES: "{{ clever_scaling.instances.fixed | default ('') }}" | |
35 | MIN_INSTANCES: "{{ clever_scaling.instances.min | default('') }}" | |
36 | MAX_INSTANCES: "{{ clever_scaling.instances.max | default('') }}" | |
37 | FLAVOR: "{{ clever_scaling.flavor.fixed | default('') }}" | |
38 | MIN_FLAVOR: "{{ clever_scaling.flavor.min | default('') }}" | |
39 | MAX_FLAVOR: "{{ clever_scaling.flavor.max | default('') }}" | |
40 | ||
45a5c133 CD |
41 | - name: Configure service dependencies |
42 | include_tasks: service-dep.yml | |
43 | vars: | |
44 | service_dep: "{{ item }}" | |
45 | with_items: "{{ clever_service_dependencies }}" | |
46 | ||
f7dd5848 | 47 | - name: Push Environment |
244339e7 | 48 | shell: "clever env import --json < {{ clever_app_confdir }}/env" |
1dc8c620 PB |
49 | args: |
50 | chdir: "{{ clever_app_root }}" | |
f7dd5848 GD |
51 | environment: |
52 | CONFIGURATION_FILE: "{{ clever_login_file }}" | |
7485b189 | 53 | changed_when: false |
f7dd5848 | 54 | |
c5aed75a | 55 | - name: Deploy to Clever-Cloud |
facc275a | 56 | command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-deploy.sh" |
e9b912b4 PB |
57 | args: |
58 | chdir: "{{ clever_app_root }}" | |
59 | environment: | |
60 | CONFIGURATION_FILE: "{{ clever_login_file }}" | |
32a91c16 | 61 | async: 3600 # 1 hour |
fa045db6 | 62 | poll: 0 |
b89d0540 PB |
63 | ignore_errors: true |
64 | register: clever_deploy | |
65 | tags: | |
66 | - skip_ansible_lint | |
e9b912b4 | 67 | |
32a91c16 | 68 | - name: Wait up to 1 hour for deployment completion |
fa045db6 | 69 | async_status: |
b89d0540 | 70 | jid: "{{ clever_deploy.ansible_job_id }}" |
fa045db6 PB |
71 | register: job_result |
72 | until: job_result.finished | |
5da7f0d8 | 73 | ignore_errors: true |
fa045db6 | 74 | delay: 30 |
32a91c16 | 75 | retries: 120 # 1 hour (120 * 30 secs delay) |
e9b912b4 | 76 | |
b89d0540 PB |
77 | ################################################################## |
78 | # Re-deploy only if its the first clever deploy for that project # | |
79 | ################################################################## | |
80 | ||
81 | - name: Retry deploy to clever-cloud | |
82 | include_tasks: redeploy.yml | |
83 | when: | |
c47b6b55 | 84 | - not job_result.finished or not job_result.rc == 0 |
b89d0540 PB |
85 | - job_result.stderr is defined |
86 | - job_result.stderr is search("Failed to read git object") | |
87 | ||
c3e2ff5e PB |
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 | ||
b89d0540 | 95 | - name: Deploy logs (stdout) |
fa045db6 PB |
96 | debug: |
97 | var: job_result.stdout_lines | |
5da7f0d8 PB |
98 | when: job_result.stdout_lines is defined |
99 | ||
b89d0540 | 100 | - name: Deploy error logs (stderr) |
5da7f0d8 PB |
101 | debug: |
102 | var: job_result.stderr_lines | |
103 | when: job_result.stderr_lines is defined | |
104 | ||
105 | - name: Fail in case of timeout or failure | |
106 | fail: | |
107 | msg: "Deployment failed. Please check logs above." | |
108 | when: not job_result.finished or not job_result.rc == 0 |