vhosts.yml 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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: Ensure nginx_vhost_path exists.
  9. file:
  10. path: "{{ nginx_vhost_path }}"
  11. state: directory
  12. notify: reload nginx
  13. - name: Add managed vhost config files.
  14. template:
  15. src: vhost.j2
  16. dest: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf"
  17. force: yes
  18. owner: root
  19. group: root
  20. mode: 0644
  21. when: item.state|default('present') != 'absent'
  22. with_items: "{{ nginx_vhosts }}"
  23. notify: reload nginx
  24. - name: Remove managed vhost config files.
  25. file:
  26. path: "{{ nginx_vhost_path }}/{{ item.server_name.split(' ')[0] }}.conf"
  27. state: absent
  28. when: item.state|default('present') == 'absent'
  29. with_items: "{{ nginx_vhosts }}"
  30. notify: reload nginx
  31. - name: Remove legacy vhosts.conf file.
  32. file:
  33. path: "{{ nginx_vhost_path }}/vhosts.conf"
  34. state: absent
  35. notify: reload nginx