大网数据广告活动
服务器运维问答

Puppet "file" resource emptied a directory

· 52CE 我爱测

I'm in the somewhat embarrassing position of having unintentionally deleted multiple TB of important data via Puppet, and I'm just trying to understand why this might have happened. Firstly, I'm pretty sure the reason it's gone (…

问题原文

原帖链接 · ticktockhouse · CC BY-SA 3.0

I'm in the somewhat embarrassing position of having unintentionally deleted multiple TB of important data via Puppet, and I'm just trying to understand why this might have happened.

Firstly, I'm pretty sure the reason it's gone (as in unrecoverable except via backups) is:

File { backup => false }

in my site.pp. The nodes were set up to hard mount something via NFS, so a mount point /mount, and a line in fstab like this:

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

I wanted to get rid of the mount, and replace it with a symlink to the same eventual location (though a different path).

My puppet manifest looked like this:

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

This yielded the following when doing a puppet run:

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

So, I duly (or stupidly) added:

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

And lo and behold, puppet proceeded to consign the contents of the all-important mount to oblivion, while the mount point itself remained.

Any idea why this might have happened?

Thanks

已采纳解答

原帖链接 · clay richardson · CC BY-SA 4.0

It replaced that directory with a link: Documentation

Under 'force':

"Replace directories with files or links"

For future reference, you can try running in noop mode to see what changes will be made:

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-04-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。