You could shell out to collect the filenames if you still want to use the
Ansible objects to do the deletions (this code assumes your shell is bash):

- shell: ls {{app_home}}/server/deploy/*{token,opm,pf-sm}*.jar
  register: jars_to_cleanup
  ignore_errors: yes

- file: name={{item}} state=absent
  with_items: jars_to_cleanup.stdout_lines

Not sure if that's better or worse than just shelling out for the rm
statement, but it's an option. Perhaps Ansible needs a glob-expansion
function/operator to handle such a case?


On Thu, Apr 3, 2014 at 10:37 AM, James Carroll
<[email protected]>wrote:

> Thanks.  I kind of came to that same conclusion about shelling it out, but
> hoping I was missing something.
>
> James
>
>
> On Wednesday, April 2, 2014 4:33:19 PM UTC-4, Michael DeHaan wrote:
>
>> Nope, the file module doesn't accept shell wildcards, it needs real
>> filenames.
>>
>> I'd shell out to rm in this case, though you won't be able to use the
>> "deletes=" keyword to the shell module to override the "changed value" so
>> it will register as a change every time.
>>
>>
>>
>> On Wed, Apr 2, 2014 at 1:05 PM, James Carroll <[email protected]>wrote:
>>
>>> I'm trying to clear a directory with certain file names based on a
>>> pattern and it doesn't seem to work:
>>>
>>> - name: Remove any extant jars
>>>   file: name="{{app_home}}/server/deploy/{{item}}" state=absent
>>>   with_items:
>>>     - "*token*.jar"
>>>     - "*opm*.jar"
>>>     - "*pf-sm*.jar"
>>>
>>> This isn't working; the existing jars stay there even though Ansible
>>> reports "CHANGED" on all three.
>>>
>>> I need this since these jars have their versions in their names and I
>>> need to make sure that they are deleted prior to pushing the updated files.
>>>
>>> Thanks,
>>>
>>>
>>>
>>> __________________________________________________________________
>>> The information contained in this email message and any attachment may be 
>>> privileged, confidential, proprietary or otherwise protected from 
>>> disclosure. If the reader of this message is not the intended recipient, 
>>> you are hereby notified that any dissemination, distribution, copying or 
>>> use of this message and any attachment is strictly prohibited. If you have 
>>> received this message in error, please notify us immediately by replying to 
>>> the message and permanently delete it from your computer and destroy any 
>>> printout thereof.
>>>
>>>  --
>>> 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/192f125e-8d10-4b6e-8887-
>>> 1b71e7c67db4%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/192f125e-8d10-4b6e-8887-1b71e7c67db4%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
> __________________________________________________________________
> The information contained in this email message and any attachment may be 
> privileged, confidential, proprietary or otherwise protected from disclosure. 
> If the reader of this message is not the intended recipient, you are hereby 
> notified that any dissemination, distribution, copying or use of this message 
> and any attachment is strictly prohibited. If you have received this message 
> in error, please notify us immediately by replying to the message and 
> permanently delete it from your computer and destroy any printout thereof.
>
>  --
> 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/801753f7-4a69-4f7f-b4b5-2607380c40e6%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/801753f7-4a69-4f7f-b4b5-2607380c40e6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAN3s8zZ_q4gKOzNyjAtfVUnzd0FN%2BSdBWpktZ_j89ggy_uYX3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to