---
# Install the nginx virtualhosts
- name: Install the nginx virtualhosts
  template: src={{ item.servername }}-virtualhost.j2 dest=/etc/nginx/sites-available/{{ item.servername }} owner=root group=root mode=0444
  with_items: '{{ tomcat_m_instances }}'
  when: not smartgears_install_generic_virthost
  notify: Reload nginx
  tags: [ 'nginx', 'virtualhost' ]

- name: Install the nginx smartexecutor virtualhost
  template: src=generic-smartgears-virtualhost.j2 dest=/etc/nginx/sites-available/{{ item.servername }} owner=root group=root mode=0444
  with_items: '{{ tomcat_m_instances }}'
  when: smartgears_install_generic_virthost
  notify: Reload nginx
  tags: [ 'nginx', 'virtualhost' ]

- name: Enable the nginx virtualhosts
  file: src=/etc/nginx/sites-available/{{ item.servername }} dest=/etc/nginx/sites-enabled/{{ item.servername }}.conf state=link
  with_items: '{{ tomcat_m_instances }}'
  notify: Reload nginx
  tags: [ 'nginx', 'virtualhost' ]