清除盐状态文件的目录

我如何使用状态文件来清除一个salt-minion上的目录? 在设置其他主pipe服务之前,我想删除/etc/supervisord/conf.d/所有*.conf文件。

以下top.slsconfiguration不起作用:

 /etc/supervisor/conf.d/*: file.absent 

file.remove失败,因为不可用。

与你有同样的问题。 这对我来说是有用的。

 remove-supervisord-confd: file.directory: - name: /etc/supervisord/conf.d/ - clean: True 

不是一个完美的答案,但你可以在目录上使用file.absent,然后重新创build它。 请注意,每次运行状态时都会删除目录。 你可以看看下面的一个忍者条件:

 supervisor-conf-delete: file.absent: - name: /etc/supervisord/conf.d supervisor-conf-create: file.directory: - name: /etc/supervisord/conf.d - user: root - group: root - mode: 0755 - require: - file: supervisor-conf-delete 

你可以在盐状态下使用cmd模块。 以下代码可能出现在您的状态文件中:

 rm -f /etc/supervisord/conf.d/*.conf: cmd.run 

如果你愿意,你也可以写更复杂的命令。