2016-11-04 105 views
-1

我的問題是:我想檢查/tmp文件夾中是否存在文件,並在開始下載之前將其刪除。檢查文件是否存在,如果存在則將其刪除

這裏是我的代碼(木偶):

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.htmlhttps://docs.puppet.com/puppet/latest/reference/lang_relationships.html

相關問題