Ask Your Question

Revision history [back]

you can try using the onlyif of exec resource.

 exec {'command when file not exists':
    command         => "command to solve the problem",
    user            => root,
    onlyif          => "test ! -f /path/to/file",
    path            => ['/usr/bin','/usr/sbin','/bin','/sbin'],
    notify          => Notify['/path/to/file not found'],         
  }

  notify {'/path/to/file not found': }

you can try using the onlyif of exec resource.

 exec {'command when file not exists':
    command         => "command to solve the problem",
    user            => root,
    onlyif          => "test ! -f /path/to/file",
    path            => ['/usr/bin','/usr/sbin','/bin','/sbin'],
    notify          => Notify['/path/to/file not found'],         
  }

  notify {'/path/to/file not found': }

 exec {'command when file exists':
    command         => "command to solve the problem",
    user            => root,
    onlyif          => "test -f /path/to/file",
    path            => ['/usr/bin','/usr/sbin','/bin','/sbin'],
    notify          => Notify['/path/to/file  found'],         
  }

  notify {'/path/to/file not found': }