---
- name: Copy php-fpm evoadmin-mail pool
  ansible.builtin.copy:
    src: pool.evoadmin-mail.conf
    dest: /etc/php/7.0/fpm/pool.d/evoadmin-mail.conf
  notify: reload php-fpm
  tags:
    - evoadmin-mail

- name: Install evoadminmail VHost
  ansible.builtin.template:
    src: nginx_evoadminmail.conf.j2
    dest: /etc/nginx/sites-available/evoadminmail.conf
  notify: reload nginx
  tags:
    - evoadmin-mail

- name: Active evoadminmail VHost
  ansible.builtin.file:
    src: "/etc/nginx/sites-available/evoadminmail.conf"
    dest: "/etc/nginx/sites-enabled/evoadminmail.conf"
    state: link
  notify: reload nginx
  when: evoadminmail_enable_vhost | bool
  tags:
    - evoadmin-mail

- name: Disable evoadminmail vhost
  ansible.builtin.file:
    dest: "/etc/nginx/sites-enabled/evoadminmail.conf"
    state: absent
  notify: reload nginx
  when: not (evoadminmail_enable_vhost | bool)
  tags:
    - evoadmin-mail
