在木偶中只复制一次文件
Copying a file only once in puppet
我是 puppet 的新手,我正在尝试将文件复制到远程服务器以安装软件包,该文件会在安装几分钟后被删除。有没有办法只复制一次这个文件。?就像下面的例子。
class absent_file {
file { '/tmp/hello-file':
ensure => 'present',
replace => 'no',
content => "From Puppet\n",
mode => '0644',
once => true
}
}
所以,我已经想出了如何去做。我没有使用文件模块,而是使用命令并触摸了另一个不会随着安装过程被删除的模块。可以删除密钥,但 somefile.txt
仍然存在,并且该过程将变得幂等。
exec {'add key':
command => "echo 'SharedKeyfile' > /key/location && touch /key/location/somefile.txt'",
onlyif => "test ! -f /key/location/somefile.txt",
}
我是 puppet 的新手,我正在尝试将文件复制到远程服务器以安装软件包,该文件会在安装几分钟后被删除。有没有办法只复制一次这个文件。?就像下面的例子。
class absent_file {
file { '/tmp/hello-file':
ensure => 'present',
replace => 'no',
content => "From Puppet\n",
mode => '0644',
once => true
}
}
所以,我已经想出了如何去做。我没有使用文件模块,而是使用命令并触摸了另一个不会随着安装过程被删除的模块。可以删除密钥,但 somefile.txt
仍然存在,并且该过程将变得幂等。
exec {'add key':
command => "echo 'SharedKeyfile' > /key/location && touch /key/location/somefile.txt'",
onlyif => "test ! -f /key/location/somefile.txt",
}