/usr/share/puppet/rack/puppet-master/config.ru is in puppet-master-passenger 5.4.0-2ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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 | # a config.ru, for use with every rack-compatible webserver.
# SSL needs to be handled outside this, though.
# if puppet is not in your RUBYLIB:
# $LOAD_PATH.unshift('/opt/puppet/lib')
$0 = "master"
# if you want debugging:
# ARGV << "--debug"
ARGV << "--rack"
# Rack applications typically don't start as root. Set --confdir, --vardir,
# --logdir, --rundir to prevent reading configuration from
# ~/ based pathing.
ARGV << "--confdir" << "/etc/puppet"
ARGV << "--vardir" << "/var/lib/puppet"
ARGV << "--logdir" << "/var/log/puppet"
ARGV << "--rundir" << "/run/puppet"
ARGV << "--codedir" << "/etc/puppet/code"
# disable always_retry_plugsin as a performance improvement. This is safe for a master to
# apply. This is intended to allow agents to recognize new features that may be
# delivered during catalog compilation.
ARGV << "--no-always_retry_plugins"
# Rack middleware for Puppet 3 compatibility
# See Debian bug #832536
class Puppet3Compat
attr_reader :master
@@puppet4_endpoints = ['puppet', 'puppet-ca']
@@v1_res_endpoints = ['catalog', 'file_bucket_file', 'file_content',
'file_metadata', 'file_metadatas', 'report',
'facts', 'node', 'resource_type', 'resource_types',
'status']
@@v1_ca_endpoints = ['certificate', 'certificate_request',
'certificate_status', 'certificate_statuses',
'certificate_revocation_list']
@@v2_endpoints = ['environments']
def initialize(app)
@master = app
end
def call(env)
components = env["PATH_INFO"].to_s.split("/")
components.shift if components.first.empty?
if components.length < 2
return master.call(env)
end
environment = components.shift
@api = components.first
# Short-circuit Puppet 4 requests
if @@puppet4_endpoints.include?(environment)
return master.call(env)
end
@req = Rack::Request.new(env)
# Rewrite Puppet 3 requests
if @@v1_ca_endpoints.include?(@api)
@req.path_info = "/puppet-ca/v1/#{components.join("/")}"
elsif @@v1_res_endpoints.include?(@api) || @@v2_endpoints.include?(@api)
@req.path_info = "/puppet/v3/#{components.join("/")}"
end
if environment != "v2.0"
@req.update_param("environment", environment)
# Re-create the query string
env['QUERY_STRING'] = Rack::Utils.build_query(@req.params)
end
if @api =~ /^file_(content|bucket_file)/ && @req.get?
env["HTTP_ACCEPT"] = "binary"
elsif @api == "file_bucket_file" && (@req.post? || @req.put?)
env["CONTENT_TYPE"] = "application/octet-stream"
end
master.call(env).tap do |res|
if @api =~ /^file_(content|bucket_file)/ && @req.get?
# Always respond with text/plain to Puppet 3 clients.
res[1]["Content-Type"] = "text/plain"
end
end
end
end
use Puppet3Compat
# NOTE: it's unfortunate that we have to use the "CommandLine" class
# here to launch the app, but it contains some initialization logic
# (such as triggering the parsing of the config file) that is very
# important. We should do something less nasty here when we've
# gotten our API and settings initialization logic cleaned up.
#
# Also note that the "$0 = master" line up near the top here is
# the magic that allows the CommandLine class to know that it's
# supposed to be running master.
#
# --cprice 2012-05-22
require 'puppet/util/command_line'
# we're usually running inside a Rack::Builder.new {} block,
# therefore we need to call run *here*.
run Puppet::Util::CommandLine.new.execute
|