You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hetzner-ansible/roles/nginx/tasks/main.yml

67 lines
1.8 KiB
YAML

- name: "Setup DNS configuration for {{ inventory_hostname }}"
include_role:
name: hetzner-ansible-dns
vars:
record_data: "{{ stage_server_ip }}"
record_name: "{{ inventory_hostname }}"
- name: Create a directory dist if it does not exist
ansible.builtin.file:
path: "{{ service_base_path }}/{{ inventory_hostname }}/dist"
state: directory
mode: '0777'
- name: Create a directory conf if it does not exist
ansible.builtin.file:
path: "{{ service_base_path }}/{{ inventory_hostname }}/conf"
state: directory
mode: '0755'
- name: "Providing nginx.conf"
become: yes
copy:
src: '{{ item }}'
dest: '{{ service_base_path }}/{{ inventory_hostname }}/conf'
mode: '0755'
with_items:
- nginx.conf
- name: "Check if {{ inventory_hostname }}/docker-compose.yml exists"
stat:
path: '{{ service_base_path }}/{{ inventory_hostname }}/docker-compose.yml'
register: check_docker_compose_file
tags:
- update_deployment
- name: "Stop {{ inventory_hostname }}"
community.docker.docker_compose:
project_src: '{{ service_base_path }}/{{ inventory_hostname }}'
state: absent
when: check_docker_compose_file.stat.exists
tags:
- update_deployment
- name: "Deploy docker templates for {{ inventory_hostname }}"
include_role:
name: hetzner-ansible-sma-deploy
tasks_from: templates
vars:
current_config: "_docker"
current_base_path: "{{ service_base_path }}"
current_destination: "{{ inventory_hostname }}"
current_owner: "{{ docker_owner }}"
current_group: "{{ docker_group }}"
current_docker: "{{ nginx_docker }}"
tags:
- update_deployment
- name: "Start {{ inventory_hostname }}"
community.docker.docker_compose:
project_src: '{{ service_base_path }}/{{ inventory_hostname }}'
state: present
pull: yes
tags:
- update_deployment