frontend-slave-instance.yml 1.6 KB
---

   # get ERP5 URL will fail if erp5 instance is not ready
 - name: Get ERP5 backend URL
   shell: "{{ role_path }}/files/kdbox-param '{{ webrunner_instance_name }}' url"
   register: erp5_url

 - stat: path="/opt/kdbox/dehydrated/certs/{{ custom_domain }}"
   register: cert_folder

 - name : requesting CDN slave instance for ERP5
   shell: echo "request('{{ frontend_software_release_url }}', '{{ custom_domain }}-slave',filter_kw={'computer_guid':'{{ computer_id }}'},partition_parameter_kw={'custom_domain':'{{ custom_domain }}','enable_cache':'true','type':'zope','url':'{{ erp5_url.stdout }}', 'path':'erp5/',},shared=True, software_type='custom-personal',)" | slapos console 
   when: cert_folder.stat.exists == False
   register: request_slave
   failed_when: "'error' in request_slave.stdout"

 - template: src=request-slave-frontend.j2 dest=/opt/kdbox/request_slave_frontend.py mode=644
   vars:
     ssl_key_content: "{{ lookup('file', '/opt/kdbox/dehydrated/certs/{{ custom_domain }}/privkey.pem') }}" 
     ssl_crt_content: "{{ lookup('file', '/opt/kdbox/dehydrated/certs/{{ custom_domain }}/cert.pem') }}"
     ssl_ca_crt_content: "{{ lookup('file', '/opt/kdbox/dehydrated/certs/{{ custom_domain }}/chain.pem') }}"
   when: cert_folder.stat.exists == True

 - name: Update slave frontend certificate
   shell: "cat /opt/kdbox/request_slave_frontend.py | slapos console"
   register: output
   when: cert_folder.stat.exists == True and kdbox_ok == False
   failed_when: "'error' in output.stderr.lower()"

 - debug: msg="{{ output }}"

 - file: path=/opt/kdbox/kdbox_ok state=touch
   when: cert_folder.stat.exists == True