--- - name: Remove default nginx vhost config file (if configured) file: path: "{{ nginx_default_vhost_path }}" state: absent when: - nginx_remove_default_vhost | bool - nginx_create_catchall_vhost | default(true) notify: restart nginx - name: Ensure nginx_vhost_path exists file: path: "{{ nginx_vhost_path }}" state: directory notify: reload nginx - include_tasks: catchall-vhost.yml when: nginx_create_catchall_vhost | default(true) | bool - name: Add managed vhost config files template: src: "{{ item.template }}" dest: "{{ nginx_vhost_path }}/{{ item.filename }}" force: true owner: root group: "{{ root_group }}" lstrip_blocks: yes backup: yes mode: 0644 when: item.state | default('present') != 'absent' with_items: "{{ nginx_vhosts }}" notify: reload nginx tags: - skip_ansible_lint - nginx_site_vhost - nginx_vhost - name: Remove managed vhost config files file: path: "{{ nginx_vhost_path }}/{{ item.filename }}.conf" state: absent when: item.state|default('present') == 'absent' with_items: "{{ nginx_vhosts }}" notify: reload nginx tags: - skip_ansible_lint - name: Remove legacy vhosts.conf file file: path: "{{ nginx_vhost_path }}/vhosts.conf" state: absent notify: reload nginx