vhosts.yml 702 B

123456789101112131415161718192021222324252627
  1. ---
  2. - name: Remove default nginx vhost config file (if configured).
  3. file:
  4. path: "{{ nginx_default_vhost_path }}"
  5. state: absent
  6. when: nginx_remove_default_vhost
  7. notify: restart nginx
  8. - name: Add managed vhost config file (if any vhosts are configured).
  9. template:
  10. src: vhosts.j2
  11. dest: "{{ nginx_vhost_path }}/vhosts.conf"
  12. mode: 0644
  13. when: nginx_vhosts|length > 0
  14. notify:
  15. - validate nginx configuration
  16. - restart nginx
  17. - name: Remove managed vhost config file (if no vhosts are configured).
  18. file:
  19. path: "{{ nginx_vhost_path }}/vhosts.conf"
  20. state: absent
  21. when: nginx_vhosts|length == 0
  22. notify:
  23. - validate nginx configuration
  24. - restart nginx