如何使用puppet删除所有/etc/*.txt文件

问题描述 投票:13回答:2

如果它存在,这个木偶清单将删除文件/etc/file.txt

  file { "/etc/file.txt":
    ensure  => absent,
  }

如何告诉木偶删除所有文件/etc/*.txt

据参考,似乎puppet file不允许使用通配符。 http://docs.puppetlabs.com/references/latest/type.html#file

ps:我知道我可以从puppet执行一个脚本,但我更喜欢另一种更优雅的方式。

puppet
2个回答
9
投票

这里有一个内置类型叫做'tidy',它允许你指定要删除的文件的文件glob模式。

http://docs.puppetlabs.com/references/latest/type.html#tidy查看。


6
投票

你可以使用整齐的glob模式:http://docs.puppetlabs.com/references/latest/type.html#tidy

所以这将是你的解决方案:

tidy { "delete-txt-files-in-etc":
    path    => "/etc",
    recurse => true,
    matches => [ '*.txt' ],
    rmdirs  => false,
}
© www.soinside.com 2019 - 2024. All rights reserved.