如果它存在,这个木偶清单将删除文件/etc/file.txt
:
file { "/etc/file.txt":
ensure => absent,
}
如何告诉木偶删除所有文件/etc/*.txt
?
据参考,似乎puppet file
不允许使用通配符。 http://docs.puppetlabs.com/references/latest/type.html#file
ps:我知道我可以从puppet执行一个脚本,但我更喜欢另一种更优雅的方式。
这里有一个内置类型叫做'tidy',它允许你指定要删除的文件的文件glob模式。
在http://docs.puppetlabs.com/references/latest/type.html#tidy查看。
你可以使用整齐的glob模式:http://docs.puppetlabs.com/references/latest/type.html#tidy
所以这将是你的解决方案:
tidy { "delete-txt-files-in-etc":
path => "/etc",
recurse => true,
matches => [ '*.txt' ],
rmdirs => false,
}