----- Original Message -----
> From: "R.I.Pienaar" <r...@devco.net>
> To: puppet-dev@googlegroups.com
> Sent: Monday, October 22, 2012 10:00:40 PM
> Subject: Re: [Puppet-dev] runmode
> 
> 
> 
> ----- Original Message -----
> > From: "Andy Parker" <a...@puppetlabs.com>
> > To: puppet-dev@googlegroups.com
> > Sent: Monday, October 22, 2012 7:57:36 PM
> > Subject: Re: [Puppet-dev] runmode
> > 
> > On Mon, Oct 22, 2012 at 11:03 AM, Brice Figureau
> > <brice-pup...@daysofwonder.com> wrote:
> > > On 22/10/12 19:25, R.I.Pienaar wrote:
> > >> hello,
> > >>
> > >> I need to get Puppet to read its config file and specifically
> > >> use
> > >> the
> > >> settings like an agent would.
> > >>
> > >> I need this for 2.7 and 3.0
> > >>
> > >> In trying to figure this out for 3.0 I have the following:
> > >>
> > >>    require 'puppet'
> > >>    require 'puppet/util/run_mode'
> > >>    Puppet.settings.preferred_run_mode = :agent
> > >
> > > I think you might need a:
> > >      Puppet.settings.use :main, :agent
> > >
> > > so that your code loads the correct sections from the settings
> > > file.
> > >
> > >>    run_mode = Puppet::Util::RunMode[
> > >>    Puppet.settings.preferred_run_mode ]
> > 
> > I believe this is the same as Puppet.run_mode
> > 
> > >>    
> > >> Puppet.settings.initialize_app_defaults(Puppet::Settings.app_defaults_for_run_mode(run_mode))
> > 
> > I think that before this you need to call
> > Puppet.settings.initialize_global_defaults
> > 
> > >>
> > >> At this point Puppet[:pidfile] is /var/lib/puppet/run/agent.pid
> > >> but when I do:
> > >
> > > It might be the default, which for $agent_pid is
> > > $statedir/agent.pid.
> > > But the default $statedir is $vardir/state, so that's not quite
> > > yet
> > > that...
> > >
> > >>    # puppet agent --configprint pidfile
> > >>
> > >> I get /var/run/puppet/agent.pid
> > >
> > > What is configured in your puppet.conf?
> > >
> > >> What is the correct way for both 2.7 and 3.0 to initialize the
> > >> settings
> > >> and to be sure I am seeing agent settings?
> > >>
> > >> It's OK if the way is completely different between versions, I
> > >> have a way to
> > >> handle that.
> > >
> > > I don't think there are such differences between 2.7/3.0, so it's
> > > possible the same code could work for both versions.
> > 
> > Because of the work that has gone into code loading (pluginsync and
> > modules) there has been a fair amount of churn in how to initialize
> > the settings. Since that is still not a published API, there might
> > still be a few more changes as we work on #7316.
> 
> So for 3 I have this down to:
> 
>         require 'puppet/util/run_mode'
>         Puppet.settings.preferred_run_mode = :agent
>         Puppet.settings.initialize_global_settings
>         
> Puppet.settings.initialize_app_defaults(Puppet::Settings.app_defaults_for_run_mode(Puppet.run_mode))
> 
> will have a play with 2.7 and see, thanks

for 2.7 it seems this is the magic:

   require 'puppet'
   $puppet_application_mode = Puppet::Util::RunMode[:agent]
   Puppet.settings.use :main, :agent
   Puppet.parse_config

have to say I am surprised about the global variable there, surely this is
not how it works?

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to