normally I am at the 'do I feel dumb' side of the conversation.
So it's really great whether for once I can help someone else out.
 
 

> On 07/05/2023 1:35 PM CEST Kathy L <[email protected]> wrote:
>  
>  
> Oh boy, do I feel dumb.  I should know that - I was making the problem harder 
> than it has to be.  Thank you!
> 
> On Wednesday, July 5, 2023 at 7:27:15 AM UTC-4 [email protected] wrote:
> 
> > hi,
> >  
> > you want to delete those files, if they exist, right?
> >  
> >   - name: delete file, if it exists
> >     ansible.builtin.file:
> >       state: absent
> >       path: "/work/{{ item }}"
> >     loop:
> >       - file1
> >       - file2
> >       - file3
> >       - file4
> >       - file5
> >       - file6
> >  
> > - all loop items will be set into the disired state (absent).
> > - If that state is reached (file is 'absent') Ansible is happy and won't do 
> > anything.
> > - If that state is not reached (file is not 'absent') Ansible will make 
> > sure the state is there (aka remove the file)
> >  
> > If you want to define those files elsewehere then in the playbook itself 
> > you can also create a variable and then just put the variable in the path 
> > line (where now {{ item }} is set
> >  
> >       path: "/work/{{ file_to remove }}"
> >  
> >  
> > 
> > > On 07/05/2023 12:59 PM CEST Kathy L <[email protected]> wrote:
> > >  
> > >  
> > > I have a list of 6 files; if any of them exist already, I need to delete 
> > > it. If none of them exist just keep going.  What I have below is giving 
> > > me errors that 'tmp_files.stat.exists is false'.  Here is what I have:
> > > 
> > > - name: Check to see if one file exists already
> > >   stat:
> > >     path: "/work/{{ item }}"
> > >   loop:  "{{ possible_file_names }}"
> > >   register: tmp_files
> > >  
> > > - debug:
> > >     msg: "file exists"
> > >   when: tmp-file.exists
> > >  
> > > How do I "stop" the loop when a file exists?  And if it doesn't, keep 
> > > going through the loop?
> > > 
> > 
> >  
> > 
> 
>  
> 
> --
> 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] 
> mailto:[email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/23aa11ee-7874-48a9-9053-aa89dbe9f3a4n%40googlegroups.com
>  
> https://groups.google.com/d/msgid/ansible-project/23aa11ee-7874-48a9-9053-aa89dbe9f3a4n%40googlegroups.com?utm_medium=email&utm_source=footer.
> 
 
---

gunnar wagner | fichtestr. 1, 19386 lübz | fon: 0176 7808 9090

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/795300010.842463.1688561176220%40office.mailbox.org.

Reply via email to