aboutsummaryrefslogblamecommitdiffhomepage
path: root/tasks/deploy.yml
blob: cc150502698f195631354a890c18be0716295ef7 (plain) (tree)
1
2
3
4
5
6
7
8
9
                       
                                                                   

                              
                                                                            


                                                 
                                                     

                               
                                                   





                                                           
                     



                                                                                                        

                       
 

                              

                                  




                                                 





                                                              

                                  
       

                                                                 


                       

                              

                                  






                                                 

                       
 







                                
 
                                 

                                                                 
                               
- name: Configure Drain
  when: syslog_server is defined or clever_syslog_server is defined
  command: clever-set-drain.sh
  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: clever-set-domain.sh
  environment:
    DOMAIN: "{{ clever_domain | default(domain) }}"
    CONFIGURATION_FILE: "{{ clever_login_file }}"

- name: Push Environment
  shell: "clever env import < {{ clever_app_confdir }}/env"
  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
  shell: "clever deploy"
  args:
    chdir: "{{ clever_app_root }}"
  environment:
    CONFIGURATION_FILE: "{{ clever_login_file }}"
  register: clever_deploy
  async: 900 # 15 minutes timeout
  poll: 30
  ignore_errors: true
  tags:
    - skip_ansible_lint

- 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 search("Failed to read git object")
  tags:
    - skip_ansible_lint

- name: Deploy to Clever-Cloud
  shell: "clever deploy"
  args:
    chdir: "{{ clever_app_root }}"
  environment:
    CONFIGURATION_FILE: "{{ clever_login_file }}"
  when: clever_deploy is failed
  register: clever_deploy
  async: 900 # 15 minutes timeout
  poll: 30
  ignore_errors: true
  tags:
    - skip_ansible_lint

- name: Return deployment logs
  debug:
    var: clever_deploy.stdout

- name: Return deployment errors
  debug:
    var: clever_deploy.stderr
  when: clever_deploy is failed

- name: Fail on deployment errors
  fail:
    msg: "The clever deployment failed! Please check logs above."
  when: clever_deploy is failed