Class: Puppet::Application::Master
Constant Summary
DOCPATTERN
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
Util::SymbolicFileMode::SetGIDBit, Util::SymbolicFileMode::SetUIDBit, Util::SymbolicFileMode::StickyBit, Util::SymbolicFileMode::SymbolicMode, Util::SymbolicFileMode::SymbolicSpecialToBit
Instance Attribute Summary
#command_line, #options
Instance Method Summary
collapse
[], available_application_names, banner, clear!, clear?, clear_everything_for_tests, #configure_indirector_routes, controlled_run, #deprecate, #deprecated?, exit, find, #handle_logdest_arg, #handlearg, #initialize, #initialize_app_defaults, interrupted?, #log_runtime_environment, #name, option, option_parser_commands, #parse_options, restart!, restart_requested?, #run, run_mode, #set_log_level, stop!, stop_requested?, try_load_class
Methods included from Util
absolute_path?, benchmark, chuser, clear_environment, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, safe_posix_fork, set_env, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, which, withenv, withumask
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Instance Method Details
#app_defaults ⇒ Object
142
143
144
145
146
|
# File 'lib/puppet/application/master.rb', line 142
def app_defaults
super.merge({
:facts_terminus => 'yaml'
})
end
|
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/puppet/application/master.rb', line 166
def compile
begin
unless catalog = Puppet::Resource::Catalog.indirection.find(options[:node])
raise _("Could not compile catalog for %{node}") % { node: options[:node] }
end
puts JSON::pretty_generate(catalog.to_resource, :allow_nan => true, :max_nesting => false)
rescue => detail
Puppet.log_exception(detail, _("Failed to compile catalog for node %{node}: %{detail}") % { node: options[:node], detail: detail })
exit(30)
end
exit(0)
end
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/puppet/application/master.rb', line 32
def help
"\npuppet-master(8) -- \#{summary}\n========\n\nSYNOPSIS\n--------\nThe central puppet server. Functions as a certificate authority by\ndefault.\n\n\nUSAGE\n-----\npuppet master [-D|--daemonize|--no-daemonize] [-d|--debug] [-h|--help]\n[-l|--logdest syslog|<FILE>|console] [-v|--verbose] [-V|--version]\n[--compile <NODE-NAME>]\n\n\nDESCRIPTION\n-----------\nThis command starts an instance of puppet master, running as a daemon\nand using Ruby's built-in Webrick webserver. Puppet master can also be\nmanaged by other application servers; when this is the case, this\nexecutable is not used.\n\n\nOPTIONS\n-------\n\nNote that any Puppet setting that's valid in the configuration file is also a\nvalid long argument. For example, 'server' is a valid setting, so you can\nspecify '--server <servername>' as an argument. Boolean settings translate into\n'--setting' and '--no-setting' pairs.\n\nSee the configuration file documentation at\nhttps://docs.puppetlabs.com/puppet/latest/reference/configuration.html for the\nfull list of acceptable settings. A commented list of all settings can also be\ngenerated by running puppet master with '--genconfig'.\n\n* --daemonize:\nSend the process into the background. This is the default.\n(This is a Puppet setting, and can go in puppet.conf. Note the special 'no-'\nprefix for boolean settings on the command line.)\n\n* --no-daemonize:\nDo not send the process into the background.\n(This is a Puppet setting, and can go in puppet.conf. Note the special 'no-'\nprefix for boolean settings on the command line.)\n\n* --debug:\nEnable full debugging.\n\n* --help:\nPrint this help message.\n\n* --logdest:\nWhere to send log messages. Choose between 'syslog' (the POSIX syslog\nservice), 'console', or the path to a log file. If debugging or verbosity is\nenabled, this defaults to 'console'. Otherwise, it defaults to 'syslog'.\n\nA path ending with '.json' will receive structured output in JSON format. The\nlog file will not have an ending ']' automatically written to it due to the\nappending nature of logging. It must be appended manually to make the content\nvalid JSON.\n\n* --masterport:\nThe port on which to listen for traffic. The default port is 8140.\n(This is a Puppet setting, and can go in puppet.conf.)\n\n* --verbose:\nEnable verbosity.\n\n* --version:\nPrint the puppet version number and exit.\n\n* --compile:\nCompile a catalogue and output it in JSON from the puppet master. Uses\nfacts contained in the $vardir/yaml/ directory to compile the catalog.\n\n\nEXAMPLE\n-------\npuppet master\n\nDIAGNOSTICS\n-----------\n\nWhen running as a standalone daemon, puppet master accepts the\nfollowing signals:\n\n* SIGHUP:\nRestart the puppet master server.\n* SIGINT and SIGTERM:\nShut down the puppet master server.\n* SIGUSR2:\nClose file descriptors for log files and reopen them. Used with logrotate.\n\nAUTHOR\n------\nLuke Kanies\n\n\nCOPYRIGHT\n---------\nCopyright (c) 2012 Puppet Inc., LLC Licensed under the Apache 2.0 License\n\n HELP\nend\n"
|
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
207
208
209
210
|
# File 'lib/puppet/application/master.rb', line 180
def main
require 'etc'
Puppet::SSL::Host.localhost
Puppet::SSL::Host.ca_location = :only if Puppet::SSL::CertificateAuthority.ca?
if Puppet.features.root?
if Puppet::Type.type(:user).new(:name => Puppet[:user]).exists?
begin
Puppet::Util.chuser
rescue => detail
Puppet.log_exception(detail, _("Could not change user to %{user}: %{detail}") % { user: Puppet[:user], detail: detail })
exit(39)
end
else
Puppet.err(_("Could not change user to %{user}. User does not exist and is required to continue.") % { user: Puppet[:user] })
exit(74)
end
end
if options[:rack]
Puppet.deprecation_warning(_("The Rack Puppet master server is deprecated and will be removed in a future release. Please use Puppet Server instead. See http://links.puppet.com/deprecate-rack-webrick-servers for more information."))
start_rack_master
else
Puppet.deprecation_warning(_("The WEBrick Puppet master server is deprecated and will be removed in a future release. Please use Puppet Server instead. See http://links.puppet.com/deprecate-rack-webrick-servers for more information."))
start_webrick_master
end
end
|
148
149
150
151
152
153
154
155
156
|
# File 'lib/puppet/application/master.rb', line 148
def preinit
Signal.trap(:INT) do
$stderr.puts _("Canceling startup")
exit(0)
end
@argv = ARGV.dup
end
|
#run_command ⇒ Object
158
159
160
161
162
163
164
|
# File 'lib/puppet/application/master.rb', line 158
def run_command
if options[:node]
compile
else
main
end
end
|
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
# File 'lib/puppet/application/master.rb', line 265
def setup
raise Puppet::Error.new(_("Puppet master is not supported on Microsoft Windows")) if Puppet.features.microsoft_windows?
setup_logs
exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
Puppet.settings.use :main, :master, :ssl, :metrics
setup_terminuses
setup_node_cache
setup_ssl
end
|
#setup_logs ⇒ Object
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
# File 'lib/puppet/application/master.rb', line 212
def setup_logs
set_log_level
if !options[:setdest]
if options[:node]
Puppet::Util::Log.newdestination(:console)
elsif !(Puppet[:daemonize] or options[:rack])
Puppet::Util::Log.newdestination(:console)
else
Puppet::Util::Log.newdestination(:syslog)
end
end
end
|
#setup_node_cache ⇒ void
This method returns an undefined value.
Honor the :node_cache_terminus setting if users have specified it directly. We normally want this nil as use-cases for querying nodes should be going to PuppetDB.
261
262
263
|
# File 'lib/puppet/application/master.rb', line 261
def setup_node_cache
Puppet::Node.indirection.cache_class = Puppet[:node_cache_terminus]
end
|
#setup_ssl ⇒ Object
243
244
245
246
247
248
249
250
251
252
253
254
|
# File 'lib/puppet/application/master.rb', line 243
def setup_ssl
if Puppet::SSL::CertificateAuthority.ca?
Puppet::SSL::Host.ca_location = :local
Puppet.settings.use :ca
Puppet::SSL::CertificateAuthority.instance
else
Puppet::SSL::Host.ca_location = :none
end
Puppet::SSL::Oids.register_puppet_oids
Puppet::SSL::Oids.load_custom_oid_file(Puppet[:trusted_oid_mapping_file])
end
|
#setup_terminuses ⇒ Object
233
234
235
236
237
238
239
240
241
|
# File 'lib/puppet/application/master.rb', line 233
def setup_terminuses
require 'puppet/file_serving/content'
require 'puppet/file_serving/metadata'
Puppet::FileServing::Content.indirection.terminus_class = :file_server
Puppet::FileServing::Metadata.indirection.terminus_class = :file_server
Puppet::FileBucket::File.indirection.terminus_class = :file
end
|
28
29
30
|
# File 'lib/puppet/application/master.rb', line 28
def summary
_("The puppet master daemon")
end
|