Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute a shell command/script using puppet

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

like image 286
AjayKumar Avatar asked Oct 18 '25 06:10

AjayKumar


1 Answers

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.

like image 164
Atmesh Mishra Avatar answered Oct 20 '25 23:10

Atmesh Mishra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!