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. I think the only way to understand how to initialize them correctly in 2.7 is going to be reading through Puppet::Application and seeing what it does as the first few steps. > -- > Brice Figureau > My Blog: http://www.masterzen.fr/ > > -- > 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. > -- 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.