On Thu, Sep 5, 2013 at 10:42 AM, Patrick Carlisle <[email protected]>wrote:
> On Wed, Sep 4, 2013 at 3:13 PM, John Julien <[email protected]> wrote: > >> I would like to check if Puppet is in noop mode or administratively >> disabled from inside a ruby script. I am having trouble getting the noop >> setting to read in properly when under the [agent] section of the config >> file. My puppet.conf has noop = true under the agent section and puppet is >> disabled via puppet agent --disable. >> >> My script outputs: >> *agent : noop : false >> Puppet is disabled >> * >> puppet config --mode agent print noop >> outputs: true >> >> Can anyone offer any guidance? Should I just use shell and parse the >> output? Here's my script: >> >> #!/opt/puppet/bin/ruby >> >> require 'puppet' >> >> setting = Puppet.settings.setting(:noop) >> puts "#{setting.section} : #{setting.name} : #{setting.value}" >> >> app = Puppet::Application::Agent.new() >> app.preinit >> Puppet[:daemonize] = false >> app.setup >> if app.agent.disabled? >> puts "Puppet is disabled" >> end >> > > Try adding a call to Puppet.initialize_settings right after requiring > puppet. I think right now you are just getting the default because nothing > is causing puppet to read the config file. > ^^ That's usually the case (I always forget the name of the method and think it's parse_settings() or something like that). Also, you can access those values in a shorter method with: Puppet[:noop] > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/puppet-dev. > For more options, visit https://groups.google.com/groups/opt_out. > -- Gary Larizza Professional Services Engineer Puppet Labs -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/puppet-dev. For more options, visit https://groups.google.com/groups/opt_out.
