- name: "Remove all directories" file: path: "/var/www/{{ item.git_name }}" state: absent when: "item.git_name is defined and project_name is not defined and conf_name is not defined" with_items: - "{{ project }}" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - name: "Remove single directory" file: path: "/var/www/{{ project_name }}" state: absent when: "project_name is defined" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - name: "Delete all symlink" file: path: "/etc/nginx/sites-enabled/{{ item.conf_name }}" state: absent when: "item.conf_name is defined and project_name is not defined and conf_name is not defined" with_items: - "{{ project }}" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - name: "remove all configure nginx" file: path: "/etc/nginx/sites-available/{{ item.conf_name }}" state: absent when: "item.conf_name is defined and project_name is not defined and conf_name is not defined" with_items: - "{{ project }}" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - name: "Delete single symlink" file: path: "/etc/nginx/sites-enabled/{{ conf_name }}" state: absent when: "conf_name is defined" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - name: "remove single configure nginx" file: path: "/etc/nginx/sites-available/{{ conf_name }}" state: absent when: "conf_name is defined" vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}" - name: restart nginx service: name: nginx state: restarted vars: ansible_become: yes ansible_become_method: sudo ansible_become_password: "{{ sudo_password }}"