我正在尝试从远程位置下载一个文件到puppet的一个目录中。
.pp文件
class test::test {
exec { 'wget http://10.0.0.1/test/test.txt':
cwd => '/opt/check',
path => ['/usr/bin', '/usr/sbin',],
}
}我还尝试了在puppet中使用wget模块:
class test::test {
include ::wget
wget::fetch { 'http://10.0.0.1/test/test.txt':
destination => '/tmp/',
timeout => 0,
verbose => false,
}
}我没有下载文件,是我做错了什么,还是有更好的方法?请让我知道。
发布于 2020-06-12 02:04:01
在您的节点上运行which wget以确保包含正确的路径,在我的centos机器上是/bin/wget。我经常(这可能是一个坏习惯)在命令中包含完整的路径,所以我会放入/bin/wget http://10.0.0.1/test/test.txt,你有没有试过在机器上手动运行这个命令?请查看此链接https://puppet.com/docs/puppet/5.5/type.html#exec
exec { 'get-test.txt':
cwd => '/opt/check',
command => '/bin/wget http://10.0.0.1/test/test.txt',
path => ['/usr/bin', '/usr/sbin',],
creates => '/opt/check/test.txt',
}如果文件存在,“create”将停止运行exec,您希望这样做,或者每次puppet运行时(默认每30分钟运行一次),它将再次运行该命令。
我刚刚在我的机器上运行了一个测试,我创建了一个文件test.pp并将其放入其中;
exec { 'get-google':
cwd => '/tmp',
command => '/bin/wget http://www.google.com',
path => ['/usr/bin', '/usr/sbin',],
creates => '/tmp/index.html',
}然后运行puppet apply test.pp,它起作用了,如果你想测试小块代码,这是一个很方便的方式。
另外,/opt/check目录是否存在?
https://stackoverflow.com/questions/62324084
复制相似问题