---
- name: Ensure Nginx is installed
  apt:
    name:
      - nginx-light
      - ssl-cert
    state: present
  notify: reload nginx
  tags:
  - nginx
  - packages

- name: Copy default vhost
  template:
    src: "{{ nginx_default_template_minimal }}"
    dest: /etc/nginx/sites-available/evolinux-default.minimal.conf
    mode: 0644
    force: "{{ nginx_force_default_template | default(False) }}"
  notify: reload nginx
  tags:
  - nginx
  - packages

- name: Enable default vhost
  file:
    src: /etc/nginx/sites-available/evolinux-default.minimal.conf
    dest: /etc/nginx/sites-enabled/default
    state: link
  notify: reload nginx
  tags:
  - nginx
  - packages

- name: Ensure Nginx is enabled
  service:
    name: nginx
    state: started
    enabled: yes
  tags:
  - nginx
