傀儡“文件”资源清空一个目录

我有些尴尬地通过Puppet无意中删除了多个重要数据的TB,我只是想明白为什么会发生这种情况。

首先,我很确定它的消失的原因(除了通过备份之外,不可恢复)是:

File { backup => false } 

在我的网站。 这些节点被设置为通过NFS来挂载某些东西,所以挂载点/挂载以及fstab中的一行如下所示:

 nfsserver:/mount /mount nfs <options> 0 0 

我想摆脱装载,并用一个符号链接replace到相同的最终位置(虽然不同的path)。

我的木偶清单看起来像这样:

 class symlinks::linkdirtest ( ) { file { '/mount': ensure => "link", target => "/anotherdir/mount", } mount { "/mount": ensure => "absent", } } 

做傀儡跑时,得到以下结果:

 notice: /Stage[main]/Symlinks::Linkdirtest/File[/mount]: Not removing directory; use 'force' to override 

所以,我适时(或愚蠢地)补充说:

 class symlinks::linkdirtest ( ) { file { '/mount': ensure => "link", target => "/anotherdir/mount", force => "true", } .... 

瞧,傀儡继续把最重要的坐骑的内容遗忘,而坐骑本身仍然存在。

任何想法为什么这可能发生?

谢谢

它用一个链接取代了那个目录:

http://docs.puppetlabs.com/references/latest/type.html#parameters-4

在“力量”下:

“用文件或链接replace目录”

为了将来的参考,你可以尝试在noop模式下运行,看看会发生什么变化:

 puppet agent --test --debug --noop --show-diff 

在应用木偶之前,testing木偶运行之前,还应该记住,您编写木偶代码的顺序并不总是木偶运行的顺序。 在这种情况下,您应该已经定义了顺序。 符号链接发生之​​前,您必须先卸载。 你可以这样做,如下所示:

 class symlinks::linkdirtest ( ) { file { '/mount': ensure => "link", target => "/anotherdir/mount", } mount { "/mount": ensure => "absent", before => File['/mount'], } }