module Puppet::ApplicationSupport
Public Class Methods
Reads the routes YAML settings from the file specified by Puppet and resets indirector termini for the current application class if listed.
For instance, PE uses this to set the master facts terminus to 'puppetdb' and its cache terminus to 'yaml'.
@param application_name [String] The name of the current application. @return [void] @api private
# File lib/puppet/application_support.rb 52 def self.configure_indirector_routes(application_name) 53 route_file = Puppet[:route_file] 54 if Puppet::FileSystem.exist?(route_file) 55 routes = Puppet::Util::Yaml.safe_load_file(route_file, [Symbol]) 56 if routes["server"] && routes["master"] 57 Puppet.warning("Route file #{route_file} contains both server and master route settings.") 58 elsif routes["server"] && !routes["master"] 59 routes["master"] = routes["server"] 60 elsif routes["master"] && !routes["server"] 61 routes["server"] = routes["master"] 62 end 63 application_routes = routes[application_name] 64 Puppet::Indirector.configure_routes(application_routes) if application_routes 65 end 66 end
Pushes a Puppet
Context
configured with a remote environment for an agent (one that exists at the master end), and a regular environment for other modes. The configuration is overridden with options from the command line before being set in a pushed Puppet
Context
.
@param run_mode [Puppet::Util::RunMode] Puppet's current Run Mode. @param environment_mode [Symbol] optional, Puppet's
current Environment Mode. Defaults to :local
@return [void] @api private
# File lib/puppet/application_support.rb 21 def self.push_application_context(run_mode, environment_mode = :local) 22 Puppet.push_context_global(Puppet.base_context(Puppet.settings), "Update for application settings (#{run_mode})") 23 # This use of configured environment is correct, this is used to establish 24 # the defaults for an application that does not override, or where an override 25 # has not been made from the command line. 26 # 27 configured_environment_name = Puppet[:environment] 28 if run_mode.name == :agent 29 configured_environment = Puppet::Node::Environment.remote(configured_environment_name) 30 elsif environment_mode == :not_required 31 configured_environment = 32 Puppet.lookup(:environments).get(configured_environment_name) || Puppet::Node::Environment.remote(configured_environment_name) 33 else 34 configured_environment = Puppet.lookup(:environments).get!(configured_environment_name) 35 end 36 configured_environment = configured_environment.override_from_commandline(Puppet.settings) 37 38 # Setup a new context using the app's configuration 39 Puppet.push_context({:current_environment => configured_environment}, 40 "Update current environment from application's configuration") 41 end