Looks relevant:

http://www.mydailytutorials.com/ansible-delete-multiple-files-directories-ansible/

Search in the page for "A better option" to find the right stuff.

I haven't tested the techniques myself, though.

Regards, K.


On Wed, Dec 19, 2018 at 9:24 PM Dick Visser <[email protected]> wrote:

> The only really reliable way to do this I found is to first register the
> actual files, filter them and then delete them
>
> On Wed, 19 Dec 2018 at 11:13, <[email protected]> wrote:
>
>> Thank you for your quick response. May I know how to delete all files
>> under a specific directory.
>>
>> I tried by giving star it is working fine by deleting all files under
>> directory but while copying files it is copying by * name.
>>
>>
>>
>>
>> On Wednesday, December 19, 2018 at 3:26:51 PM UTC+5:30, Dick Visser wrote:
>>>
>>> This is expected as the ‘dest’ Parameter that you want to be absent is
>>> the webapps directory
>>>
>>> I.E. it gets deleted
>>>
>>> On Wed, 19 Dec 2018 at 08:14, <[email protected]> wrote:
>>>
>> 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
>>>> <https://groups.google.com/d/msgid/ansible-project/ab2177f6-c047-4519-85e6-875acb67c8fc%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> Sent from a mobile device - please excuse the brevity, spelling and
>>> punctuation.
>>>
>> --
>> 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/83b659ce-4a97-48e7-b604-1b827e2d7f03%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/83b659ce-4a97-48e7-b604-1b827e2d7f03%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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/CAL8fbwOtWGO3KwTvF7DMk37b83r%2BC8%3DsV_EezT%2Bg%3DYyZr8JtOQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAL8fbwOtWGO3KwTvF7DMk37b83r%2BC8%3DsV_EezT%2Bg%3DYyZr8JtOQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : [email protected]
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
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/CA%2B%2BT08Sb7rt539ng1p40mGJa%2B21jE2o%3D%3DGe5Oiz4ye6LLpxVkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to