file.absent for deletion of multiple files in windows

1,351 views
Skip to first unread message

Mosby Simmons

unread,
Aug 19, 2019, 10:04:59 PM8/19/19
to Salt-users
All,

I'm trying to delete multiple files with a salt state and was hoping to use a glob.  I don't want to delete the directory.

Is there a way to do this?

I found this: https://www.openmediavault.org/?p=2211 but this is for unix and similar script doesn't seem to work.

I also found this: https://github.com/saltstack/salt/issues/9183 but didn't really find a solution.

If you have basic syntax I would appreciate it.

Thanks!


Dirk Heinrichs

unread,
Aug 20, 2019, 8:57:17 AM8/20/19
to Salt-users
Am Dienstag, 20. August 2019 04:04:59 UTC+2 schrieb Mosby Simmons:

I'm trying to delete multiple files with a salt state and was hoping to use a glob.  I don't want to delete the directory.

[First try didn't make it to the list, so I'm trying again using web UI.]

I've implemented file.tidied, similar to Puppet's tidy, to do exactly this. It's part of Salt 2019.2.0. If you want it for 2018.3.4, just drop me a note and I'll send you the module.

Bye...

    Dirk
-- Dirk Heinrichs <dirk.he...@altum.de> GPG Public Key: D01B367761B0F7CE6E6D81AAD5A2E54246986015 Sichere Internetkommunikation: http://www.retroshare.org Privacy Handbuch: https://www.privacy-handbuch.de

Dirk Heinrichs

unread,
Aug 20, 2019, 11:23:22 AM8/20/19
to salt-...@googlegroups.com
Am 19.08.19 um 21:14 schrieb Mosby Simmons:

> I'm trying to delete multiple files with a salt state and was hoping
> to use a glob.  I don't want to delete the directory.

signature.asc

Mosby Simmons

unread,
Aug 20, 2019, 2:15:45 PM8/20/19
to Salt-users
After more googling I finally found that you could do multiple files using the following format:

remove_tmp_files:
  file.absent:
    - names:
      - '/tmp/file1'
      - '/tmp/file2'
      .....


Thanks for the quick responses though!

Markus Kramer

unread,
Sep 10, 2019, 6:23:07 AM9/10/19
to Salt-users
Yes, names is handy.
Have you also found a solution for the glob (/tmp/file*)?

Mosby Simmons

unread,
Sep 10, 2019, 11:32:25 AM9/10/19
to Salt-users
No unfortunately not.

Markus Kramer

unread,
Sep 11, 2019, 4:53:09 AM9/11/19
to salt-...@googlegroups.com
thank you, that is unfortunate

--
You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/y5zQoeLY1RY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/a9354fb7-3f87-4842-888e-d76bcde50049%40googlegroups.com.

Dirk Heinrichs

unread,
Sep 12, 2019, 12:10:54 PM9/12/19
to salt-...@googlegroups.com, Mosby Simmons
Am 10.09.19 um 17:32 schrieb Mosby Simmons:

> No unfortunately not.

Look at the thread again. I've sent the solution.
signature.asc

Markus Kramer

unread,
Sep 12, 2019, 3:17:58 PM9/12/19
to salt-...@googlegroups.com
Hi Dirk,
Thank you, I overlooked that.
Please send the module, or the pull request. 

Markus

--
You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/y5zQoeLY1RY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.

Dirk Heinrichs

unread,
Sep 13, 2019, 12:07:53 PM9/13/19
to salt-...@googlegroups.com
Am 12.09.19 um 21:16 schrieb Markus Kramer:

> Please send the module, or the pull request.

Sure. Here you are: https://github.com/saltstack/salt/pull/47718
signature.asc
Reply all
Reply to author
Forward
0 new messages