---
# tasks file for nginx
- name: Install the packages
  apt: name={{ item }} state=present update_cache=yes
  with_items: nginx_packages
  when: ansible_os_family == "Debian"
  tags: [packages, nginx]

- name: ensure nginx service is up
  action: service name=nginx state=started
  tags: [nginx]

- name: make sure that there is no default website
  file: path={{ NGINX_SITES_ENABLED_CONFIG_PATH }}/default state=absent
  tags: [nginx]

- name: installing website config {{ name }}
  template: src=site.j2 dest={{ NGINX_SITES_AVAILABLE_CONFIG_PATH }}/{{ name }}.conf
  tags: [nginx]

- name: create a symlink for website {{ name }}
  file: src={{ NGINX_SITES_AVAILABLE_CONFIG_PATH }}/{{ name }}.conf dest={{ NGINX_SITES_ENABLED_CONFIG_PATH }}/{{ name }} state=link
  # also a handler named restart nginx is present if needed
  notify:
  - reload nginx
  tags: [nginx]
---
# tasks file for nginx
- name: Install the packages
  apt: name={{ item }} state=present update_cache=yes
  with_items: nginx_packages
  when: ansible_os_family == "Debian"
  tags: [packages, nginx]

- name: ensure nginx service is up
  action: service name=nginx state=started
  tags: [nginx]

- name: make sure that there is no default website
  file: path={{ NGINX_SITES_ENABLED_CONFIG_PATH }}/default state=absent
  notify:
  - reload nginx
  tags: [nginx]

- name: installing website config {{ name }}
  template: src=site.j2 dest={{ NGINX_SITES_AVAILABLE_CONFIG_PATH }}/{{ name }}.conf
  tags: [nginx]

- name: create a symlink for website {{ name }}
  file: src={{ NGINX_SITES_AVAILABLE_CONFIG_PATH }}/{{ name }}.conf dest={{ NGINX_SITES_ENABLED_CONFIG_PATH }}/{{ name }} state=link
  # also a handler named restart nginx is present if needed
  notify:
  - reload nginx
  tags: [nginx]
Add the reload when the site is removed.
Add the reload when the site is removed.
