how to set path when applying single puppet module?
I'm trying to run a single module like this:
puppet apply --verbose --modulepath=moduleshere --noop -e 'include myclass'
However, I get this kind of error, indicating the path is not set
Parameter unless failed: '[ -e "${logfile}" ]' is not qualified and no path was specified. Please qualify the command or specify a path.
I don't want to explicitly specify the path in every such location, and it works fine when run as part of a full puppet run. How can I specify the path when running a single module?
The commands in an Exec
resource either have to be fully qualified (i. e. /usr/bin/test
instead of test
) or the path
attribute of that Exec
resource has to be set.
If you can modify the Puppet manifest(s) you can simply add the following definition for setting a default path
attribute for all Exec
resources to /bin
:
Exec { path => "/bin" }
As a (more or less) dirty workaround you can also just set the default path
for any Exec
resource on the command line:
$ puppet apply --verbose -e 'Exec { path => "/bin" }' your_manifest.pp
Documentation pointers:
- https://puppet.com/docs/puppet/latest/services_apply.html
- https://puppet.com/docs/puppet/latest/types/exec.html
- https://puppet.com/docs/puppet/latest/lang_defaults.html
That.. shouldn't work as part of a full run. It needs a full path to the executable in the unless
command. Maybe you've got a path set in a global file that's part of your full runs?
Try unless => '/usr/bin/[ -e "${logfile}" ]'
, instead.
I agree with Shane that the default path is probably set in a globally scoped manifest. You could do the same but you can't pass it as an argument, so either use stdin:
$ puppet apply -v --modulepath=moduleshere --noop <<EOF
Exec { path => "/bin:/sbin:/usr/bin:/usr/sbin" }
include myclass
EOF
or put the Exec and include lines into example.pp
and then use puppet apply -v ... example.pp
.
You need to use fully qualified path.
For example either:
exec { "sample":
command => "/usr/bin/test",
}
or:
exec { "sample":
path => ['/usr/bin', '/usr/sbin', '/bin'],
command => "test",
}