--- ### tags: ### update_deployment - name: "Send mattermost message" uri: url: "{{ mattermost_hook_smardigo }}" method: POST body: "{{ lookup('template','mattermost-deploy-start.json.j2') }}" body_format: json headers: Content-Type: "application/json" delegate_to: 127.0.0.1 become: false when: - send_status_messages - name: Gather current server infos hcloud_server_info: api_token: "{{ hetzner_authentication_token }}" register: hetzner_server_infos delegate_to: 127.0.0.1 become: false - name: Save current server infos as variable (fact) set_fact: hetzner_server_infos_json: "{{ hetzner_server_infos.hcloud_server_info }}" delegate_to: 127.0.0.1 become: false - name: Read ip for {{ inventory_hostname }} set_fact: stage_server_ip: "{{ item.ipv4_address }}" when: item.name == inventory_hostname with_items: "{{ hetzner_server_infos_json }}" delegate_to: 127.0.0.1 become: false - name: "Setup DNS configuration for {{ service_name }}" include_role: name: _digitalocean tasks_from: domain vars: record_data: "{{ stage_server_ip }}" record_name: "{{ service_name }}" - name: "Setup public DNS configuration for {{ service_name }}" include_role: name: _digitalocean tasks_from: domain vars: record_data: "{{ item.ip }}" record_name: "{{ item.name }}" loop: "{{ docker_registry_public_dns_entries }}" when: docker_registry_public_dns_entries is defined - name: "Check docker networks" include_role: name: _docker tasks_from: networks - name: "Check if {{ service_name }}/docker-compose.yml exists" stat: path: '{{ service_base_path }}/{{ service_name }}/docker-compose.yml' register: check_docker_compose_file tags: - update_deployment - name: "Stop {{ service_name }}" shell: docker-compose down args: chdir: '{{ service_base_path }}/{{ service_name }}' when: check_docker_compose_file.stat.exists ignore_errors: yes tags: - update_deployment - name: "Deploy service configuration for {{ service_name }}" include_role: name: _deploy tasks_from: configs vars: current_config: "docker-registry" current_base_path: "{{ service_base_path }}" current_destination: "{{ service_name }}" current_owner: "{{ docker_owner }}" current_group: "{{ docker_group }}" current_docker: "{{ docker_registry_docker }}" - name: "Update {{ service_name }}" shell: docker-compose pull args: chdir: '{{ service_base_path }}/{{ service_name }}' tags: - update_deployment - name: "Start {{ service_name }}" shell: docker-compose up -d args: chdir: '{{ service_base_path }}/{{ service_name }}' tags: - update_deployment - name: "Update landing page entries for {{ service_name }}" include_role: name: _deploy tasks_from: caddy_landing_page vars: current_services: [ { current_name: "{{ service_name }}", current_url: "{{ http_s }}://{{ service_url }}", current_version: "{{ docker_registry_image_version }}", current_date: "{{ ansible_date_time.iso8601 }}", management: "{{ http_s }}://{{ service_url }}:{{ monitor_port_service }}/management", }, ] tags: - update_deployment - name: "Update landing page with public entries {{ service_name }}" include_role: name: _deploy tasks_from: caddy_landing_page vars: current_services: [ { current_name: "{{ item.name }}", current_url: "{{ http_s }}://{{ item.name }}.{{ domain }}", current_version: "{{ docker_registry_image_version }}", current_date: "{{ ansible_date_time.iso8601 }}", management: "{{ http_s }}://{{ service_url }}:{{ monitor_port_service }}/management", }, ] loop: "{{ docker_registry_public_dns_entries }}" when: docker_registry_public_dns_entries is defined tags: - update_deployment - name: "Update landing page with extra entries for {{ service_name }}" include_role: name: _deploy tasks_from: caddy_landing_page vars: current_services: [ { current_name: "{{ item.name }}", current_url: "{{ item.domain }}", current_version: "{{ docker_registry_image_version }}", current_date: "{{ ansible_date_time.iso8601 }}", management: "{{ http_s }}://{{ service_url }}:{{ monitor_port_service }}/management", }, ] loop: "{{ docker_registry_extra_domain_entries }}" when: docker_registry_extra_domain_entries is defined tags: - update_deployment - name: "Send mattermost messsge" uri: url: "{{ mattermost_hook_smardigo }}" method: POST body: "{{ lookup('template','mattermost-deploy-end.json.j2') }}" body_format: json headers: Content-Type: "application/json" delegate_to: 127.0.0.1 become: false when: - send_status_messages