salt.file.absent with regular expression

481 views
Skip to first unread message

gargi

unread,
Sep 8, 2017, 4:37:13 PM9/8/17
to Salt-users
Hi all,

this might be much easier -- I just somehow cannot find the right solution. I'm trying to execute something like the salt way:
$ rm -rf /opt/activemq*

Of course, I could execute it as a command, however, I wanted to use file.absent:
delete_activemq:
  file.absent:
    - names:
      - /opt/activemq*
      - /etc/init.d/activemq
      - /etc/default/activemq

All works fine except that salt is trying to delete a folder / file with the name /opt/activemq* instead of interpreting the * as a regular expression / regex.

How can I do that?

Thank you,

Edgar

Thomas Phipps

unread,
Sep 8, 2017, 5:04:09 PM9/8/17
to Salt-users
file.absent doesn't do globs. but file.find does. 

{% set files = salt.file.find(path='/opt/', name='activemq*') %}
{% set files = files + ['/etc/init.d/activemq','/etc/default/activemq'] %}
delete_activemq:
  file.absent:
    - names: {{files|yaml}}

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/72b745f6-a867-445e-85b2-51f7f8014463%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages