15

如果文件存在,此人偶清单将删除该文件/etc/file.txt

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

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

根据参考资料,似乎puppet file不允许使用通配符。 https://puppet.com/docs/puppet/latest/types/file.html

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

4

2 回答 2

9

有一个名为“tidy”的内置类型,它允许您指定要删除的文件的文件 glob 模式。

在https://puppet.com/docs/puppet/latest/types/tidy.html查看。

于 2014-05-05T13:36:10.220 回答
8

您可以使用整洁的 glob 模式:https ://puppet.com/docs/puppet/latest/types/tidy.html

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

tidy { "delete-txt-files-in-etc":
    path    => "/etc",
    recurse => true,
    matches => [ '*.txt' ],
    rmdirs  => false,
}
于 2015-06-19T08:36:21.857 回答