[HOW TO] Puppet Validation of Exec[generating file] failed: '....' is not qualified and no path was specified. Please qualify the command or specify a path

I just run executable resource in Puppet and could not run successful. Here is content of Puppet file.
root@puppet:/etc/puppet/manifests# cat exec.pp
exec { 'generating file':
cwd => '/tmp/',
command => 'for i in {1.2}.txt; do touch $name; done',
creates => '/tmp/1.txt',
}
root@puppet:/etc/puppet/manifests# puppet apply --noop exec.pp
Notice: Compiled catalog for puppet in environment production in 0.10 seconds
Error: Validation of Exec[generating file] failed: 'for name in {1.2}.txt; do touch $name; done' is not qualified and no path was specified. Please qualify the command or specify a path. at /etc/puppet/manifests/exec.pp:5

Following the notification, I should declare the qualified path of command, then I put a default path as /bin
root@puppet:/etc/puppet/manifests# vim exec.pp
exec { 'generating file':
cwd => '/tmp/',
path => '/bin',
command => 'for name in {1.2}.txt; do touch $name; done',
creates => '/tmp/1.txt',
}
root@puppet:/etc/puppet/manifests# puppet apply --noop exec.pp
Notice: Compiled catalog for puppet in environment production in 0.10 seconds
Notice: /Stage[main]/Main/Exec[generating file]/returns: current_value notrun, should be 0 (noop)
Notice: Class[Main]: Would have triggered 'refresh' from 1 events
Notice: Stage[main]: Would have triggered 'refresh' from 1 events
Notice: Finished catalog run in 0.04 seconds

It works!!!

So you can do like me to fix it.

Tiến Phan - R0039

Knowledge is Endless

Sharing for Success

0 nhận xét:

Post a Comment