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
You should have done a little research before posting this question. But nevermind..
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.