On Mon, Jan 10, 2011 at 05:06:04PM -0800, pl wrote:
> Hi,
>
> > Puppet::Provider::Package defines the prefetch class method. This is
> > called at the beginning of the puppet run to find matches between existing
> > packages and the one you described in your manifest. Prefetch calls
> > instances which should return an array of provider instances. One
> > provider instance for each package with the appropiate property_hash
> > {ensure => "whatever-version"}. If you dont know how to implement it try
> > with returning an empty array like hpux.rb does.
>
> Thanks.
>
> I still have this problem that I can't run puppet as a daemon and
> install packages as any other user. Trying to sudo inside the custom
> provider fails if puppet is running as a daemon.
>
> Is there no way around that?
Yes there is. And you will probably dont want to use backticks.
You can browse the functions in puppet/lib/util.rb for alternatives.
There are different ways to run commands. If you have defined a command
like you already did:
commands :npm_cmd => "/home/node/opt/bin/npm"
This will mean that puppet will only use the provider if the command is
there and you will get a method for free that will run that command.
npm_cmd('argument1','argument2')
I'm not sure if this will have the output as a return value or just
success/failure. To parse output I find execpipe convenient. (You can
use command(:my_own_defined_command) to return your command as a string
value)
execpipe("#{command(:npm_cmd)} list_or_whatever_argument") do |output|
output.each_line do |line|
# do parsing here
end
end
To run all these as a different user you should (although I never tried
it) wrap them in
Puppet::Util::SUIDManager.asuser("username", "group") do
# do stuff here as different user
end
Just grep for SUIDManager in the sources and you will find examples. You
may have to use userids and groupids for that to work i dont know.
Hope this helps.
-Stefan
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.