My question is: I want to check if a file exists in the /tmp
folder, and delete it before it starts downloading again.
Here is my code (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',
}
You probably want to do this ...
# 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",
}
See https://docs.puppet.com/puppet/latest/reference/types/exec.html and https://docs.puppet.com/puppet/latest/reference/lang_relationships.html