Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

having issue with test in exec


I have issue with below code, the manifests does not run exec resource if I use test option

exec { test:
  path => '/etc',
  command => "/bin/sed -i 's/comment$id/#comment$id/g' /etc/services',
  onlyif => "test `grep  comment$id /etc/services` -eq 0"

If I run with without test in onlyif then exec resoruce will execute correctly.

onlyif => "test `grep  comment$id /etc/services` -eq 0"

if the value (comment$id) is existing without any comment line then the exec resourc should start, that is my intention for onlyif condition