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

                                  
              
                                                                            


                                                 
                                                     
                               

                                  
              
                                                   



                                                           

                                  

                                                 
                     



                                                                                                        

                       
 

                                                                                                                                                

                                  
                           





                                                              

                                  
       

                                                                    


                       

                                                                                                                                                

                                  
                                 

                       
 
                               


                                  





                                                 
 







                                            
- name: Configure Drain
  when: syslog_server is defined or clever_syslog_server is defined
  command: 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: 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: Push to Clever-Cloud to trigger deployment
  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_git_push
  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_git_push is failed
    - clever_git_push.stderr is search("shallow update not allowed")
  tags:
    - skip_ansible_lint

- name: Push to Clever-Cloud to trigger deployment
  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_git_push is failed
  tags:
    - skip_ansible_lint

- name: Watch deployment status
  command: "clever-wait-deploy.sh"
  args:
    chdir: "{{ clever_app_root }}"
  async: 900
  poll: 0
  register: long_command
  environment:
    CONFIGURATION_FILE: "{{ clever_login_file }}"
  changed_when: False

# Waits up to 15 minutes
- name: Wait for deployment completion
  async_status:
    jid: "{{ long_command.ansible_job_id }}"
  register: job_result
  until: job_result.finished
  delay: 30
  retries: 30