blob: d5e5a4555fe6e9515dcd4b01a758d1cb92701b99 (
plain) (
tree)
|
|
- name: Configure Drain
when: syslog_server is defined or clever_syslog_server is defined
command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-set-drain.sh"
args:
chdir: "{{ clever_app_root }}"
environment:
SYSLOG_UDP_SERVER: "{{ clever_syslog_server | default(syslog_server) }}"
CONFIGURATION_FILE: "{{ clever_login_file }}"
- name: Configure Domain
when: domain is defined or clever_domain is defined
command: "{{ ansible_env.HOME }}/{{ clever_user_path }}/clever-set-domain.sh"
args:
chdir: "{{ clever_app_root }}"
environment:
DOMAIN: "{{ clever_domain | default(domain) }}"
CONFIGURATION_FILE: "{{ clever_login_file }}"
- name: Push Environment
shell: "clever env import < {{ clever_app_confdir }}/env"
args:
chdir: "{{ clever_app_root }}"
environment:
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://git@push-par-clevercloud-customers.services.clever-cloud.com/{{ 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://git@push-par-clevercloud-customers.services.clever-cloud.com/{{ 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"
args:
chdir: "{{ clever_app_root }}"
environment:
CONFIGURATION_FILE: "{{ clever_login_file }}"
async: 2400 # 40 minutes
poll: 0
register: long_command
changed_when: False
- name: Wait 40 minutes for deployment completion
async_status:
jid: "{{ long_command.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)
debug:
var: job_result.stdout_lines
when: job_result.stdout_lines is defined
- name: Waiting script logs (stderr)
debug:
var: job_result.stderr_lines
when: job_result.stderr_lines is defined
- name: Fail in case of timeout or failure
fail:
msg: "Deployment failed. Please check logs above."
when: not job_result.finished or not job_result.rc == 0
|