-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from paulrbr-fl/upgrade-clever-cli
deploy: remove custom polling script now that the CLI does it for us
- Loading branch information
Showing
6 changed files
with
56 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,80 +24,45 @@ | |
CONFIGURATION_FILE: "{{ clever_login_file }}" | ||
changed_when: false | ||
|
||
#TODO: Improve ssh-key validation | ||
- name: Accept Clever-Cloud servers | ||
shell: "ssh-keyscan -H push-par-clevercloud-customers.services.clever-cloud.com >> ~/.ssh/known_hosts" | ||
tags: | ||
- skip_ansible_lint | ||
|
||
- name: Deploy to Clever-Cloud | ||
command: "git push --force git+ssh://[email protected]/{{ clever_app }}.git HEAD:refs/heads/master" | ||
args: | ||
chdir: "{{ clever_app_root }}" | ||
register: clever_deploy | ||
ignore_errors: true | ||
tags: | ||
- skip_ansible_lint | ||
|
||
################################################################## | ||
# Re-deploy only if its the first clever deploy for that project # | ||
################################################################## | ||
|
||
- name: First time push to Clever-Cloud needs a full git clone | ||
command: "git fetch --unshallow" | ||
args: | ||
chdir: "{{ clever_app_root }}" | ||
when: | ||
- clever_deploy is failed | ||
- clever_deploy.stderr is defined | ||
- clever_deploy.stderr is search("Failed to read git object") | ||
tags: | ||
- skip_ansible_lint | ||
|
||
- name: Deploy to Clever-Cloud | ||
command: "git push --force git+ssh://[email protected]/{{ clever_app }}.git HEAD:refs/heads/master" | ||
args: | ||
chdir: "{{ clever_app_root }}" | ||
when: | ||
- clever_deploy is failed | ||
- clever_deploy.stderr is defined | ||
- clever_deploy.stderr is search("Failed to read git object") | ||
register: clever_deploy | ||
tags: | ||
- skip_ansible_lint | ||
|
||
############################################################################## | ||
# Poll deployment status from 'clever activity' command. # | ||
# 'clever deploy' command is not yet 100% reliable to get a blocking command # | ||
# until the deployment is over. Hence the need for a custom waiting script. # | ||
############################################################################## | ||
|
||
- name: Watch deployment status | ||
command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-wait-deploy.sh" | ||
shell: "clever deploy --force" | ||
args: | ||
chdir: "{{ clever_app_root }}" | ||
environment: | ||
CONFIGURATION_FILE: "{{ clever_login_file }}" | ||
async: 2400 # 40 minutes | ||
poll: 0 | ||
register: long_command | ||
changed_when: False | ||
ignore_errors: true | ||
register: clever_deploy | ||
tags: | ||
- skip_ansible_lint | ||
|
||
- name: Wait 40 minutes for deployment completion | ||
- name: Wait up to 40 minutes for deployment completion | ||
async_status: | ||
jid: "{{ long_command.ansible_job_id }}" | ||
jid: "{{ clever_deploy.ansible_job_id }}" | ||
register: job_result | ||
until: job_result.finished | ||
ignore_errors: true | ||
delay: 30 | ||
retries: 80 # 40 minutes (80 * 30 secs delay) | ||
|
||
- name: Waiting script logs (stdout) | ||
################################################################## | ||
# Re-deploy only if its the first clever deploy for that project # | ||
################################################################## | ||
|
||
- name: Retry deploy to clever-cloud | ||
include_tasks: redeploy.yml | ||
when: | ||
- not job_result.rc == 0 | ||
- job_result.stderr is defined | ||
- job_result.stderr is search("Failed to read git object") | ||
|
||
- name: Deploy logs (stdout) | ||
debug: | ||
var: job_result.stdout_lines | ||
when: job_result.stdout_lines is defined | ||
|
||
- name: Waiting script logs (stderr) | ||
- name: Deploy error logs (stderr) | ||
debug: | ||
var: job_result.stderr_lines | ||
when: job_result.stderr_lines is defined | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
################################################################## | ||
# Re-deploy only if its the first clever deploy for that project # | ||
################################################################## | ||
|
||
- name: First time push to Clever-Cloud needs a full git clone | ||
command: "git fetch --unshallow" | ||
args: | ||
chdir: "{{ clever_app_root }}" | ||
tags: | ||
- skip_ansible_lint | ||
|
||
- name: Deploy to Clever-Cloud | ||
shell: "clever deploy --force" | ||
args: | ||
chdir: "{{ clever_app_root }}" | ||
environment: | ||
CONFIGURATION_FILE: "{{ clever_login_file }}" | ||
async: 2400 # 40 minutes | ||
poll: 0 | ||
ignore_errors: true | ||
register: clever_deploy | ||
tags: | ||
- skip_ansible_lint | ||
|
||
- name: Wait up to 40 minutes for deployment completion | ||
async_status: | ||
jid: "{{ clever_deploy.ansible_job_id }}" | ||
register: job_result | ||
until: job_result.finished | ||
ignore_errors: true | ||
delay: 30 | ||
retries: 80 # 40 minutes (80 * 30 secs delay) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters