我的问题是:我想检查/tmp
文件夹中是否存在文件,并在重新开始下载之前将其删除。
这是我的代码(Puppet):
exec { 'Download mediawiki to temp':
cwd => '/tmp',
command => '/usr/bin/wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.1.tar.gz',
}
答案 0 :(得分:0)
你可能想要这样做......
# local vars for readability
$theurl = 'https://releases.wikimedia.org/mediawiki/1.27'
$tarball = 'mediawiki-1.27.1.tar.gz'
$wget_command = "/usr/bin/wget $theurl/$tarball"
$rm_command = "/bin/rm -f /tmp/$tarball"
exec { 'Delete mediawiki from temp':
cwd => '/tmp',
command => $rm_command,
}->
exec { 'Download mediawiki to temp':
cwd => '/tmp',
command => $wget_command,
creates => "/tmp/$tarball",
}
请参阅https://docs.puppet.com/puppet/latest/reference/types/exec.html和https://docs.puppet.com/puppet/latest/reference/lang_relationships.html