I want to execute a shell command/script using puppet only when a file exists in particular path.
For example if a text file test.txt
exists in /root
path then puppet will execute shell script, otherwise puppet didn't execute any commands
exec {"Comment to your resource":
command => 'your command',
provider => shell,
onlyif => '/usr/bin/test -e /path/to/file/test.txt',
}
onlyif
will execute the command in Exec
if and only if the command executed(in the onlyif
) has return code 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With