Hi Team,

I am trying to delete files under a specific directory but not directory. 
Please find the below yaml files.


Playbook.yml
---
- hosts: all
    tasks:
    - name: Ansible remove file
      file:
        path: "{{ item.dest }}"
        state: absent
      with_items:
            - "{{ SAMPLE }}"
            - "{{ SAMPLE_TMP }}" 


vars/main.yml

---

SAMPLE:
- { src: '/tmp/abc.war', dest: '/tmp/test/' }
- { src: '/tmp/def.war', dest: 'tmp/test/' }
- { src: '/tmp/xyz.war', dest: '/tmp/test/' }


SAMPLE_TMP:
- { src: /tmp/test/abc.war, dest: /app/tomcatprofile/abc/webapps/ }
- { src: '/tmp/test/def.war', dest: '/app/tomcatprofile/def/webapps/' }
- { src: '/tmp/test/xyz.war', dest: '/app/tomcatprofile/test/webapps/' }





In the first loop SAMPLE all files under test folder are getting cleared 
but in the second loop...webapps folder itself is getting deleted....Could 
someone please help.



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ab2177f6-c047-4519-85e6-875acb67c8fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to