diff options
author | Paul Bonaud <paul.bonaud@fretlink.com> | 2018-11-21 13:20:56 +0100 |
---|---|---|
committer | Paul Bonaud <paul.bonaud@fretlink.com> | 2018-11-21 13:23:36 +0100 |
commit | 8fa0dde4720de58a268af5d0ce8818e7da236655 (patch) | |
tree | 7b4a32db2941b920142b40946f98a3dab2e2c144 /tasks | |
parent | 5485dbc4db3e141673457475bcda5fc88057739f (diff) | |
download | ansible-clever-8fa0dde4720de58a268af5d0ce8818e7da236655.tar.gz ansible-clever-8fa0dde4720de58a268af5d0ce8818e7da236655.tar.zst ansible-clever-8fa0dde4720de58a268af5d0ce8818e7da236655.zip |
deploy_task: Update clever CLI tools and use it instead of git push
Updating to latest version of 1.1.1 helps to have a stable `clever
deploy` command.
This commit relies on the output of the command instead of manually
pooling the results with `clever activity` command.
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/deploy.yml | 53 | ||||
-rw-r--r-- | tasks/setup.yml | 1 |
2 files changed, 29 insertions, 25 deletions
diff --git a/tasks/deploy.yml b/tasks/deploy.yml index 84ebe73..10c02c4 100644 --- a/tasks/deploy.yml +++ b/tasks/deploy.yml | |||
@@ -24,11 +24,15 @@ | |||
24 | tags: | 24 | tags: |
25 | - skip_ansible_lint | 25 | - skip_ansible_lint |
26 | 26 | ||
27 | - name: Push to Clever-Cloud to trigger deployment | 27 | - name: Deploy to Clever-Cloud |
28 | 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" |
29 | args: | 29 | args: |
30 | chdir: "{{ clever_app_root }}" | 30 | chdir: "{{ clever_app_root }}" |
31 | register: clever_git_push | 31 | environment: |
32 | CONFIGURATION_FILE: "{{ clever_login_file }}" | ||
33 | register: clever_deploy | ||
34 | async: 900 # 15 minutes timeout | ||
35 | poll: 30 | ||
32 | ignore_errors: true | 36 | ignore_errors: true |
33 | tags: | 37 | tags: |
34 | - skip_ansible_lint | 38 | - skip_ansible_lint |
@@ -38,33 +42,34 @@ | |||
38 | args: | 42 | args: |
39 | chdir: "{{ clever_app_root }}" | 43 | chdir: "{{ clever_app_root }}" |
40 | when: | 44 | when: |
41 | - clever_git_push is failed | 45 | - clever_deploy is failed |
42 | - clever_git_push.stderr is search("shallow update not allowed") | 46 | - clever_deploy.stderr is search("Failed to read git object") |
43 | tags: | 47 | tags: |
44 | - skip_ansible_lint | 48 | - skip_ansible_lint |
45 | 49 | ||
46 | - name: Push to Clever-Cloud to trigger deployment | 50 | - name: Deploy to Clever-Cloud |
47 | command: "git push --force git+ssh://git@push-par-clevercloud-customers.services.clever-cloud.com/{{ clever_app }}.git HEAD:refs/heads/master" | 51 | shell: "clever deploy" |
48 | args: | 52 | args: |
49 | chdir: "{{ clever_app_root }}" | 53 | chdir: "{{ clever_app_root }}" |
50 | when: clever_git_push is failed | 54 | environment: |
55 | CONFIGURATION_FILE: "{{ clever_login_file }}" | ||
56 | when: clever_deploy is failed | ||
57 | register: clever_deploy | ||
58 | async: 900 # 15 minutes timeout | ||
59 | poll: 30 | ||
60 | ignore_errors: true | ||
51 | tags: | 61 | tags: |
52 | - skip_ansible_lint | 62 | - skip_ansible_lint |
53 | 63 | ||
54 | - name: Watch deployment status | 64 | - name: Return deployment logs |
55 | command: "clever-wait-deploy.sh '{{ clever_app_root }}'" | 65 | debug: |
56 | async: 900 | 66 | var: clever_deploy.stdout |
57 | poll: 0 | 67 | |
58 | register: long_command | 68 | - name: Return deployment errors |
59 | environment: | 69 | debug: |
60 | CONFIGURATION_FILE: "{{ clever_login_file }}" | 70 | var: clever_deploy.stderr |
61 | changed_when: False | 71 | when: clever_deploy is failed |
62 | 72 | ||
63 | # Waits up to 15 minutes | 73 | - name: Fail on deployment errors |
64 | - name: Wait for deployment completion | 74 | fail: "The clever deployment failed! Please check logs above." |
65 | async_status: | 75 | when: clever_deploy is failed |
66 | jid: "{{ long_command.ansible_job_id }}" | ||
67 | register: job_result | ||
68 | until: job_result.finished | ||
69 | delay: 30 | ||
70 | retries: 30 | ||
diff --git a/tasks/setup.yml b/tasks/setup.yml index f85a635..33b1ff6 100644 --- a/tasks/setup.yml +++ b/tasks/setup.yml | |||
@@ -26,4 +26,3 @@ | |||
26 | with_items: | 26 | with_items: |
27 | - clever-set-domain.sh | 27 | - clever-set-domain.sh |
28 | - clever-set-drain.sh | 28 | - clever-set-drain.sh |
29 | - clever-wait-deploy.sh | ||