Module: Puppet
- Extended by:
- Util, Util::Logging
- Defined in:
- lib/puppet.rb,
lib/puppet/pops.rb,
lib/puppet/type.rb,
lib/puppet/util.rb,
lib/puppet/error.rb,
lib/puppet/vendor.rb,
lib/puppet/loaders.rb,
lib/puppet/version.rb,
lib/puppet/defaults.rb,
lib/puppet/type/zfs.rb,
lib/puppet/type/exec.rb,
lib/puppet/type/host.rb,
lib/puppet/type/user.rb,
lib/puppet/type/group.rb,
lib/puppet/type/mount.rb,
lib/puppet/type/zpool.rb,
lib/puppet/application.rb,
lib/puppet/module_tool.rb,
lib/puppet/type/notify.rb,
lib/puppet/type/router.rb,
lib/puppet/type/sshkey.rb,
lib/puppet/parser/lexer.rb,
lib/puppet/type/package.rb,
lib/puppet/type/service.rb,
lib/puppet/util/plugins.rb,
lib/puppet/parser/parser.rb,
lib/puppet/parser/parser.rb,
lib/puppet/property/list.rb,
lib/puppet/type/maillist.rb,
lib/puppet/type/schedule.rb,
lib/puppet/util/classgen.rb,
lib/puppet/util/platform.rb,
lib/puppet/util/run_mode.rb,
lib/puppet/type/file/mode.rb,
lib/puppet/type/file/type.rb,
lib/puppet/type/mailalias.rb,
lib/puppet/util/execution.rb,
lib/puppet/resource/status.rb,
lib/puppet/type/file/ctime.rb,
lib/puppet/type/file/group.rb,
lib/puppet/type/file/mtime.rb,
lib/puppet/type/file/owner.rb,
lib/puppet/type/filebucket.rb,
lib/puppet/type/selboolean.rb,
lib/puppet/type/file/ensure.rb,
lib/puppet/type/file/source.rb,
lib/puppet/type/file/target.rb,
lib/puppet/network/authstore.rb,
lib/puppet/property/keyvalue.rb,
lib/puppet/ssl/configuration.rb,
lib/puppet/type/file/content.rb,
lib/puppet/util/command_line.rb,
lib/puppet/network/authconfig.rb,
lib/puppet/pops/parser/eparser.rb,
lib/puppet/pops/parser/eparser.rb,
lib/puppet/type/file/selcontext.rb,
lib/puppet/parser/parser_factory.rb,
lib/puppet/property/ordered_list.rb,
lib/puppet/type/ssh_authorized_key.rb,
lib/puppet/util/constant_inflector.rb,
lib/puppet/util/symbolic_file_mode.rb,
lib/puppet/parser/e4_parser_adapter.rb,
lib/puppet/util/command_line/trollop.rb,
lib/puppet/module_tool/install_directory.rb,
lib/puppet/ssl/certificate_authority/interface.rb,
lib/puppet/util/command_line/puppet_option_parser.rb
Overview
The main Puppet class. Everything is contained here.
Defined Under Namespace
Modules: Coercion, Confiner, DSL, Environments, ExternalFileError, FileBucket, FileBucketFile, FileSystem, Functions, Graph, Indirector, MetaType, ModuleTool, Network, Parser, Pops, Rails, SSL, Scheduler, Test, Util Classes: Agent, AlreadyImportedError, Application, AuthStoreError, AuthorizationError, Bindings, ConfigurationError, Configurer, Confine, ConfineCollection, ConstantAlreadyDefined, Context, Daemon, DataBinding, DevError, Error, ExecutionFailure, FileCollection, FileServing, Forge, ImportError, Interface, LexError, Module, Node, Parameter, ParseError, Plugins, Property, Provider, Relationship, Reports, Resource, ResourceError, Run, SELFileContext, Settings, Status, SubclassAlreadyDefined, Transaction, Type, Vendor
Constant Summary collapse
- Face =
Puppet::Interface
- PUPPETVERSION =
'3.7.4'- AS_DURATION =
NOTE: For information about the available values for the “:type” property of settings,
see the docs for Settings.define_settings %q{This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y).}- STORECONFIGS_ONLY =
%q{This setting is only used by the ActiveRecord storeconfigs and inventory backends, which are deprecated.}- Log =
This is for backward compatibility from when we changed the constant to Puppet::Util::Log because the reports include the constant name. Apparently the alias was created in March 2007, should could probably be removed soon.
Puppet::Util::Log
- Metric =
This is necessary because we changed the class path in early 2007, and reports directly yaml-dump these metrics, so both client and server have to agree on the class name.
Puppet::Util::Metric
- ResourceType =
self- @@settings =
the hash that determines how our system behaves
Puppet::Settings.new
Constants included from Util
Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE
Constants included from Util::POSIX
Util::POSIX::LOCALE_ENV_VARS, Util::POSIX::USER_ENV_VARS
Constants included from Util::SymbolicFileMode
Util::SymbolicFileMode::SetGIDBit, Util::SymbolicFileMode::SetUIDBit, Util::SymbolicFileMode::StickyBit, Util::SymbolicFileMode::SymbolicMode, Util::SymbolicFileMode::SymbolicSpecialToBit
Class Attribute Summary collapse
- .features ⇒ Object readonly
- .name ⇒ Object writeonly
Class Method Summary collapse
-
.[](param) ⇒ Object
Get the value for a setting.
-
.[]=(param, value) ⇒ Object
setting access and stuff.
-
.base_context(settings) ⇒ Object
private
The bindings used for initialization of puppet.
-
.bootstrap_context ⇒ Object
private
A simple set of bindings that is just enough to limp along to initialization where the Puppet.base_context bindings are put in place.
- .clear ⇒ Object
- .debug=(value) ⇒ Object
- .default_diffargs ⇒ Object
-
.define_settings(section, hash) ⇒ Object
Store a new default value.
- .genmanifest ⇒ Object
-
.initialize_settings(args = []) ⇒ void
Initialize puppet’s settings.
- .initialize_settings_for_run_mode(run_mode) ⇒ Object deprecated Deprecated.
-
.lookup(name, &block) ⇒ Object
private
Lookup a binding by name or return a default value provided by a passed block (if given).
- .mark_context(name) ⇒ Object private
-
.newtype(name, options = {}, &block) ⇒ Object
Create a new type.
- .override(bindings, description = "") { ... } ⇒ Object private
- .parse_config ⇒ Object deprecated Deprecated.
-
.pop_context ⇒ Object
private
Return to the previous context.
- .push_context(overrides, description = "") ⇒ Object private
- .rollback_context(name) ⇒ Object private
- .run_mode ⇒ Object
-
.settings ⇒ Object
Note: It’s important that these accessors (‘self.settings`, `self.[]`) are defined before we try to load any “features” (which happens a few lines below), because the implementation of the features loading may examine the values of settings.
-
.version ⇒ String
version is a public API method intended to always provide a fast and lightweight way to determine the version of Puppet.
- .version=(version) ⇒ Object
Methods included from Util
absolute_path?, activerecord_version, benchmark, binread, chuser, classproxy, deterministic_rand, execfail, execpipe, execute, exit_on_fail, logmethods, memory, path_to_uri, pretty_backtrace, proxy, replace_file, safe_posix_fork, symbolizehash, thinmark, uri_to_path, which, withenv, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::SymbolicFileMode
#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Methods included from Util::Logging
clear_deprecation_warnings, deprecation_warning, format_exception, get_deprecation_offender, log_and_raise, log_deprecations_to_file, log_exception, puppet_deprecation_warning, send_log
Class Attribute Details
.name=(value) ⇒ Object (writeonly)
37 38 39 |
# File 'lib/puppet.rb', line 37 def name=(value) @name = value end |
Class Method Details
.[](param) ⇒ Object
Get the value for a setting
56 57 58 59 60 61 62 |
# File 'lib/puppet.rb', line 56 def self.[](param) if param == :debug return Puppet::Util::Log.level == :debug else return @@settings[param] end end |
.[]=(param, value) ⇒ Object
setting access and stuff
83 84 85 |
# File 'lib/puppet.rb', line 83 def self.[]=(param,value) @@settings[param] = value end |
.base_context(settings) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The bindings used for initialization of puppet
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/puppet.rb', line 180 def self.base_context(settings) environments = settings[:environmentpath] modulepath = Puppet::Node::Environment.split_path(settings[:basemodulepath]) if environments.empty? loaders = [Puppet::Environments::Legacy.new] else loaders = Puppet::Environments::Directories.from_path(environments, modulepath) # in case the configured environment (used for the default sometimes) # doesn't exist default_environment = Puppet[:environment].to_sym if default_environment == :production loaders << Puppet::Environments::StaticPrivate.new( Puppet::Node::Environment.create(Puppet[:environment].to_sym, [], Puppet::Node::Environment::NO_MANIFEST)) end end { :environments => Puppet::Environments::Cached.new(Puppet::Environments::Combined.new(*loaders)), :http_pool => proc { require 'puppet/network/http' Puppet::Network::HTTP::NoCachePool.new } } end |
.bootstrap_context ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A simple set of bindings that is just enough to limp along to initialization where the base_context bindings are put in place
211 212 213 214 215 216 217 |
# File 'lib/puppet.rb', line 211 def self.bootstrap_context root_environment = Puppet::Node::Environment.create(:'*root*', [], Puppet::Node::Environment::NO_MANIFEST) { :current_environment => root_environment, :root_environment => root_environment } end |
.debug=(value) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/puppet.rb', line 91 def self.debug=(value) if value Puppet::Util::Log.level=(:debug) else Puppet::Util::Log.level=(:notice) end end |
.default_diffargs ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/puppet/defaults.rb', line 3 def self.default_diffargs if (Facter.value(:kernel) == "AIX" && Facter.value(:kernelmajversion) == "5300") "" else "-u" end end |
.define_settings(section, hash) ⇒ Object
Store a new default value.
78 79 80 |
# File 'lib/puppet.rb', line 78 def self.define_settings(section, hash) @@settings.define_settings(section, hash) end |
.genmanifest ⇒ Object
116 117 118 119 120 121 |
# File 'lib/puppet.rb', line 116 def self.genmanifest if Puppet[:genmanifest] puts Puppet.settings.to_manifest exit(0) end end |
.initialize_settings(args = []) ⇒ void
This method returns an undefined value.
Initialize puppet’s settings. This is intended only for use by external tools that are not
built off of the Faces API or the Puppet::Util::Application class. It may also be used
to initialize state so that a Face may be used programatically, rather than as a stand-alone
command-line tool.
138 139 140 |
# File 'lib/puppet.rb', line 138 def self.initialize_settings(args = []) do_initialize_settings_for_run_mode(:user, args) end |
.initialize_settings_for_run_mode(run_mode) ⇒ Object
Initialize puppet’s settings for a specified run_mode.
145 146 147 148 |
# File 'lib/puppet.rb', line 145 def self.initialize_settings_for_run_mode(run_mode) Puppet.deprecation_warning("initialize_settings_for_run_mode may be removed in a future release, as may run_mode itself") do_initialize_settings_for_run_mode(run_mode, []) end |
.lookup(name, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Lookup a binding by name or return a default value provided by a passed block (if given).
235 236 237 |
# File 'lib/puppet.rb', line 235 def self.lookup(name, &block) @context.lookup(name, &block) end |
.mark_context(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
248 249 250 |
# File 'lib/puppet.rb', line 248 def self.mark_context(name) @context.mark(name) end |
.newtype(name, options = {}, &block) ⇒ Object
Create a new type. Just proxy to the Type class. The mirroring query code was deprecated in 2008, but this is still in heavy use. I suppose this can count as a soft deprecation for the next dev. –daniel 2011-04-12
165 166 167 |
# File 'lib/puppet.rb', line 165 def self.newtype(name, = {}, &block) Puppet::Type.newtype(name, , &block) end |
.override(bindings, description = "") { ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
243 244 245 |
# File 'lib/puppet.rb', line 243 def self.override(bindings, description = "", &block) @context.override(bindings, description, &block) end |
.parse_config ⇒ Object
Parse the config file for this process.
125 126 127 128 |
# File 'lib/puppet.rb', line 125 def self.parse_config() Puppet.deprecation_warning("Puppet.parse_config is deprecated; please use Faces API (which will handle settings and state management for you), or (less desirable) call Puppet.initialize_settings") Puppet.initialize_settings end |
.pop_context ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return to the previous context.
229 230 231 |
# File 'lib/puppet.rb', line 229 def self.pop_context @context.pop end |
.push_context(overrides, description = "") ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
222 223 224 |
# File 'lib/puppet.rb', line 222 def self.push_context(overrides, description = "") @context.push(overrides, description) end |
.rollback_context(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
253 254 255 |
# File 'lib/puppet.rb', line 253 def self.rollback_context(name) @context.rollback(name) end |
.run_mode ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/puppet.rb', line 99 def self.run_mode # This sucks (the existence of this method); there are a lot of places in our code that branch based the value of # "run mode", but there used to be some really confusing code paths that made it almost impossible to determine # when during the lifecycle of a puppet application run the value would be set properly. A lot of the lifecycle # stuff has been cleaned up now, but it still seems frightening that we rely so heavily on this value. # # I'd like to see about getting rid of the concept of "run_mode" entirely, but there are just too many places in # the code that call this method at the moment... so I've settled for isolating it inside of the Settings class # (rather than using a global variable, as we did previously...). Would be good to revisit this at some point. # # --cprice 2012-03-16 Puppet::Util::RunMode[@@settings.preferred_run_mode] end |
.settings ⇒ Object
Note: It’s important that these accessors (‘self.settings`, `self.[]`) are defined before we try to load any “features” (which happens a few lines below), because the implementation of the features loading may examine the values of settings.
47 48 49 |
# File 'lib/puppet.rb', line 47 def self.settings @@settings end |
.version ⇒ String
version is a public API method intended to always provide a fast and lightweight way to determine the version of Puppet.
The intent is that software external to Puppet be able to determine the Puppet version with no side-effects. The expected use is:
require 'puppet/version'
version = Puppet.version
This function has the following ordering precedence. This precedence list is designed to facilitate automated packaging tasks by simply writing to the VERSION file in the same directory as this source file.
1. If a version has been explicitly assigned using the Puppet.version=
method, return that version.
2. If there is a VERSION file, read the contents, trim any
trailing whitespace, and return that version string.
3. Return the value of the Puppet::PUPPETVERSION constant hard-coded into
the source code.
If there is no VERSION file, the method must return the version string of the nearest parent version that is an officially released version. That is to say, if a branch named 3.1.x contains 25 patches on top of the most recent official release of 3.1.1, then the version method must return the string “3.1.1” if no “VERSION” file is present.
By design the version identifier is not intended to vary during the life a process. There is no guarantee provided that writing to the VERSION file while a Puppet process is running will cause the version string to be updated. On the contrary, the contents of the VERSION are cached to reduce filesystem accesses.
The VERSION file is intended to be used by package maintainers who may be applying patches or otherwise changing the software version in a manner that warrants a different software version identifier. The VERSION file is intended to be managed and owned by the release process and packaging related tasks, and as such should not reside in version control. The PUPPETVERSION constant is intended to be version controlled in history.
Ideally, this behavior will allow package maintainers to precisely specify the version of the software they’re packaging as in the following example:
$ git describe --match "3.0.*" > lib/puppet/VERSION
$ ruby -r puppet -e 'puts Puppet.version'
3.0.1-260-g9ca4e54
62 63 64 65 66 67 68 69 |
# File 'lib/puppet/version.rb', line 62 def self.version version_file = File.join(File.dirname(__FILE__), 'VERSION') return @puppet_version if @puppet_version if version = read_version_file(version_file) @puppet_version = version end @puppet_version ||= PUPPETVERSION end |
.version=(version) ⇒ Object
71 72 73 |
# File 'lib/puppet/version.rb', line 71 def self.version=(version) @puppet_version = version end |