AjayKumar
AjayKumar

Reputation: 59

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

Upvotes: 4

Views: 14377

Answers (1)

Atmesh Mishra
Atmesh Mishra

Reputation: 549

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.

Upvotes: 5

Related Questions