diff --git a/acceptance/lib/puppet/acceptance/environment_utils_spec.rb b/acceptance/lib/puppet/acceptance/environment_utils_spec.rb index 5b2383b27..d3ee14c57 100644 --- a/acceptance/lib/puppet/acceptance/environment_utils_spec.rb +++ b/acceptance/lib/puppet/acceptance/environment_utils_spec.rb @@ -1,144 +1,144 @@ require File.join(File.dirname(__FILE__),'../../acceptance_spec_helper.rb') require 'puppet/acceptance/environment_utils' module EnvironmentUtilsSpec describe 'EnvironmentUtils' do class ATestCase include Puppet::Acceptance::EnvironmentUtils def step(str) yield end def on(host, command, options = nil) stdout = host.do(command, options) yield TestResult.new(stdout) if block_given? end end class TestResult attr_accessor :stdout def initialize(stdout) self.stdout = stdout end end class TestHost attr_accessor :did, :directories, :attributes def initialize(directories, attributes = {}) self.directories = directories self.did = [] self.attributes = attributes end def do(command, options) did << (options.nil? ? command : [command, options]) case command when /^ls (.*)/ then directories[$1] end end def [](param) attributes[param] end end let(:testcase) { ATestCase.new } let(:host) { TestHost.new(directory_contents, 'user' => 'root', 'group' => 'puppet') } let(:directory_contents) do { - '/etc/puppetlabs' => 'foo bar baz widget', + '/etc/puppet' => 'foo bar baz widget', '/tmp/dir' => 'foo dingo bar thing', } end it "runs the block of code" do ran_code = false - testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppetlabs', '/tmp/dir') do + testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppet', '/tmp/dir') do ran_code = true end expect(ran_code).to be true expect(host.did).to eq([ - "ls /etc/puppetlabs", + "ls /etc/puppet", "ls /tmp/dir", - "mv /etc/puppetlabs/foo /etc/puppetlabs/foo.bak", - "mv /etc/puppetlabs/bar /etc/puppetlabs/bar.bak", - "cp -R /tmp/dir/foo /etc/puppetlabs/foo", - "cp -R /tmp/dir/dingo /etc/puppetlabs/dingo", - "cp -R /tmp/dir/bar /etc/puppetlabs/bar", - "cp -R /tmp/dir/thing /etc/puppetlabs/thing", - "chown -R root:puppetlabs /etc/puppetlabs/foo /etc/puppetlabs/dingo /etc/puppetlabs/bar /etc/puppetlabs/thing", - "chmod -R 770 /etc/puppetlabs/foo /etc/puppetlabs/dingo /etc/puppetlabs/bar /etc/puppetlabs/thing", - "rm -rf /etc/puppetlabs/foo /etc/puppetlabs/dingo /etc/puppetlabs/bar /etc/puppetlabs/thing", - "mv /etc/puppetlabs/foo.bak /etc/puppetlabs/foo", - "mv /etc/puppetlabs/bar.bak /etc/puppetlabs/bar" + "mv /etc/puppet/foo /etc/puppet/foo.bak", + "mv /etc/puppet/bar /etc/puppet/bar.bak", + "cp -R /tmp/dir/foo /etc/puppet/foo", + "cp -R /tmp/dir/dingo /etc/puppet/dingo", + "cp -R /tmp/dir/bar /etc/puppet/bar", + "cp -R /tmp/dir/thing /etc/puppet/thing", + "chown -R root:puppet /etc/puppet/foo /etc/puppet/dingo /etc/puppet/bar /etc/puppet/thing", + "chmod -R 770 /etc/puppet/foo /etc/puppet/dingo /etc/puppet/bar /etc/puppet/thing", + "rm -rf /etc/puppet/foo /etc/puppet/dingo /etc/puppet/bar /etc/puppet/thing", + "mv /etc/puppet/foo.bak /etc/puppet/foo", + "mv /etc/puppet/bar.bak /etc/puppet/bar" ]) end it "backs up the original items that are shadowed by tmp items" do - testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppetlabs', '/tmp/dir') {} - expect(host.did.grep(%r{mv /etc/puppetlabs/\w+ })).to eq([ - "mv /etc/puppetlabs/foo /etc/puppetlabs/foo.bak", - "mv /etc/puppetlabs/bar /etc/puppetlabs/bar.bak", + testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppet', '/tmp/dir') {} + expect(host.did.grep(%r{mv /etc/puppet/\w+ })).to eq([ + "mv /etc/puppet/foo /etc/puppet/foo.bak", + "mv /etc/puppet/bar /etc/puppet/bar.bak", ]) end it "copies in all the tmp items into the working dir" do - testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppetlabs', '/tmp/dir') {} + testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppet', '/tmp/dir') {} expect(host.did.grep(%r{cp})).to eq([ - "cp -R /tmp/dir/foo /etc/puppetlabs/foo", - "cp -R /tmp/dir/dingo /etc/puppetlabs/dingo", - "cp -R /tmp/dir/bar /etc/puppetlabs/bar", - "cp -R /tmp/dir/thing /etc/puppetlabs/thing", + "cp -R /tmp/dir/foo /etc/puppet/foo", + "cp -R /tmp/dir/dingo /etc/puppet/dingo", + "cp -R /tmp/dir/bar /etc/puppet/bar", + "cp -R /tmp/dir/thing /etc/puppet/thing", ]) end it "opens the permissions on all copied files to 770 and sets ownership based on host settings" do - testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppetlabs', '/tmp/dir') {} + testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppet', '/tmp/dir') {} expect(host.did.grep(%r{ch(mod|own)})).to eq([ - "chown -R root:puppet /etc/puppetlabs/foo /etc/puppetlabs/dingo /etc/puppetlabs/bar /etc/puppetlabs/thing", - "chmod -R 770 /etc/puppetlabs/foo /etc/puppetlabs/dingo /etc/puppetlabs/bar /etc/puppetlabs/thing", + "chown -R root:puppet /etc/puppet/foo /etc/puppet/dingo /etc/puppet/bar /etc/puppet/thing", + "chmod -R 770 /etc/puppet/foo /etc/puppet/dingo /etc/puppet/bar /etc/puppet/thing", ]) end it "deletes all the tmp items from the working dir" do - testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppetlabs', '/tmp/dir') {} + testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppet', '/tmp/dir') {} expect(host.did.grep(%r{rm})).to eq([ - "rm -rf /etc/puppetlabs/foo /etc/puppetlabs/dingo /etc/puppetlabs/bar /etc/puppetlabs/thing", + "rm -rf /etc/puppet/foo /etc/puppet/dingo /etc/puppet/bar /etc/puppet/thing", ]) end it "replaces the original items that had been shadowed into the working dir" do - testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppetlabs', '/tmp/dir') {} - expect(host.did.grep(%r{mv /etc/puppetlabs/\w+\.bak})).to eq([ - "mv /etc/puppetlabs/foo.bak /etc/puppetlabs/foo", - "mv /etc/puppetlabs/bar.bak /etc/puppetlabs/bar" + testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppet', '/tmp/dir') {} + expect(host.did.grep(%r{mv /etc/puppet/\w+\.bak})).to eq([ + "mv /etc/puppet/foo.bak /etc/puppet/foo", + "mv /etc/puppet/bar.bak /etc/puppet/bar" ]) end it "always cleans up, even if the code we yield to raises an error" do expect do - testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppetlabs', '/tmp/dir') do + testcase.safely_shadow_directory_contents_and_yield(host, '/etc/puppet', '/tmp/dir') do raise 'oops' end end.to raise_error('oops') expect(host.did).to eq([ - "ls /etc/puppetlabs", + "ls /etc/puppet", "ls /tmp/dir", - "mv /etc/puppetlabs/foo /etc/puppetlabs/foo.bak", - "mv /etc/puppetlabs/bar /etc/puppetlabs/bar.bak", - "cp -R /tmp/dir/foo /etc/puppetlabs/foo", - "cp -R /tmp/dir/dingo /etc/puppetlabs/dingo", - "cp -R /tmp/dir/bar /etc/puppetlabs/bar", - "cp -R /tmp/dir/thing /etc/puppetlabs/thing", - "chown -R root:puppetlabs /etc/puppetlabs/foo /etc/puppetlabs/dingo /etc/puppetlabs/bar /etc/puppetlabs/thing", - "chmod -R 770 /etc/puppetlabs/foo /etc/puppetlabs/dingo /etc/puppetlabs/bar /etc/puppetlabs/thing", - "rm -rf /etc/puppetlabs/foo /etc/puppetlabs/dingo /etc/puppetlabs/bar /etc/puppetlabs/thing", - "mv /etc/puppetlabs/foo.bak /etc/puppetlabs/foo", - "mv /etc/puppetlabs/bar.bak /etc/puppetlabs/bar" + "mv /etc/puppet/foo /etc/puppet/foo.bak", + "mv /etc/puppet/bar /etc/puppet/bar.bak", + "cp -R /tmp/dir/foo /etc/puppet/foo", + "cp -R /tmp/dir/dingo /etc/puppet/dingo", + "cp -R /tmp/dir/bar /etc/puppet/bar", + "cp -R /tmp/dir/thing /etc/puppet/thing", + "chown -R root:puppet /etc/puppet/foo /etc/puppet/dingo /etc/puppet/bar /etc/puppet/thing", + "chmod -R 770 /etc/puppet/foo /etc/puppet/dingo /etc/puppet/bar /etc/puppet/thing", + "rm -rf /etc/puppet/foo /etc/puppet/dingo /etc/puppet/bar /etc/puppet/thing", + "mv /etc/puppet/foo.bak /etc/puppet/foo", + "mv /etc/puppet/bar.bak /etc/puppet/bar" ]) end end end diff --git a/acceptance/lib/puppet/acceptance/module_utils.rb b/acceptance/lib/puppet/acceptance/module_utils.rb index 4b0c94c4a..7886a4656 100644 --- a/acceptance/lib/puppet/acceptance/module_utils.rb +++ b/acceptance/lib/puppet/acceptance/module_utils.rb @@ -1,308 +1,308 @@ module Puppet module Acceptance module ModuleUtils # Return an array of module paths for a given host. # # Example return value: # # [ - # "/etc/puppetlabs/agent/environments/production/modules", - # "/etc/puppetlabs/agent/modules", - # "/opt/puppetlabs/agent/modules", + # "/etc/puppetlabs/puppet/environments/production/modules", + # "/etc/puppetlabs/puppet/modules", + # "/opt/puppet/share/puppet/modules", # ] # # @param host [String] hostname # @return [Array] paths for found modulepath def get_modulepaths_for_host (host) separator = ':' if host['platform'] =~ /windows/ separator = ';' end environment = on(host, puppet("config print environment")).stdout.chomp on(host, puppet("config print modulepath --environment #{environment}")).stdout.chomp.split(separator) end # Return a string of the default (first) path in modulepath for a given host. # # Example return value: # # "/etc/puppetlabs/puppet/environments/production/modules" # # @param host [String] hostname # @return [String] first path for found modulepath def get_default_modulepath_for_host (host) get_modulepaths_for_host(host)[0] end # Return an array of paths to installed modules for a given host. # # Example return value: # # [ # "/opt/puppet/share/puppet/modules/apt", # "/opt/puppet/share/puppet/modules/auth_conf", # "/opt/puppet/share/puppet/modules/concat", # ] # # @param host [String] hostname # @return [Array] paths for found modules def get_installed_modules_for_host (host) on host, puppet("module list --render-as pson") str = stdout.lines.to_a.last pat = /\(([^()]+)\)/ mods = str.scan(pat).flatten return mods end # Return a hash of array of paths to installed modules for a hosts. # The individual hostnames are the keys of the hash. The only value # for a given key is an array of paths for the found modules. # # Example return value: # # { # "my_master" => # [ # "/opt/puppet/share/puppet/modules/apt", # "/opt/puppet/share/puppet/modules/auth_conf", # "/opt/puppet/share/puppet/modules/concat", # ], # "my_agent01" => # [ # "/opt/puppet/share/puppet/modules/apt", # "/opt/puppet/share/puppet/modules/auth_conf", # "/opt/puppet/share/puppet/modules/concat", # ], # } # # @param hosts [Array] hostnames # @return [Hash] paths for found modules indexed by hostname def get_installed_modules_for_hosts (hosts) mods = {} hosts.each do |host| mods[host] = get_installed_modules_for_host host end return mods end # Compare the module paths in given hashes and remove paths that # are were not present in the first hash. The use case for this # method is to remove any modules that were installed during the # course of a test run. # # Installed module hashes would be gathered using the # `get_+installed_module_for_hosts` command in the setup stage # and teardown stages of a test. These hashes would be passed into # this method in order to find modules installed during the test # and delete them in order to return the SUT environments to their # initial state. # # TODO: Enhance to take versions into account, so that upgrade/ # downgrade events during a test does not persist in the SUT # environment. # # @param beginning_hash [Hash] paths for found modules indexed # by hostname. Taken in the setup stage of a test. # @param ending_hash [Hash] paths for found modules indexed # by hostname. Taken in the teardown stage of a test. def rm_installed_modules_from_hosts (beginning_hash, ending_hash) ending_hash.each do |host, mod_array| mod_array.each do |mod| if ! beginning_hash[host].include? mod on host, "rm -rf '#{mod}'" end end end end # Convert a semantic version number string to an integer. # # Example return value given an input of '1.2.42': # # 10242 # # @param semver [String] semantic version number def semver_to_i ( semver ) # semver assumed to be in format .. # calculation assumes that each segment is < 100 tmp = semver.split('.') tmp[0].to_i * 10000 + tmp[1].to_i * 100 + tmp[2].to_i end # Compare two given semantic version numbers. # # Returns an integer indicating the relationship between the two: # 0 indicates that both are equal # a value greater than 0 indicates that the semver1 is greater than semver2 # a value less than 0 indicates that the semver1 is less than semver2 # def semver_cmp ( semver1, semver2 ) semver_to_i(semver1) - semver_to_i(semver2) end # Assert that a module was installed according to the UI.. # # This is a wrapper to centralize the validation about how # the UI responded that a module was installed. # It is called after a call # to `on ( host )` and inspects # STDOUT for specific content. # # @param stdout [String] # @param module_author [String] the author portion of a module name # @param module_name [String] the name portion of a module name # @param module_verion [String] the version of the module to compare to # installed version # @param compare_op [String] the operator for comparing the verions of # the installed module def assert_module_installed_ui ( stdout, module_author, module_name, module_version = nil, compare_op = nil ) valid_compare_ops = {'==' => 'equal to', '>' => 'greater than', '<' => 'less than'} assert_match(/#{module_author}-#{module_name}/, stdout, "Notice that module '#{module_author}-#{module_name}' was installed was not displayed") if version /#{module_author}-#{module_name} \(.*v(\d+\.\d+\.\d+)/ =~ stdout installed_version = Regexp.last_match[1] if valid_compare_ops.include? compare_op assert_equal( true, semver_cmp(installed_version, module_version).send(compare_op, 0), "Installed version '#{installed_version}' of '#{module_name}' was not #{valid_compare_ops[compare_op]} '#{module_version}'") end end end # Assert that a module is installed on disk. # # @param host [HOST] the host object to make the remote call on # @param module_name [String] the name portion of a module name # @param optional moduledir [String, Array] the path where the module should be, will # iterate over components of the modulepath by default. def assert_module_installed_on_disk (host, module_name, moduledir=nil) moduledir ||= get_modulepaths_for_host(host) modulepath = moduledir.is_a?(Array) ? moduledir : [moduledir] moduledir= nil modulepath.each do |i| # module directory should exist if on(host, %Q{[ -d "#{i}/#{module_name}" ]}, :acceptable_exit_codes => (0..255)).exit_code == 0 moduledir = i end end fail_test('module directory not found') unless moduledir owner = '' group = '' on host, %Q{ls -ld "#{moduledir}"} do listing = stdout.split(' ') owner = listing[2] group = listing[3] end # A module's files should have: # * a mode of 644 (755, if they're a directory) # * owner == owner of moduledir # * group == group of moduledir on host, %Q{ls -alR "#{moduledir}/#{module_name}"} do listings = stdout.split("\n") listings = listings.grep(/^[bcdlsp-]/) listings = listings.reject { |l| l =~ /\.\.$/ } listings.each do |line| fileinfo = parse_ls(line) assert_equal owner, fileinfo[:owner] assert_equal group, fileinfo[:group] if fileinfo[:filetype] == 'd' assert_equal 'rwx', fileinfo[:perms][:user] assert_equal 'r-x', fileinfo[:perms][:group] assert_equal 'r-x', fileinfo[:perms][:other] else assert_equal 'rw-', fileinfo[:perms][:user] assert_equal 'r--', fileinfo[:perms][:group] assert_equal 'r--', fileinfo[:perms][:other] end end end end LS_REGEX = %r[(.)(...)(...)(...).?\s+\d+\s+(\w+)\s+(\w+).*(\S+)$] def parse_ls(line) match = line.match(LS_REGEX) if match.nil? fail_test "#{line.inspect} doesn't match ls output regular expression" end captures = match.captures { :filetype => captures[0], :perms => { :user => captures[1], :group => captures[2], :other => captures[3], }, :owner => captures[4], :group => captures[5], :file => captures[6] } end private :parse_ls # Assert that a module is not installed on disk. # # @param host [HOST] the host object to make the remote call on # @param module_name [String] the name portion of a module name # @param optional moduledir [String, Array] the path where the module should be, will # iterate over components of the modulepath by default. def assert_module_not_installed_on_disk (host, module_name, moduledir=nil) moduledir ||= get_modulepaths_for_host(host) modulepath = moduledir.is_a?(Array) ? moduledir : [moduledir] moduledir= nil modulepath.each do |i| # module directory should not exist on host, %Q{[ ! -d "#{i}/#{module_name}" ]} end end # Create a simple directory environment and puppet.conf at :tmpdir. # # @note Also registers a teardown block to remove generated files. # # @param tmpdir [String] directory to contain all the # generated environment files # @return [String] path to the new puppet configuration file defining the # environments def generate_base_directory_environments(tmpdir) puppet_conf = "#{tmpdir}/puppet2.conf" dir_envs = "#{tmpdir}/environments" step 'Configure a the direnv directory environment' apply_manifest_on master, %Q{ File { ensure => directory, owner => #{master.puppet['user']}, group => #{master.puppet['group']}, mode => "0750", } file { [ '#{dir_envs}', '#{dir_envs}/direnv', ]: } file { '#{puppet_conf}': ensure => file, content => " [main] environmentpath=#{dir_envs} " } } return puppet_conf end end end end diff --git a/acceptance/setup/git/pre-suite/030_PuppetMasterSanity.rb b/acceptance/setup/git/pre-suite/030_PuppetMasterSanity.rb index ad9ca6493..926256609 100644 --- a/acceptance/setup/git/pre-suite/030_PuppetMasterSanity.rb +++ b/acceptance/setup/git/pre-suite/030_PuppetMasterSanity.rb @@ -1,16 +1,16 @@ test_name "Puppet Master sanity checks: PID file and SSL dir creation" -pidfile = '/var/run/puppetlabs/master.pid' +pidfile = '/var/lib/puppet/run/master.pid' hostname = on(master, 'facter hostname').stdout.strip fqdn = on(master, 'facter fqdn').stdout.strip with_puppet_running_on(master, :main => { :dns_alt_names => "puppet,#{hostname},#{fqdn}", :verbose => true, :noop => true }) do # SSL dir created? step "SSL dir created?" on master, "[ -d #{master['puppetpath']}/ssl ]" # PID file exists? step "PID file created?" on master, "[ -f #{pidfile} ]" end diff --git a/conf/puppet.conf b/conf/puppet.conf deleted file mode 100644 index 4a8ae4c2f..000000000 --- a/conf/puppet.conf +++ /dev/null @@ -1,9 +0,0 @@ -[main] - # Where Puppet stores dynamic and growing data. - vardir=/opt/puppetlabs/agent/cache - - # The Puppet log directory. - logdir=/var/log/puppetlabs/agent - - # Where Puppet PID files are kept. - rundir=/var/run/puppetlabs diff --git a/ext/debian/puppet.conf b/ext/debian/puppet.conf deleted file mode 120000 index 95ebaf6c4..000000000 --- a/ext/debian/puppet.conf +++ /dev/null @@ -1 +0,0 @@ -../../conf/puppet.conf \ No newline at end of file diff --git a/ext/debian/puppet.conf b/ext/debian/puppet.conf new file mode 100644 index 000000000..79830082e --- /dev/null +++ b/ext/debian/puppet.conf @@ -0,0 +1,14 @@ +[main] +logdir=/var/log/puppet +vardir=/var/lib/puppet +ssldir=$vardir/ssl +rundir=/var/run/puppet +factpath=$vardir/lib/facter +templatedir=$confdir/templates + +[master] +# These are needed when the puppetmaster is run by passenger +# and can safely be removed if webrick is used. +ssl_client_header = SSL_CLIENT_S_DN +ssl_client_verify_header = SSL_CLIENT_VERIFY + diff --git a/ext/debian/puppet.init b/ext/debian/puppet.init index e9234be35..bba849907 100644 --- a/ext/debian/puppet.init +++ b/ext/debian/puppet.init @@ -1,119 +1,119 @@ #! /bin/sh ### BEGIN INIT INFO # Provides: puppet # Required-Start: $network $named $remote_fs $syslog # Required-Stop: $network $named $remote_fs $syslog # Should-Start: puppet # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/puppet DAEMON_OPTS="" NAME="agent" PROCNAME="puppet" DESC="puppet agent" -PIDFILE="/var/run/puppetlabs/${NAME}.pid" +PIDFILE="/var/run/puppet/${NAME}.pid" test -x $DAEMON || exit 0 [ -r /etc/default/puppet ] && . /etc/default/puppet . /lib/lsb/init-functions is_true() { if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then return 0 else return 1 fi } reload_puppet_agent() { start-stop-daemon --stop --quiet --signal HUP --pidfile $PIDFILE --name $PROCNAME } start_puppet_agent() { if is_true "$START" ; then start-stop-daemon --start --quiet --pidfile $PIDFILE \ --startas $DAEMON -- $NAME $DAEMON_OPTS else echo "" echo "puppet not configured to start, please edit /etc/default/puppet to enable" fi } stop_puppet_agent() { start-stop-daemon --stop --retry TERM/10/KILL/5 --quiet --oknodo --pidfile $PIDFILE --name $PROCNAME rm -f "$PIDFILE" } status_puppet_agent() { if (type status_of_proc > /dev/null 2>&1) ; then status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}" else status_of_proc() { local pidfile daemon name status pidfile= OPTIND=1 while getopts p: opt ; do case "$opt" in p) pidfile="$OPTARG";; esac done shift $(($OPTIND - 1)) if [ -n "$pidfile" ]; then pidfile="-p $pidfile" fi daemon="$1" name="$2" status="0" pidofproc $pidfile $daemon >/dev/null || status="$?" if [ "$status" = 0 ]; then log_success_msg "$name is running" return 0 elif [ "$status" = 4 ]; then log_failure_msg "could not access PID file for $name" return $status else log_failure_msg "$name is not running" return $status fi } status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}" fi } case "$1" in start) log_begin_msg "Starting $DESC" start_puppet_agent log_end_msg $? ;; stop) log_begin_msg "Stopping $DESC" stop_puppet_agent log_end_msg $? ;; reload) log_begin_msg "Reloading $DESC" reload_puppet_agent log_end_msg $? ;; status) status_puppet_agent ;; restart|force-reload) log_begin_msg "Restarting $DESC" stop_puppet_agent start_puppet_agent log_end_msg $? ;; *) echo "Usage: $0 {start|stop|status|restart|force-reload|reload}" >&2 exit 1 ;; esac diff --git a/ext/debian/puppetmaster.init b/ext/debian/puppetmaster.init index 145eebafe..d3dffac33 100644 --- a/ext/debian/puppetmaster.init +++ b/ext/debian/puppetmaster.init @@ -1,137 +1,137 @@ #! /bin/sh ### BEGIN INIT INFO # Provides: puppetmaster # Required-Start: $network $named $remote_fs $syslog # Required-Stop: $network $named $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/puppet DAEMON_OPTS="" NAME=master DESC="puppet master" test -x $DAEMON || exit 0 [ -r /etc/default/puppetmaster ] && . /etc/default/puppetmaster . /lib/lsb/init-functions if [ ! -d /var/run/puppet ]; then mkdir -p /var/run/puppet fi -chown puppet:puppet /var/run/puppetlabs +chown puppet:puppet /var/run/puppet mongrel_warning="The mongrel servertype is no longer built-in to Puppet. It appears as though mongrel is being used, as the number of puppetmasters is greater than one. Starting the puppetmaster service will not behave as expected until this is resolved. Only the first port has been used in the service, and only one puppetmaster has been started. These settings are defined in /etc/default/puppetmaster" # Warn about removed and unsupported mongrel servertype if ([ -n "$PUPPETMASTERS" ] && [ ${PUPPETMASTERS} -gt 1 ]) || [ "${SERVERTYPE}" = "mongrel" ]; then echo $mongrel_warning echo fi is_true() { if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then return 0 else return 1 fi } start_puppet_master() { if is_true "$START" ; then - start-stop-daemon --start --quiet --pidfile /var/run/puppetlabs/${NAME}.pid \ + start-stop-daemon --start --quiet --pidfile /var/run/puppet/${NAME}.pid \ --startas $DAEMON -- $NAME $DAEMON_OPTS --masterport=$PORT else echo "" echo "puppetmaster not configured to start, please edit /etc/default/puppetmaster to enable" fi } stop_puppet_master() { - start-stop-daemon --stop --retry TERM/10/KILL/5 --quiet --oknodo --pidfile /var/run/puppetlabs/${NAME}.pid + start-stop-daemon --stop --retry TERM/10/KILL/5 --quiet --oknodo --pidfile /var/run/puppet/${NAME}.pid } status_puppet_master() { if ( ! type status_of_proc > /dev/null 2>&1 ) ; then status_of_proc() { local pidfile daemon name status pidfile= OPTIND=1 while getopts p: opt ; do case "$opt" in p) pidfile="$OPTARG";; esac done shift $(($OPTIND - 1)) if [ -n "$pidfile" ]; then pidfile="-p $pidfile" fi daemon="$1" name="$2" status="0" pidofproc $pidfile $daemon >/dev/null || status="$?" if [ "$status" = 0 ]; then log_success_msg "$name is running" return 0 elif [ "$status" = 4 ]; then log_failure_msg "could not access PID file for $name" return $status else log_failure_msg "$name is not running" return $status fi } fi if is_true "$START" ; then - status_of_proc -p "/var/run/puppetlabs/${NAME}.pid" "${DAEMON}" "${NAME}" + status_of_proc -p "/var/run/puppet/${NAME}.pid" "${DAEMON}" "${NAME}" else echo "" echo "puppetmaster not configured to start" - status_of_proc -p "/var/run/puppetlabs/${NAME}.pid" "${DAEMON}" "${NAME}" + status_of_proc -p "/var/run/puppet/${NAME}.pid" "${DAEMON}" "${NAME}" fi } case "$1" in start) log_begin_msg "Starting $DESC" start_puppet_master log_end_msg $? ;; stop) log_begin_msg "Stopping $DESC" stop_puppet_master log_end_msg $? ;; reload) # Do nothing, as Puppetmaster rechecks its config automatically ;; status) status_puppet_master ;; restart|force-reload) log_begin_msg "Restarting $DESC" stop_puppet_master start_puppet_master log_end_msg $? ;; *) echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2 exit 1 ;; esac # vim: tabstop=4:softtabstop=4:shiftwidth=4:expandtab diff --git a/ext/gentoo/conf.d/puppet b/ext/gentoo/conf.d/puppet index df8ccff6d..e7e62574b 100644 --- a/ext/gentoo/conf.d/puppet +++ b/ext/gentoo/conf.d/puppet @@ -1,5 +1,5 @@ # Location of PID files -PUPPET_PID_DIR="/var/run/puppetlabs" +PUPPET_PID_DIR="/var/run/puppet" # You may specify other parameters to the puppet client here #PUPPET_EXTRA_OPTS="" diff --git a/ext/gentoo/conf.d/puppetmaster b/ext/gentoo/conf.d/puppetmaster index 9f10e59f8..37b04d44d 100644 --- a/ext/gentoo/conf.d/puppetmaster +++ b/ext/gentoo/conf.d/puppetmaster @@ -1,12 +1,12 @@ # Location of PID files -PUPPETMASTER_PID_DIR="/var/run/puppetlabs" +PUPPETMASTER_PID_DIR="/var/run/puppet" # Location of the main manifest #PUPPETMASTER_MANIFEST="/etc/puppet/manifests/site.pp" # Where to log general messages to. # Specify syslog to send log messages to the system log. #PUPPETMASTER_LOG="syslog" # You may specify other parameters to the puppetmaster here #PUPPETMASTER_EXTRA_OPTS="--no-ca" diff --git a/ext/gentoo/puppet/puppet.conf b/ext/gentoo/puppet/puppet.conf deleted file mode 120000 index a12b7da15..000000000 --- a/ext/gentoo/puppet/puppet.conf +++ /dev/null @@ -1 +0,0 @@ -../../../conf/puppet.conf \ No newline at end of file diff --git a/ext/gentoo/puppet/puppet.conf b/ext/gentoo/puppet/puppet.conf new file mode 100644 index 000000000..2f25fc051 --- /dev/null +++ b/ext/gentoo/puppet/puppet.conf @@ -0,0 +1,20 @@ +[main] + # The Puppet log directory. + # The default value is '$vardir/log'. + logdir = /var/log/puppet + + # Where Puppet PID files are kept. + # The default value is '$vardir/run'. + rundir = /var/run/puppet + + # Where SSL certificates are kept. + # The default value is '$confdir/ssl'. + ssldir = $vardir/ssl + +[puppetd] + # The file in which puppetd stores a list of the classes + # associated with the retrieved configuratiion. Can be loaded in + # the separate ``puppet`` executable using the ``--loadclasses`` + # option. + # The default value is '$confdir/classes.txt'. + classfile = $vardir/classes.txt diff --git a/ext/ips/puppet.conf b/ext/ips/puppet.conf deleted file mode 120000 index 95ebaf6c4..000000000 --- a/ext/ips/puppet.conf +++ /dev/null @@ -1 +0,0 @@ -../../conf/puppet.conf \ No newline at end of file diff --git a/ext/ips/puppet.conf b/ext/ips/puppet.conf new file mode 100644 index 000000000..c0abd0af5 --- /dev/null +++ b/ext/ips/puppet.conf @@ -0,0 +1,23 @@ + +[main] + vardir = /var/lib/puppet + + # The Puppet log directory. + # The default value is '$vardir/log'. + logdir = /var/log/puppet + + # Where Puppet PID files are kept. + # The default value is '$vardir/run'. + rundir = /var/run/puppet + + # Where SSL certificates are kept. + # The default value is '$confdir/ssl'. + ssldir = $vardir/ssl + +[agent] + # The file in which puppetd stores a list of the classes + # associated with the retrieved configuratiion. Can be loaded in + # the separate ``puppet`` executable using the ``--loadclasses`` + # option. + # The default value is '$confdir/classes.txt'. + classfile = $vardir/classes.txt diff --git a/ext/redhat/client.init b/ext/redhat/client.init index 265401cae..7e93e564f 100644 --- a/ext/redhat/client.init +++ b/ext/redhat/client.init @@ -1,119 +1,119 @@ #!/bin/bash # puppet Init script for running the puppet client daemon # # Author: Duane Griffin # David Lutterkort # # chkconfig: - 98 02 # # description: Enables periodic system configuration checks through puppet. # processname: puppet # config: /etc/sysconfig/puppet # Source function library. . /etc/rc.d/init.d/functions PATH=/usr/bin:/sbin:/bin:/usr/sbin export PATH [ -f /etc/sysconfig/puppet ] && . /etc/sysconfig/puppet lockfile=${LOCKFILE-/var/lock/subsys/puppet} -pidfile=${PIDFILE-/var/run/puppetlabs/agent.pid} +pidfile=${PIDFILE-/var/run/puppet/agent.pid} puppetd=${PUPPETD-/usr/bin/puppet} RETVAL=0 PUPPET_OPTS="agent " [ -n "${PUPPET_SERVER}" ] && PUPPET_OPTS="${PUPPET_OPTS} --server=${PUPPET_SERVER}" [ -n "$PUPPET_LOG" ] && PUPPET_OPTS="${PUPPET_OPTS} --logdest=${PUPPET_LOG}" [ -n "$PUPPET_PORT" ] && PUPPET_OPTS="${PUPPET_OPTS} --masterport=${PUPPET_PORT}" # Determine if we can use the -p option to daemon, killproc, and status. # RHEL < 5 can't. if status | grep -q -- '-p' 2>/dev/null; then daemonopts="--pidfile $pidfile" pidopts="-p $pidfile" fi # Figure out if the system just booted. Let's assume # boot doesn't take longer than 5 minutes ## Not used for now ##[ -n "$INIT_VERSION" ] && PUPPET_OPTS="${PUPPET_OPTS} --fullrun" start() { echo -n $"Starting puppet agent: " daemon $daemonopts $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } stop() { echo -n $"Stopping puppet agent: " killproc $pidopts $puppetd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } reload() { echo -n $"Restarting puppet agent: " killproc $pidopts $puppetd -HUP RETVAL=$? echo return $RETVAL } restart() { stop start } rh_status() { status $pidopts $puppetd RETVAL=$? return $RETVAL } rh_status_q() { rh_status >/dev/null 2>&1 } genconfig() { echo -n $"Generate puppet agent configuration: " $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} --genconfig } case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload|force-reload) reload ;; condrestart|try-restart) rh_status_q || exit 0 restart ;; status) rh_status ;; once) shift $puppetd ${PUPPET_OPTS} --onetime ${PUPPET_EXTRA_OPTS} $@ ;; genconfig) genconfig ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|once|genconfig}" exit 1 esac exit $RETVAL diff --git a/ext/redhat/puppet.conf b/ext/redhat/puppet.conf deleted file mode 120000 index 95ebaf6c4..000000000 --- a/ext/redhat/puppet.conf +++ /dev/null @@ -1 +0,0 @@ -../../conf/puppet.conf \ No newline at end of file diff --git a/ext/redhat/puppet.conf b/ext/redhat/puppet.conf new file mode 100644 index 000000000..cb1be6494 --- /dev/null +++ b/ext/redhat/puppet.conf @@ -0,0 +1,20 @@ +[main] + # The Puppet log directory. + # The default value is '$vardir/log'. + logdir = /var/log/puppet + + # Where Puppet PID files are kept. + # The default value is '$vardir/run'. + rundir = /var/run/puppet + + # Where SSL certificates are kept. + # The default value is '$confdir/ssl'. + ssldir = $vardir/ssl + +[agent] + # The file in which puppetd stores a list of the classes + # associated with the retrieved configuratiion. Can be loaded in + # the separate ``puppet`` executable using the ``--loadclasses`` + # option. + # The default value is '$confdir/classes.txt'. + classfile = $vardir/classes.txt diff --git a/ext/redhat/server.init b/ext/redhat/server.init index 73a51bfde..c34182b32 100644 --- a/ext/redhat/server.init +++ b/ext/redhat/server.init @@ -1,128 +1,128 @@ #!/bin/bash # puppetmaster This shell script enables the puppetmaster server. # # Authors: Duane Griffin # Peter Meier (Mongrel enhancements) # # chkconfig: - 65 45 # # description: Server for the puppet system management tool. # processname: puppetmaster PATH=/usr/bin:/sbin:/bin:/usr/sbin export PATH lockfile=/var/lock/subsys/puppetmaster -pidfile=/var/run/puppetlabs/master.pid +pidfile=/var/run/puppet/master.pid # Source function library. . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/puppetmaster ]; then . /etc/sysconfig/puppetmaster fi PUPPETMASTER_OPTS="master " [ -n "$PUPPETMASTER_MANIFEST" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --manifest=${PUPPETMASTER_MANIFEST}" [ -n "$PUPPETMASTER_PORTS" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --masterport=${PUPPETMASTER_PORTS[0]}" [ -n "$PUPPETMASTER_LOG" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --logdest ${PUPPETMASTER_LOG}" PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} \ ${PUPPETMASTER_EXTRA_OPTS}" # Determine if we can use the -p option to daemon, killproc, and status. # RHEL < 5 can't. if status | grep -q -- '-p' 2>/dev/null; then daemonopts="--pidfile $pidfile" pidopts="-p $pidfile" fi mongrel_warning="The mongrel servertype is no longer built-in to Puppet. It appears as though mongrel is being used, as the number of ports is greater than one. Starting the puppetmaster service will not behave as expected until this is resolved. Only the first port has been used in the service. These settings are defined at /etc/sysconfig/puppetmaster" # Warn about removed and unsupported mongrel servertype if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then echo $mongrel_warning echo fi RETVAL=0 PUPPETMASTER=/usr/bin/puppet start() { echo -n $"Starting puppetmaster: " # Confirm the manifest exists if [ -r $PUPPETMASTER_MANIFEST ]; then daemon $daemonopts $PUPPETMASTER $PUPPETMASTER_OPTS RETVAL=$? else failure $"Manifest does not exist: $PUPPETMASTER_MANIFEST" echo return 1 fi [ $RETVAL -eq 0 ] && touch "$lockfile" echo return $RETVAL } stop() { echo -n $"Stopping puppetmaster: " killproc $pidopts $PUPPETMASTER RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f "$lockfile" return $RETVAL } restart() { stop start } genconfig() { echo -n $"Generate configuration puppetmaster: " $PUPPETMASTER $PUPPETMASTER_OPTS --genconfig } rh_status() { status $pidopts $PUPPETMASTER RETVAL=$? return $RETVAL } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) start ;; stop) stop ;; restart|reload|force-reload) restart ;; condrestart) rh_status_q || exit 0 restart ;; status) rh_status ;; genconfig) genconfig ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|genconfig}" exit 1 esac exit $RETVAL # vim: tabstop=4:softtabstop=4:shiftwidth=4:expandtab diff --git a/ext/solaris/smf/svc-puppetd b/ext/solaris/smf/svc-puppetd index 799fea833..8acc19cfa 100755 --- a/ext/solaris/smf/svc-puppetd +++ b/ext/solaris/smf/svc-puppetd @@ -1,64 +1,64 @@ #!/bin/sh # This is the /etc/init.d file for puppetd # Modified for CSW # # description: puppetd - Puppet Automation Client # . /lib/svc/share/smf_include.sh prefix=/opt/csw exec_prefix=/opt/csw sysconfdir=/opt/csw/etc sbindir=/opt/csw/sbin -pidfile=/var/run/puppetlabs/agent.pid +pidfile=/var/lib/puppet/run/agent.pid case "$1" in start) cd / # Start daemons. printf "Starting Puppet client services:" /opt/csw/sbin/puppetd printf " puppetd" echo "" ;; stop) printf "Stopping Puppet client services:" kill `cat $pidfile` printf " puppetd" echo "" ;; restart) printf "Restarting Puppet client services:" kill -HUP `cat $pidfile` printf " puppetd" echo "" ;; reload) printf "Reloading Puppet client services:" kill -HUP `cat $pidfile` printf " puppetd" echo "" ;; status) if [ -f $pidfile ]; then pid=`cat $pidfile` curpid=`pgrep puppetd` if [ "$pid" -eq "$curpid" ]; then exit 0 else exit 1 fi else exit 1 fi esac exit 0 diff --git a/ext/solaris/smf/svc-puppetmasterd b/ext/solaris/smf/svc-puppetmasterd index 47e9c7997..683324dec 100755 --- a/ext/solaris/smf/svc-puppetmasterd +++ b/ext/solaris/smf/svc-puppetmasterd @@ -1,60 +1,60 @@ #!/bin/sh # . /lib/svc/share/smf_include.sh prefix=/opt/csw exec_prefix=/opt/csw sysconfdir=/opt/csw/etc sbindir=/opt/csw/sbin -pidfile=/var/run/puppetlabs/master.pid +pidfile=/var/lib/puppet/run/master.pid case "$1" in start) cd / # Start daemons. printf "Starting Puppet server services:" /opt/csw/sbin/puppetmasterd printf " puppetmaster" echo "" ;; stop) printf "Stopping Puppet server services:" kill `cat $pidfile` printf " puppetmasterd" echo "" ;; restart) printf "Restarting Puppet server services:" kill -HUP `cat $pidfile` printf " puppetmasterd" echo "" ;; reload) printf "Reloading Puppet server services:" kill -HUP `cat $pidfile` printf " puppetmasterd" echo "" ;; status) if [ -f $pidfile ]; then pid=`cat $pidfile` curpid=`pgrep puppetmasterd` if [ "$pid" -eq "$curpid" ]; then exit 0 else exit 1 fi else exit 1 fi esac exit 0 diff --git a/ext/suse/client.init b/ext/suse/client.init index c111d7925..e54f462f4 100644 --- a/ext/suse/client.init +++ b/ext/suse/client.init @@ -1,144 +1,144 @@ #!/bin/bash # puppet Init script for running the puppet client daemon # # Author: Duane Griffin # David Lutterkort # Martin Vuk (SuSE support) # # chkconfig: - 98 02 # # description: Enables periodic system configuration checks through puppet. # processname: puppet # config: /etc/sysconfig/puppet ### BEGIN INIT INFO # Provides: puppet # Required-Start: $local_fs $remote_fs $network $syslog # Should-Start: puppet # Required-Stop: $local_fs $remote_fs $network $syslog # Should-Stop: puppet # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: puppet # Description: Enables periodic system configuration checks through puppet. ### END INIT INFO # Shell functions sourced from /etc/rc.status: # rc_check check and set local and overall rc status # rc_status check and set local and overall rc status # rc_status -v ditto but be verbose in local rc status # rc_status -v -r ditto and clear the local rc status # rc_failed set local and overall rc status to failed # rc_reset clear local rc status (overall remains) # rc_exit exit appropriate to overall rc status [ -f /etc/rc.status ] && . /etc/rc.status [ -f /etc/sysconfig/puppet ] && . /etc/sysconfig/puppet lockfile=${LOCKFILE-/var/lock/subsys/puppet} -pidfile=${PIDFILE-/var/run/puppetlabs/agent.pid} +pidfile=${PIDFILE-/var/run/puppet/agent.pid} puppetd=${PUPPETD-/usr/bin/puppet} RETVAL=0 PUPPET_OPTS="agent" [ -n "${PUPPET_SERVER}" ] && PUPPET_OPTS="${PUPPET_OPTS} --server=${PUPPET_SERVER}" [ -n "$PUPPET_LOG" ] && PUPPET_OPTS="${PUPPET_OPTS} --logdest=${PUPPET_LOG}" [ -n "$PUPPET_PORT" ] && PUPPET_OPTS="${PUPPET_OPTS} --port=${PUPPET_PORT}" # First reset status of this service rc_reset # Return values acc. to LSB for all commands but status: # 0 - success # 1 - misc error # 2 - invalid or excess args # 3 - unimplemented feature (e.g. reload) # 4 - insufficient privilege # 5 - program not installed # 6 - program not configured # # Note that starting an already running service, stopping # or restarting a not-running service as well as the restart # with force-reload (in case signalling is not supported) are # considered a success. case "$1" in start) echo -n "Starting puppet services." ## Start daemon with startproc(8). If this fails ## the echo return value is set appropriate. # startproc should return 0, even if service is # already running to match LSB spec. startproc -p ${pidfile} $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} && touch ${lockfile} # Remember status and be verbose rc_status -v ;; stop) echo -n "Shutting down puppet:" ## Stop daemon with killproc(8) and if this fails ## set echo the echo return value. killproc -QUIT -p ${pidfile} $puppetd && rm -f ${lockfile} ${pidfile} # Remember status and be verbose rc_status -v ;; try-restart) ## Stop the service and if this succeeds (i.e. the ## service was running before), start it again. $0 status >/dev/null && $0 restart # Remember status and be quiet rc_status ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $0 stop $0 start # Remember status and be quiet rc_status ;; force-reload) ## Signal the daemon to reload its config. Most daemons ## do this on signal 1 (SIGHUP). ## If it does not support it, restart. echo -n "Reload service puppet" ## if it supports it: killproc -HUP -p ${pidfile} $puppetd rc_status -v ;; reload) ## Like force-reload, but if daemon does not support ## signalling, do nothing (!) # If it supports signalling: echo -n "Reload puppet services." killproc -HUP -p ${pidfile} $puppetd rc_status -v ;; status) echo -n "Checking for service puppetd: " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. # Status has a slightly different for the status command: # 0 - service running # 1 - service dead, but /var/run/ pid file exists # 2 - service dead, but /var/lock/ lock file exists # 3 - service not running # NOTE: checkproc returns LSB compliant status values. checkproc -p ${pidfile} $puppetd rc_status -v ;; once) shift $puppetd ${PUPPET_OPTS} --onetime ${PUPPET_EXTRA_OPTS} $@ ;; *) echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|once}" exit 1 esac rc_exit diff --git a/ext/suse/server.init b/ext/suse/server.init index e109469b2..632ab034a 100644 --- a/ext/suse/server.init +++ b/ext/suse/server.init @@ -1,173 +1,173 @@ #!/bin/bash # puppetmaster This shell script enables the puppetmaster server. # # Author: Duane Griffin # Martin Vuk (SuSE support) # # chkconfig: - 65 45 # # description: Server for the puppet system management tool. # processname: puppetmaster ### BEGIN INIT INFO # Provides: puppetmaster # Required-Start: $local_fs $remote_fs $network $syslog # Should-Start: puppetmaster # Required-Stop: $local_fs $remote_fs $network $syslog # Should-Stop: puppetmaster # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: puppetmaster # Description: Server for the puppet system management tool. ### END INIT INFO # Shell functions sourced from /etc/rc.status: # rc_check check and set local and overall rc status # rc_status check and set local and overall rc status # rc_status -v ditto but be verbose in local rc status # rc_status -v -r ditto and clear the local rc status # rc_failed set local and overall rc status to failed # rc_reset clear local rc status (overall remains) # rc_exit exit appropriate to overall rc status lockfile=/var/lock/subsys/puppetmaster -pidfile=/var/run/puppetlabs/master.pid +pidfile=/var/run/puppet/master.pid # Source function library. [ -f /etc/rc.status ] && . /etc/rc.status if [ -f /etc/sysconfig/puppetmaster ]; then . /etc/sysconfig/puppetmaster fi PUPPETMASTER_OPTS="master " [ -n "$PUPPETMASTER_MANIFEST" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --manifest=${PUPPETMASTER_MANIFEST}" [ -n "$PUPPETMASTER_PORTS" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --masterport=${PUPPETMASTER_PORTS[0]}" [ -n "$PUPPETMASTER_LOG" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --logdest ${PUPPETMASTER_LOG}" PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} \ ${PUPPETMASTER_EXTRA_OPTS}" RETVAL=0 PUPPETMASTER=/usr/bin/puppet mongrel_warning="The mongrel servertype is no longer built-in to Puppet. It appears as though mongrel is being used, as the number of ports is greater than one. Starting the puppetmaster service will not behave as expected until this is resolved. Only the first port has been used in the service. These settings are defined at /etc/sysconfig/puppetmaster" # Warn about removed and unsupported mongrel servertype if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then echo $mongrel_warning echo fi start() { echo -n $"Starting puppetmaster: " echo return $RETVAL } # First reset status of this service rc_reset # Return values acc. to LSB for all commands but status: # 0 - success # 1 - misc error # 2 - invalid or excess args # 3 - unimplemented feature (e.g. reload) # 4 - insufficient privilege # 5 - program not installed # 6 - program not configured # # Note that starting an already running service, stopping # or restarting a not-running service as well as the restart # with force-reload (in case signalling is not supported) are # considered a success. case "$1" in start) echo -n "Starting puppetmaster services." ## Start daemon with startproc(8). If this fails ## the echo return value is set appropriate. # startproc should return 0, even if service is # already running to match LSB spec. # Confirm the manifest exists if [ -r $PUPPETMASTER_MANIFEST ]; then startproc -p ${pidfile} $PUPPETMASTER $PUPPETMASTER_OPTS && touch "$lockfile" else rc_failed echo "Manifest does not exist: $PUPPETMASTER_MANIFEST" fi # Remember status and be verbose rc_status -v ;; stop) echo -n "Shutting down puppetmaster:" ## Stop daemon with killproc(8) and if this fails ## set echo the echo return value. killproc -QUIT -p ${pidfile} $PUPPETMASTER && rm -f ${lockfile} ${pidfile} # Remember status and be verbose rc_status -v ;; try-restart) ## Stop the service and if this succeeds (i.e. the ## service was running before), start it again. $0 status >/dev/null && $0 restart # Remember status and be quiet rc_status ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $0 stop $0 start # Remember status and be quiet rc_status ;; force-reload) ## Signal the daemon to reload its config. Most daemons ## do this on signal 1 (SIGHUP). ## If it does not support it, restart. echo -n "Reload service puppet" ## if it supports it: killproc -HUP -p ${pidfile} $PUPPETMASTER rc_status -v ;; reload) ## Like force-reload, but if daemon does not support ## signalling, do nothing (!) # If it supports signalling: echo -n "Reload puppet services." killproc -HUP -p ${pidfile} $PUPPETMASTER rc_status -v ;; status) echo -n "Checking for service puppetmaster: " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. # Status has a slightly different for the status command: # 0 - service running # 1 - service dead, but /var/run/ pid file exists # 2 - service dead, but /var/lock/ lock file exists # 3 - service not running # NOTE: checkproc returns LSB compliant status values. checkproc -p ${pidfile} $PUPPETMASTER rc_status -v ;; *) echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" exit 1 esac rc_exit diff --git a/install.rb b/install.rb index 569338c0d..a0aa1f88e 100755 --- a/install.rb +++ b/install.rb @@ -1,474 +1,429 @@ #! /usr/bin/env ruby #-- # Copyright 2004 Austin Ziegler # Install utility. Based on the original installation script for rdoc by the # Pragmatic Programmers. # # This program is free software. It may be redistributed and/or modified under # the terms of the GPL version 2 (or later) or the Ruby licence. # # Usage # ----- # In most cases, if you have a typical project layout, you will need to do # absolutely nothing to make this work for you. This layout is: # # bin/ # executable files -- "commands" # lib/ # the source of the library # # The default behaviour: # 1) Build Rdoc documentation from all files in bin/ (excluding .bat and .cmd), # all .rb files in lib/, ./README, ./ChangeLog, and ./Install. # 2) Build ri documentation from all files in bin/ (excluding .bat and .cmd), # and all .rb files in lib/. This is disabled by default on Microsoft Windows. # 3) Install commands from bin/ into the Ruby bin directory. On Windows, if a # if a corresponding batch file (.bat or .cmd) exists in the bin directory, # it will be copied over as well. Otherwise, a batch file (always .bat) will # be created to run the specified command. # 4) Install all library files ending in .rb from lib/ into Ruby's # site_lib/version directory. # #++ require 'rbconfig' require 'find' require 'fileutils' require 'tempfile' begin require 'ftools' # apparently on some system ftools doesn't get loaded $haveftools = true rescue LoadError puts "ftools not found. Using FileUtils instead.." $haveftools = false end require 'optparse' require 'ostruct' begin require 'rdoc/rdoc' $haverdoc = true rescue LoadError puts "Missing rdoc; skipping documentation" $haverdoc = false end PREREQS = %w{openssl facter cgi hiera} MIN_FACTER_VERSION = 1.5 InstallOptions = OpenStruct.new def glob(list) g = list.map { |i| Dir.glob(i) } g.flatten! g.compact! g end def do_configs(configs, target, strip = 'conf/') Dir.mkdir(target) unless File.directory? target configs.each do |cf| ocf = File.join(InstallOptions.config_dir, cf.gsub(/#{strip}/, '')) if $haveftools File.install(cf, ocf, 0644, true) else FileUtils.install(cf, ocf, {:mode => 0644, :preserve => true, :verbose => true}) end end if $operatingsystem == 'windows' src_dll = 'ext/windows/eventlog/puppetres.dll' dst_dll = File.join(InstallOptions.bin_dir, 'puppetres.dll') if $haveftools File.install(src_dll, dst_dll, 0644, true) else FileUtils.install(src_dll, dst_dll, {:mode => 0644, :preserve => true, :verbose => true}) end require 'win32/registry' include Win32::Registry::Constants begin Win32::Registry::HKEY_LOCAL_MACHINE.create('SYSTEM\CurrentControlSet\services\eventlog\Application\Puppet', KEY_ALL_ACCESS | 0x0100) do |reg| reg.write_s('EventMessageFile', dst_dll.tr('/', '\\')) reg.write_i('TypesSupported', 0x7) end rescue Win32::Registry::Error => e warn "Failed to create puppet eventlog registry key: #{e}" end end end def do_bins(bins, target, strip = 's?bin/') Dir.mkdir(target) unless File.directory? target bins.each do |bf| obf = bf.gsub(/#{strip}/, '') install_binfile(bf, obf, target) end end def do_libs(libs, strip = 'lib/') libs.each do |lf| next if File.directory? lf olf = File.join(InstallOptions.site_dir, lf.sub(/^#{strip}/, '')) op = File.dirname(olf) if $haveftools File.makedirs(op, true) File.chmod(0755, op) File.install(lf, olf, 0644, true) else FileUtils.makedirs(op, {:mode => 0755, :verbose => true}) FileUtils.chmod(0755, op) FileUtils.install(lf, olf, {:mode => 0644, :preserve => true, :verbose => true}) end end end def do_man(man, strip = 'man/') man.each do |mf| omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, '')) om = File.dirname(omf) if $haveftools File.makedirs(om, true) File.chmod(0755, om) File.install(mf, omf, 0644, true) else FileUtils.makedirs(om, {:mode => 0755, :verbose => true}) FileUtils.chmod(0755, om) FileUtils.install(mf, omf, {:mode => 0644, :preserve => true, :verbose => true}) end gzip = %x{which gzip} gzip.chomp! %x{#{gzip} -f #{omf}} end end # Verify that all of the prereqs are installed def check_prereqs PREREQS.each { |pre| begin require pre if pre == "facter" # to_f isn't quite exact for strings like "1.5.1" but is good # enough for this purpose. facter_version = Facter.version.to_f if facter_version < MIN_FACTER_VERSION puts "Facter version: #{facter_version}; minimum required: #{MIN_FACTER_VERSION}; cannot install" exit -1 end end rescue LoadError puts "Could not load #{pre}; cannot install" exit -1 end } end ## # Prepare the file installation. # def prepare_installation $operatingsystem = Facter.value :operatingsystem InstallOptions.configs = true # Only try to do docs if we're sure they have rdoc if $haverdoc InstallOptions.rdoc = true InstallOptions.ri = $operatingsystem != "windows" else InstallOptions.rdoc = false InstallOptions.ri = false end ARGV.options do |opts| opts.banner = "Usage: #{File.basename($0)} [options]" opts.separator "" opts.on('--[no-]rdoc', 'Prevents the creation of RDoc output.', 'Default on.') do |onrdoc| InstallOptions.rdoc = onrdoc end opts.on('--[no-]ri', 'Prevents the creation of RI output.', 'Default off on mswin32.') do |onri| InstallOptions.ri = onri end opts.on('--[no-]tests', 'Prevents the execution of unit tests.', 'Default off.') do |ontest| InstallOptions.tests = ontest warn "The tests flag is no longer functional in Puppet and is deprecated as of Dec 19, 2012. It will be removed in a future version of Puppet." end opts.on('--[no-]configs', 'Prevents the installation of config files', 'Default off.') do |ontest| InstallOptions.configs = ontest end opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir| InstallOptions.destdir = destdir end - opts.on('--configdir[=OPTIONAL]', 'Installation directory for config files', 'Default /etc/puppetlabs/agent') do |configdir| + opts.on('--configdir[=OPTIONAL]', 'Installation directory for config files', 'Default /etc/puppet') do |configdir| InstallOptions.configdir = configdir end - opts.on('--vardir[=OPTIONAL]', 'Installation directory for var files', 'Default /opt/puppetlabs/agent/cache') do |vardir| - InstallOptions.vardir = vardir - end - opts.on('--rundir[=OPTIONAL]', 'Installation directory for state files', 'Default /var/run/puppetlabs') do |rundir| - InstallOptions.rundir = rundir - end - opts.on('--logdir[=OPTIONAL]', 'Installation directory for log files', 'Default /var/log/puppetlabs/agent') do |logdir| - InstallOptions.logdir = logdir - end opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides RbConfig::CONFIG["bindir"]') do |bindir| InstallOptions.bindir = bindir end opts.on('--ruby[=OPTIONAL]', 'Ruby interpreter to use with installation', 'overrides ruby used to call install.rb') do |ruby| InstallOptions.ruby = ruby end opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides RbConfig::CONFIG["sitelibdir"]') do |sitelibdir| InstallOptions.sitelibdir = sitelibdir end opts.on('--mandir[=OPTIONAL]', 'Installation directory for man pages', 'overrides RbConfig::CONFIG["mandir"]') do |mandir| InstallOptions.mandir = mandir end opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick| InstallOptions.rdoc = false InstallOptions.ri = false InstallOptions.configs = true end opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full| InstallOptions.rdoc = true InstallOptions.ri = true InstallOptions.configs = true end opts.separator("") opts.on_tail('--help', "Shows this help text.") do $stderr.puts opts exit end opts.parse! end version = [RbConfig::CONFIG["MAJOR"], RbConfig::CONFIG["MINOR"]].join(".") libdir = File.join(RbConfig::CONFIG["libdir"], "ruby", version) # Mac OS X 10.5 and higher declare bindir # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin # which is not generally where people expect executables to be installed # These settings are appropriate defaults for all OS X versions. if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/ RbConfig::CONFIG['bindir'] = "/usr/bin" end - if $operatingsystem == "windows" + if not InstallOptions.configdir.nil? + configdir = InstallOptions.configdir + elsif $operatingsystem == "windows" begin require 'win32/dir' rescue LoadError => e puts "Cannot run on Microsoft Windows without the win32-process, win32-dir & win32-service gems: #{e}" exit -1 end - end - - if not InstallOptions.configdir.nil? - configdir = InstallOptions.configdir - elsif $operatingsystem == "windows" configdir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc") else - configdir = "/etc/puppetlabs/agent" - end - - if not InstallOptions.vardir.nil? - vardir = InstallOptions.vardir - elsif $operatingsystem == "windows" - vardir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var") - else - vardir = "/opt/puppetlabs/agent/cache" - end - - if not InstallOptions.rundir.nil? - rundir = InstallOptions.rundir - elsif $operatingsystem == "windows" - rundir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var", "run") - else - rundir = "/var/run/puppetlabs" - end - - if not InstallOptions.logdir.nil? - logdir = InstallOptions.logdir - elsif $operatingsystem == "windows" - logdir = File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var", "log") - else - logdir = "/var/log/puppetlabs/agent" + configdir = "/etc/puppet" end if not InstallOptions.bindir.nil? bindir = InstallOptions.bindir else bindir = RbConfig::CONFIG['bindir'] end if not InstallOptions.sitelibdir.nil? sitelibdir = InstallOptions.sitelibdir else sitelibdir = RbConfig::CONFIG["sitelibdir"] if sitelibdir.nil? sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ } if sitelibdir.nil? sitelibdir = File.join(libdir, "site_ruby") elsif sitelibdir !~ Regexp.quote(version) sitelibdir = File.join(sitelibdir, version) end end end if not InstallOptions.mandir.nil? mandir = InstallOptions.mandir else mandir = RbConfig::CONFIG['mandir'] end # This is the new way forward if not InstallOptions.destdir.nil? destdir = InstallOptions.destdir # To be deprecated once people move over to using --destdir option elsif not ENV['DESTDIR'].nil? destdir = ENV['DESTDIR'] warn "DESTDIR is deprecated. Use --destdir instead." else destdir = '' end configdir = join(destdir, configdir) - vardir = join(destdir, vardir) - rundir = join(destdir, rundir) - logdir = join(destdir, logdir) bindir = join(destdir, bindir) mandir = join(destdir, mandir) sitelibdir = join(destdir, sitelibdir) FileUtils.makedirs(configdir) if InstallOptions.configs FileUtils.makedirs(bindir) FileUtils.makedirs(mandir) FileUtils.makedirs(sitelibdir) - FileUtils.makedirs(vardir) - FileUtils.makedirs(rundir) - FileUtils.makedirs(logdir) InstallOptions.site_dir = sitelibdir InstallOptions.config_dir = configdir - InstallOptions.var_dir = vardir - InstallOptions.run_dir = rundir - InstallOptions.log_dir = logdir InstallOptions.bin_dir = bindir InstallOptions.lib_dir = libdir InstallOptions.man_dir = mandir end ## # Join two paths. On Windows, dir must be converted to a relative path, # by stripping the drive letter, but only if the basedir is not empty. # def join(basedir, dir) return "#{basedir}#{dir[2..-1]}" if $operatingsystem == "windows" and basedir.length > 0 and dir.length > 2 "#{basedir}#{dir}" end ## # Build the rdoc documentation. Also, try to build the RI documentation. # def build_rdoc(files) return unless $haverdoc begin r = RDoc::RDoc.new r.document(["--main", "README", "--title", "Puppet -- Site Configuration Management", "--line-numbers"] + files) rescue RDoc::RDocError => e $stderr.puts e.message rescue Exception => e $stderr.puts "Couldn't build RDoc documentation\n#{e.message}" end end def build_ri(files) return unless $haverdoc begin ri = RDoc::RDoc.new #ri.document(["--ri-site", "--merge"] + files) ri.document(["--ri-site"] + files) rescue RDoc::RDocError => e $stderr.puts e.message rescue Exception => e $stderr.puts "Couldn't build Ri documentation\n#{e.message}" $stderr.puts "Continuing with install..." end end ## # Install file(s) from ./bin to RbConfig::CONFIG['bindir']. Patch it on the way # to insert a #! line; on a Unix install, the command is named as expected # (e.g., bin/rdoc becomes rdoc); the shebang line handles running it. Under # windows, we add an '.rb' extension and let file associations do their stuff. def install_binfile(from, op_file, target) tmp_file = Tempfile.new('puppet-binfile') if not InstallOptions.ruby.nil? ruby = InstallOptions.ruby else ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) end File.open(from) do |ip| File.open(tmp_file.path, "w") do |op| op.puts "#!#{ruby}" contents = ip.readlines contents.shift if contents[0] =~ /^#!/ op.write contents.join end end if $operatingsystem == "windows" installed_wrapper = false if File.exists?("#{from}.bat") FileUtils.install("#{from}.bat", File.join(target, "#{op_file}.bat"), :mode => 0755, :preserve => true, :verbose => true) installed_wrapper = true end if File.exists?("#{from}.cmd") FileUtils.install("#{from}.cmd", File.join(target, "#{op_file}.cmd"), :mode => 0755, :preserve => true, :verbose => true) installed_wrapper = true end if not installed_wrapper tmp_file2 = Tempfile.new('puppet-wrapper') cwv = <<-EOS @echo off setlocal set RUBY_BIN=%~dp0 set RUBY_BIN=%RUBY_BIN:\\=/% "%RUBY_BIN%ruby.exe" -x "%RUBY_BIN%puppet" %* EOS File.open(tmp_file2.path, "w") { |cw| cw.puts cwv } FileUtils.install(tmp_file2.path, File.join(target, "#{op_file}.bat"), :mode => 0755, :preserve => true, :verbose => true) tmp_file2.unlink installed_wrapper = true end end FileUtils.install(tmp_file.path, File.join(target, op_file), :mode => 0755, :preserve => true, :verbose => true) tmp_file.unlink end # Change directory into the puppet root so we don't get the wrong files for install. FileUtils.cd File.dirname(__FILE__) do # Set these values to what you want installed. configs = glob(%w{conf/auth.conf}) bins = glob(%w{bin/*}) rdoc = glob(%w{bin/* lib/**/*.rb README* }).reject { |e| e=~ /\.(bat|cmd)$/ } ri = glob(%w{bin/*.rb lib/**/*.rb}).reject { |e| e=~ /\.(bat|cmd)$/ } man = glob(%w{man/man[0-9]/*}) libs = glob(%w{lib/**/*}) check_prereqs prepare_installation #build_rdoc(rdoc) if InstallOptions.rdoc #build_ri(ri) if InstallOptions.ri do_configs(configs, InstallOptions.config_dir) if InstallOptions.configs do_bins(bins, InstallOptions.bin_dir) do_libs(libs) do_man(man) unless $operatingsystem == "windows" end diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index c41278461..b181566df 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -1,1711 +1,1711 @@ module Puppet def self.default_diffargs if (Facter.value(:kernel) == "AIX" && Facter.value(:kernelmajversion) == "5300") "" else "-u" end end ############################################################################################ # NOTE: For information about the available values for the ":type" property of settings, # see the docs for Settings.define_settings ############################################################################################ AS_DURATION = %q{This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y).} # This is defined first so that the facter implementation is replaced before other setting defaults are evaluated. define_settings(:main, :cfacter => { :default => false, :type => :boolean, :desc => 'Whether or not to use the native facter (cfacter) implementation instead of the Ruby one (facter). Defaults to false.', :hook => proc do |value| return unless value raise ArgumentError, 'facter has already evaluated facts.' if Facter.instance_variable_get(:@collection) raise ArgumentError, 'cfacter version 0.2.0 or later is not installed.' unless Puppet.features.cfacter? CFacter.initialize # Setup Facter's logging again now that native facter is initialized Puppet::Util::Logging.setup_facter_logging! end } ) define_settings(:main, :confdir => { :default => nil, :type => :directory, :desc => "The main Puppet configuration directory. The default for this setting is calculated based on the user. If the process is running as root or the user that Puppet is supposed to run as, it defaults to a system directory, but if it's running as any other user, it defaults to being in the user's home directory.", }, :vardir => { :default => nil, :type => :directory, :owner => "service", :group => "service", :desc => "Where Puppet stores dynamic and growing data. The default for this setting is calculated specially, like `confdir`_.", }, ### NOTE: this setting is usually being set to a symbol value. We don't officially have a ### setting type for that yet, but we might want to consider creating one. :name => { :default => nil, :desc => "The name of the application, if we are running as one. The default is essentially $0 without the path or `.rb`.", } ) define_settings(:main, :logdir => { :default => nil, :type => :directory, :mode => "0750", :owner => "service", :group => "service", :desc => "The directory in which to store log files", }, :log_level => { :default => 'notice', :type => :enum, :values => ["debug","info","notice","warning","err","alert","emerg","crit"], :desc => "Default logging level for messages from Puppet. Allowed values are: * debug * info * notice * warning * err * alert * emerg * crit ", :hook => proc {|value| Puppet::Util::Log.level = value }, :call_hook => :on_initialize_and_write, }, :disable_warnings => { :default => [], :type => :array, :desc => "A comma-separated list of warning types to suppress. If large numbers of warnings are making Puppet's logs too large or difficult to use, you can temporarily silence them with this setting. If you are preparing to upgrade Puppet to a new major version, you should re-enable all warnings for a while. Valid values for this setting are: * `deprecations` --- disables deprecation warnings.", :hook => proc do |value| values = munge(value) valid = %w[deprecations] invalid = values - (values & valid) if not invalid.empty? raise ArgumentError, "Cannot disable unrecognized warning types #{invalid.inspect}. Valid values are #{valid.inspect}." end end } ) define_settings(:main, :priority => { :default => nil, :type => :priority, :desc => "The scheduling priority of the process. Valid values are 'high', 'normal', 'low', or 'idle', which are mapped to platform-specific values. The priority can also be specified as an integer value and will be passed as is, e.g. -5. Puppet must be running as a privileged user in order to increase scheduling priority.", }, :trace => { :default => false, :type => :boolean, :desc => "Whether to print stack traces on some errors", :hook => proc do |value| # Enable or disable Facter's trace option too Facter.trace(value) if Facter.respond_to? :trace end }, :profile => { :default => false, :type => :boolean, :desc => "Whether to enable experimental performance profiling", }, :autoflush => { :default => true, :type => :boolean, :desc => "Whether log files should always flush to disk.", :hook => proc { |value| Log.autoflush = value } }, :syslogfacility => { :default => "daemon", :desc => "What syslog facility to use when logging to syslog. Syslog has a fixed list of valid facilities, and you must choose one of those; you cannot just make one up." }, :statedir => { :default => "$vardir/state", :type => :directory, :mode => "01755", :desc => "The directory where Puppet state is stored. Generally, this directory can be removed without causing harm (although it might result in spurious service restarts)." }, :rundir => { :default => nil, :type => :directory, :mode => "0755", :owner => "service", :group => "service", :desc => "Where Puppet PID files are kept." }, :genconfig => { :default => false, :type => :boolean, :desc => "When true, causes Puppet applications to print an example config file to stdout and exit. The example will include descriptions of each setting, and the current (or default) value of each setting, incorporating any settings overridden on the CLI (with the exception of `genconfig` itself). This setting only makes sense when specified on the command line as `--genconfig`.", }, :genmanifest => { :default => false, :type => :boolean, :desc => "Whether to just print a manifest to stdout and exit. Only makes sense when specified on the command line as `--genmanifest`. Takes into account arguments specified on the CLI.", }, :configprint => { :default => "", :desc => "Print the value of a specific configuration setting. If the name of a setting is provided for this, then the value is printed and puppet exits. Comma-separate multiple values. For a list of all values, specify 'all'.", }, :color => { :default => "ansi", :type => :string, :desc => "Whether to use colors when logging to the console. Valid values are `ansi` (equivalent to `true`), `html`, and `false`, which produces no color. Defaults to false on Windows, as its console does not support ansi colors.", }, :mkusers => { :default => false, :type => :boolean, :desc => "Whether to create the necessary user and group that puppet agent will run as.", }, :manage_internal_file_permissions => { :default => true, :type => :boolean, :desc => "Whether Puppet should manage the owner, group, and mode of files it uses internally", }, :onetime => { :default => false, :type => :boolean, :desc => "Perform one configuration run and exit, rather than spawning a long-running daemon. This is useful for interactively running puppet agent, or running puppet agent from cron.", :short => 'o', }, :path => { :default => "none", :desc => "The shell search path. Defaults to whatever is inherited from the parent process. This setting can only be set in the `[main]` section of puppet.conf; it cannot be set in `[master]`, `[agent]`, or an environment config section.", :call_hook => :on_define_and_write, :hook => proc do |value| ENV["PATH"] = "" if ENV["PATH"].nil? ENV["PATH"] = value unless value == "none" paths = ENV["PATH"].split(File::PATH_SEPARATOR) Puppet::Util::Platform.default_paths.each do |path| ENV["PATH"] += File::PATH_SEPARATOR + path unless paths.include?(path) end value end }, :libdir => { :type => :directory, :default => "$vardir/lib", :desc => "An extra search path for Puppet. This is only useful for those files that Puppet will load on demand, and is only guaranteed to work for those cases. In fact, the autoload mechanism is responsible for making sure this directory is in Ruby's search path\n", :call_hook => :on_initialize_and_write, :hook => proc do |value| $LOAD_PATH.delete(@oldlibdir) if defined?(@oldlibdir) && $LOAD_PATH.include?(@oldlibdir) @oldlibdir = value $LOAD_PATH << value end }, :environment => { :default => "production", :desc => "The environment Puppet is running in. For clients (e.g., `puppet agent`) this determines the environment itself, which is used to find modules and much more. For servers (i.e., `puppet master`) this provides the default environment for nodes we know nothing about." }, :environmentpath => { :default => "$confdir/environments", :desc => "A search path for directory environments, as a list of directories separated by the system path separator character. (The POSIX path separator is ':', and the Windows path separator is ';'.) This setting must have a value set to enable **directory environments.** The recommended value is `$confdir/environments`. For more details, see http://docs.puppetlabs.com/puppet/latest/reference/environments.html", :type => :path, }, :always_cache_features => { :type => :boolean, :default => false, :desc => <<-'EOT' Affects how we cache attempts to load Puppet 'features'. If false, then calls to `Puppet.features.?` will always attempt to load the feature (which can be an expensive operation) unless it has already been loaded successfully. This makes it possible for a single agent run to, e.g., install a package that provides the underlying capabilities for a feature, and then later load that feature during the same run (even if the feature had been tested earlier and had not been available). If this setting is set to true, then features will only be checked once, and if they are not available, the negative result is cached and returned for all subsequent attempts to load the feature. This behavior is almost always appropriate for the server, and can result in a significant performance improvement for features that are checked frequently. EOT }, :diff_args => { :default => lambda { default_diffargs }, :desc => "Which arguments to pass to the diff command when printing differences between files. The command to use can be chosen with the `diff` setting.", }, :diff => { :default => (Puppet.features.microsoft_windows? ? "" : "diff"), :desc => "Which diff command to use when printing differences between files. This setting has no default value on Windows, as standard `diff` is not available, but Puppet can use many third-party diff tools.", }, :show_diff => { :type => :boolean, :default => false, :desc => "Whether to log and report a contextual diff when files are being replaced. This causes partial file contents to pass through Puppet's normal logging and reporting system, so this setting should be used with caution if you are sending Puppet's reports to an insecure destination. This feature currently requires the `diff/lcs` Ruby library.", }, :daemonize => { :type => :boolean, :default => (Puppet.features.microsoft_windows? ? false : true), :desc => "Whether to send the process into the background. This defaults to true on POSIX systems, and to false on Windows (where Puppet currently cannot daemonize).", :short => "D", :hook => proc do |value| if value and Puppet.features.microsoft_windows? raise "Cannot daemonize on Windows" end end }, :maximum_uid => { :default => 4294967290, :desc => "The maximum allowed UID. Some platforms use negative UIDs but then ship with tools that do not know how to handle signed ints, so the UIDs show up as huge numbers that can then not be fed back into the system. This is a hackish way to fail in a slightly more useful way when that happens.", }, :route_file => { :default => "$confdir/routes.yaml", :desc => "The YAML file containing indirector route configuration.", }, :node_terminus => { :type => :terminus, :default => "plain", :desc => "Where to find information about nodes.", }, :node_cache_terminus => { :type => :terminus, :default => nil, :desc => "How to store cached nodes. Valid values are (none), 'json', 'msgpack', 'yaml' or write only yaml ('write_only_yaml'). The master application defaults to 'write_only_yaml', all others to none.", }, :data_binding_terminus => { :type => :terminus, :default => "hiera", :desc => "Where to retrive information about data.", }, :hiera_config => { :default => "$confdir/hiera.yaml", :desc => "The hiera configuration file. Puppet only reads this file on startup, so you must restart the puppet master every time you edit it.", :type => :file, }, :binder_config => { :default => nil, :desc => "The binder configuration file. Puppet reads this file on each request to configure the bindings system. If set to nil (the default), a $confdir/binder_config.yaml is optionally loaded. If it does not exists, a default configuration is used. If the setting :binding_config is specified, it must reference a valid and existing yaml file.", :type => :file, }, :catalog_terminus => { :type => :terminus, :default => "compiler", :desc => "Where to get node catalogs. This is useful to change if, for instance, you'd like to pre-compile catalogs and store them in memcached or some other easily-accessed store.", }, :catalog_cache_terminus => { :type => :terminus, :default => nil, :desc => "How to store cached catalogs. Valid values are 'json', 'msgpack' and 'yaml'. The agent application defaults to 'json'." }, :facts_terminus => { :default => 'facter', :desc => "The node facts terminus.", }, :default_file_terminus => { :type => :terminus, :default => "rest", :desc => "The default source for files if no server is given in a uri, e.g. puppet:///file. The default of `rest` causes the file to be retrieved using the `server` setting. When running `apply` the default is `file_server`, causing requests to be filled locally." }, :http_proxy_host => { :default => "none", :desc => "The HTTP proxy host to use for outgoing connections. Note: You may need to use a FQDN for the server hostname when using a proxy. Environment variable http_proxy or HTTP_PROXY will override this value", }, :http_proxy_port => { :default => 3128, :desc => "The HTTP proxy port to use for outgoing connections", }, :http_proxy_user => { :default => "none", :desc => "The user name for an authenticated HTTP proxy. Requires the `http_proxy_host` setting.", }, :http_proxy_password =>{ :default => "none", :hook => proc do |value| if Puppet.settings[:http_proxy_password] =~ /[@!# \/]/ raise "Passwords set in the http_proxy_password setting must be valid as part of a URL, and any reserved characters must be URL-encoded. We received: #{value}" end end, :desc => "The password for the user of an authenticated HTTP proxy. Requires the `http_proxy_user` setting. Note that passwords must be valid when used as part of a URL. If a password contains any characters with special meanings in URLs (as specified by RFC 3986 section 2.2), they must be URL-encoded. (For example, `#` would become `%23`.)", }, :http_keepalive_timeout => { :default => "4s", :type => :duration, :desc => "The maximum amount of time a persistent HTTP connection can remain idle in the connection pool, before it is closed. This timeout should be shorter than the keepalive timeout used on the HTTP server, e.g. Apache KeepAliveTimeout directive. #{AS_DURATION}" }, :http_debug => { :default => false, :type => :boolean, :desc => "Whether to write HTTP request and responses to stderr. This should never be used in a production environment." }, :http_connect_timeout => { :default => "2m", :type => :duration, :desc => "The maximum amount of time to wait when establishing an HTTP connection. The default value is 2 minutes. #{AS_DURATION}", }, :http_read_timeout => { :type => :duration, :desc => "The time to wait for one block to be read from an HTTP connection. If nothing is read after the elapsed interval then the connection will be closed. The default value is unlimited. #{AS_DURATION}", }, :filetimeout => { :default => "15s", :type => :duration, :desc => "The minimum time to wait between checking for updates in configuration files. This timeout determines how quickly Puppet checks whether a file (such as manifests or templates) has changed on disk. #{AS_DURATION}", }, :environment_timeout => { :default => "unlimited", :type => :ttl, :desc => "The time to live for a cached environment. #{AS_DURATION} This setting can also be set to `unlimited`, which causes the environment to be cached until the master is restarted." }, :environment_data_provider => { :default => "none", :desc => "The name of a registered environment data provider. The two built in and registered providers are 'none' (no environment specific data), and 'function' (environment specific data obtained by calling the function 'environment::data()'). Other environment data providers may be registered in modules on the module path. For such custom data providers see the respective module documentation." }, :prerun_command => { :default => "", :desc => "A command to run before every agent run. If this command returns a non-zero return code, the entire Puppet run will fail.", }, :postrun_command => { :default => "", :desc => "A command to run after every agent run. If this command returns a non-zero return code, the entire Puppet run will be considered to have failed, even though it might have performed work during the normal run.", }, :freeze_main => { :default => false, :type => :boolean, :desc => "Freezes the 'main' class, disallowing any code to be added to it. This essentially means that you can't have any code outside of a node, class, or definition other than in the site manifest.", } ) Puppet.define_settings(:module_tool, :module_repository => { :default => 'https://forgeapi.puppetlabs.com', :desc => "The module repository", }, :module_working_dir => { :default => '$vardir/puppet-module', :desc => "The directory into which module tool data is stored", }, :module_skeleton_dir => { :default => '$module_working_dir/skeleton', :desc => "The directory which the skeleton for module tool generate is stored.", }, :forge_authorization => { :default => nil, :desc => "The authorization key to connect to the Puppet Forge. Leave blank for unauthorized or license based connections", }, :module_groups => { :default => nil, :desc => "Extra module groups to request from the Puppet Forge", } ) Puppet.define_settings( :main, # We have to downcase the fqdn, because the current ssl stuff (as oppsed to in master) doesn't have good facilities for # manipulating naming. :certname => { :default => lambda { Puppet::Settings.default_certname.downcase }, :desc => "The name to use when handling certificates. When a node requests a certificate from the CA puppet master, it uses the value of the `certname` setting as its requested Subject CN. This is the name used when managing a node's permissions in [auth.conf](http://docs.puppetlabs.com/puppet/latest/reference/config_file_auth.html). In most cases, it is also used as the node's name when matching [node definitions](http://docs.puppetlabs.com/puppet/latest/reference/lang_node_definitions.html) and requesting data from an ENC. (This can be changed with the `node_name_value` and `node_name_fact` settings, although you should only do so if you have a compelling reason.) A node's certname is available in Puppet manifests as `$trusted['certname']`. (See [Facts and Built-In Variables](http://docs.puppetlabs.com/puppet/latest/reference/lang_facts_and_builtin_vars.html) for more details.) * For best compatibility, you should limit the value of `certname` to only use letters, numbers, periods, underscores, and dashes. (That is, it should match `/\A[a-z0-9._-]+\Z/`.) * The special value `ca` is reserved, and can't be used as the certname for a normal node. Defaults to the node's fully qualified domain name.", :hook => proc { |value| raise(ArgumentError, "Certificate names must be lower case; see #1168") unless value == value.downcase }}, :dns_alt_names => { :default => '', :desc => < { :default => "$confdir/csr_attributes.yaml", :type => :file, :desc => < { :default => "$ssldir/certs", :type => :directory, :mode => "0755", :owner => "service", :group => "service", :desc => "The certificate directory." }, :ssldir => { :default => "$confdir/ssl", :type => :directory, :mode => "0771", :owner => "service", :group => "service", :desc => "Where SSL certificates are kept." }, :publickeydir => { :default => "$ssldir/public_keys", :type => :directory, :mode => "0755", :owner => "service", :group => "service", :desc => "The public key directory." }, :requestdir => { :default => "$ssldir/certificate_requests", :type => :directory, :mode => "0755", :owner => "service", :group => "service", :desc => "Where host certificate requests are stored." }, :privatekeydir => { :default => "$ssldir/private_keys", :type => :directory, :mode => "0750", :owner => "service", :group => "service", :desc => "The private key directory." }, :privatedir => { :default => "$ssldir/private", :type => :directory, :mode => "0750", :owner => "service", :group => "service", :desc => "Where the client stores private certificate information." }, :passfile => { :default => "$privatedir/password", :type => :file, :mode => "0640", :owner => "service", :group => "service", :desc => "Where puppet agent stores the password for its private key. Generally unused." }, :hostcsr => { :default => "$ssldir/csr_$certname.pem", :type => :file, :mode => "0644", :owner => "service", :group => "service", :desc => "Where individual hosts store and look for their certificate requests." }, :hostcert => { :default => "$certdir/$certname.pem", :type => :file, :mode => "0644", :owner => "service", :group => "service", :desc => "Where individual hosts store and look for their certificates." }, :hostprivkey => { :default => "$privatekeydir/$certname.pem", :type => :file, :mode => "0640", :owner => "service", :group => "service", :desc => "Where individual hosts store and look for their private key." }, :hostpubkey => { :default => "$publickeydir/$certname.pem", :type => :file, :mode => "0644", :owner => "service", :group => "service", :desc => "Where individual hosts store and look for their public key." }, :localcacert => { :default => "$certdir/ca.pem", :type => :file, :mode => "0644", :owner => "service", :group => "service", :desc => "Where each client stores the CA certificate." }, :ssl_client_ca_auth => { :type => :file, :mode => "0644", :owner => "service", :group => "service", :desc => "Certificate authorities who issue server certificates. SSL servers will not be considered authentic unless they possess a certificate issued by an authority listed in this file. If this setting has no value then the Puppet master's CA certificate (localcacert) will be used." }, :ssl_server_ca_auth => { :type => :file, :mode => "0644", :owner => "service", :group => "service", :desc => "Certificate authorities who issue client certificates. SSL clients will not be considered authentic unless they possess a certificate issued by an authority listed in this file. If this setting has no value then the Puppet master's CA certificate (localcacert) will be used." }, :hostcrl => { :default => "$ssldir/crl.pem", :type => :file, :mode => "0644", :owner => "service", :group => "service", :desc => "Where the host's certificate revocation list can be found. This is distinct from the certificate authority's CRL." }, :certificate_revocation => { :default => true, :type => :boolean, :desc => "Whether certificate revocation should be supported by downloading a Certificate Revocation List (CRL) to all clients. If enabled, CA chaining will almost definitely not work.", }, :digest_algorithm => { :default => 'md5', :type => :enum, :values => ["md5", "sha256"], :desc => 'Which digest algorithm to use for file resources and the filebucket. Valid values are md5, sha256. Default is md5.', } ) define_settings( :ca, :ca_name => { :default => "Puppet CA: $certname", :desc => "The name to use the Certificate Authority certificate.", }, :cadir => { :default => "$ssldir/ca", :type => :directory, :owner => "service", :group => "service", :mode => "0755", :desc => "The root directory for the certificate authority." }, :cacert => { :default => "$cadir/ca_crt.pem", :type => :file, :owner => "service", :group => "service", :mode => "0644", :desc => "The CA certificate." }, :cakey => { :default => "$cadir/ca_key.pem", :type => :file, :owner => "service", :group => "service", :mode => "0640", :desc => "The CA private key." }, :capub => { :default => "$cadir/ca_pub.pem", :type => :file, :owner => "service", :group => "service", :mode => "0644", :desc => "The CA public key." }, :cacrl => { :default => "$cadir/ca_crl.pem", :type => :file, :owner => "service", :group => "service", :mode => "0644", :desc => "The certificate revocation list (CRL) for the CA. Will be used if present but otherwise ignored.", }, :caprivatedir => { :default => "$cadir/private", :type => :directory, :owner => "service", :group => "service", :mode => "0750", :desc => "Where the CA stores private certificate information." }, :csrdir => { :default => "$cadir/requests", :type => :directory, :owner => "service", :group => "service", :mode => "0755", :desc => "Where the CA stores certificate requests" }, :signeddir => { :default => "$cadir/signed", :type => :directory, :owner => "service", :group => "service", :mode => "0755", :desc => "Where the CA stores signed certificates." }, :capass => { :default => "$caprivatedir/ca.pass", :type => :file, :owner => "service", :group => "service", :mode => "0640", :desc => "Where the CA stores the password for the private key." }, :serial => { :default => "$cadir/serial", :type => :file, :owner => "service", :group => "service", :mode => "0644", :desc => "Where the serial number for certificates is stored." }, :autosign => { :default => "$confdir/autosign.conf", :type => :autosign, :desc => "Whether (and how) to autosign certificate requests. This setting is only relevant on a puppet master acting as a certificate authority (CA). Valid values are true (autosigns all certificate requests; not recommended), false (disables autosigning certificates), or the absolute path to a file. The file specified in this setting may be either a **configuration file** or a **custom policy executable.** Puppet will automatically determine what it is: If the Puppet user (see the `user` setting) can execute the file, it will be treated as a policy executable; otherwise, it will be treated as a config file. If a custom policy executable is configured, the CA puppet master will run it every time it receives a CSR. The executable will be passed the subject CN of the request _as a command line argument,_ and the contents of the CSR in PEM format _on stdin._ It should exit with a status of 0 if the cert should be autosigned and non-zero if the cert should not be autosigned. If a certificate request is not autosigned, it will persist for review. An admin user can use the `puppet cert sign` command to manually sign it, or can delete the request. For info on autosign configuration files, see [the guide to Puppet's config files](http://docs.puppetlabs.com/guides/configuring.html).", }, :allow_duplicate_certs => { :default => false, :type => :boolean, :desc => "Whether to allow a new certificate request to overwrite an existing certificate.", }, :ca_ttl => { :default => "5y", :type => :duration, :desc => "The default TTL for new certificates. #{AS_DURATION}" }, :req_bits => { :default => 4096, :desc => "The bit length of the certificates.", }, :keylength => { :default => 4096, :desc => "The bit length of keys.", }, :cert_inventory => { :default => "$cadir/inventory.txt", :type => :file, :mode => "0644", :owner => "service", :group => "service", :desc => "The inventory file. This is a text file to which the CA writes a complete listing of all certificates." } ) # Define the config default. define_settings(:application, :config_file_name => { :type => :string, :default => Puppet::Settings.default_config_file_name, :desc => "The name of the puppet config file.", }, :config => { :type => :file, :default => "$confdir/${config_file_name}", :desc => "The configuration file for the current puppet application.", }, :pidfile => { :type => :file, :default => "$rundir/${run_mode}.pid", :desc => "The file containing the PID of a running process. This file is intended to be used by service management frameworks and monitoring systems to determine if a puppet process is still in the process table.", }, :bindaddress => { :default => "0.0.0.0", :desc => "The address a listening server should bind to.", } ) define_settings(:environment, :manifest => { :default => nil, :type => :file_or_directory, :desc => "The entry-point manifest for puppet master. This can be one file or a directory of manifests to be evaluated in alphabetical order. Puppet manages this path as a directory if one exists or if the path ends with a / or \\. Setting a global value for `manifest` in puppet.conf is not allowed (but it can be overridden from them commandline). Please use directory environments instead. If you need to use something other than the environment's `manifests` directory as the main manifest, you can set `manifest` in environment.conf. For more info, see http://docs.puppetlabs.com/puppet/latest/reference/environments.html", }, :modulepath => { :default => "", :type => :path, :desc => "The search path for modules, as a list of directories separated by the system path separator character. (The POSIX path separator is ':', and the Windows path separator is ';'.) Setting a global value for `modulepath` in puppet.conf is not allowed (but it can be overridden from the commandline). Please use directory environments instead. If you need to use something other than the default modulepath of `:$basemodulepath`, you can set `modulepath` in environment.conf. For more info, see http://docs.puppetlabs.com/puppet/latest/reference/environments.html", }, :config_version => { :default => "", :desc => "How to determine the configuration version. By default, it will be the time that the configuration is parsed, but you can provide a shell script to override how the version is determined. The output of this script will be added to every log message in the reports, allowing you to correlate changes on your hosts to the source version on the server. Setting a global value for config_version in puppet.conf is not allowed (but it can be overridden from the commandline). Please set a per-environment value in environment.conf instead. For more info, see http://docs.puppetlabs.com/puppet/latest/reference/environments.html", }, ) define_settings(:master, :user => { :default => "puppet", :desc => "The user puppet master should run as.", }, :group => { :default => "puppet", :desc => "The group puppet master should run as.", }, :default_manifest => { :default => "./manifests", :type => :string, :desc => "The default main manifest for directory environments. Any environment that doesn't set the `manifest` setting in its `environment.conf` file will use this manifest. This setting's value can be an absolute or relative path. An absolute path will make all environments default to the same main manifest; a relative path will allow each environment to use its own manifest, and Puppet will resolve the path relative to each environment's main directory. In either case, the path can point to a single file or to a directory of manifests to be evaluated in alphabetical order.", }, :disable_per_environment_manifest => { :default => false, :type => :boolean, :desc => "Whether to disallow an environment-specific main manifest. When set to `true`, Puppet will use the manifest specified in the `default_manifest` setting for all environments. If an environment specifies a different main manifest in its `environment.conf` file, catalog requests for that environment will fail with an error. This setting requires `default_manifest` to be set to an absolute path.", :hook => proc do |value| if value && !Pathname.new(Puppet[:default_manifest]).absolute? raise(Puppet::Settings::ValidationError, "The 'default_manifest' setting must be set to an absolute path when 'disable_per_environment_manifest' is true") end end, }, :code => { :default => "", :desc => "Code to parse directly. This is essentially only used by `puppet`, and should only be set if you're writing your own Puppet executable.", }, :masterhttplog => { :default => "$logdir/masterhttp.log", :type => :file, :owner => "service", :group => "service", :mode => "0660", :create => true, :desc => "Where the puppet master web server saves its access log. This is only used when running a WEBrick puppet master. When puppet master is running under a Rack server like Passenger, that web server will have its own logging behavior." }, :masterport => { :default => 8140, :desc => "The port for puppet master traffic. For puppet master, this is the port to listen on; for puppet agent, this is the port to make requests on. Both applications use this setting to get the port.", }, :master_url_prefix => { :default => "/puppet", :desc => "The prefix at which the puppet master API is mounted.", :hook => proc do |value| if !value.start_with?("/") Puppet[:master_url_prefix] = "/#{value}" end end }, :node_name => { :default => "cert", :desc => "How the puppet master determines the client's identity and sets the 'hostname', 'fqdn' and 'domain' facts for use in the manifest, in particular for determining which 'node' statement applies to the client. Possible values are 'cert' (use the subject's CN in the client's certificate) and 'facter' (use the hostname that the client reported in its facts)", }, :bucketdir => { :default => "$vardir/bucket", :type => :directory, :mode => "0750", :owner => "service", :group => "service", :desc => "Where FileBucket files are stored." }, :rest_authconfig => { :default => "$confdir/auth.conf", :type => :file, :desc => "The configuration file that defines the rights to the different rest indirections. This can be used as a fine-grained authorization system for `puppet master`.", }, :ca => { :default => true, :type => :boolean, :desc => "Whether the master should function as a certificate authority.", }, :trusted_oid_mapping_file => { :default => "$confdir/custom_trusted_oid_mapping.yaml", :type => :file, :desc => "File that provides mapping between custom SSL oids and user-friendly names" }, :basemodulepath => { - :default => "$confdir/modules#{File::PATH_SEPARATOR}/opt/puppetlabs/agent/modules", + :default => "$confdir/modules#{File::PATH_SEPARATOR}/usr/share/puppet/modules", :type => :path, :desc => "The search path for **global** modules. Should be specified as a list of directories separated by the system path separator character. (The POSIX path separator is ':', and the Windows path separator is ';'.) These are the modules that will be used by _all_ environments. Note that the `modules` directory of the active environment will have priority over any global directories. For more info, see http://docs.puppetlabs.com/puppet/latest/reference/environments.html", }, :ssl_client_header => { :default => "HTTP_X_CLIENT_DN", :desc => "The header containing an authenticated client's SSL DN. This header must be set by the proxy to the authenticated client's SSL DN (e.g., `/CN=puppet.puppetlabs.com`). Puppet will parse out the Common Name (CN) from the Distinguished Name (DN) and use the value of the CN field for authorization. Note that the name of the HTTP header gets munged by the web server common gateway inteface: an `HTTP_` prefix is added, dashes are converted to underscores, and all letters are uppercased. Thus, to use the `X-Client-DN` header, this setting should be `HTTP_X_CLIENT_DN`.", }, :ssl_client_verify_header => { :default => "HTTP_X_CLIENT_VERIFY", :desc => "The header containing the status message of the client verification. This header must be set by the proxy to 'SUCCESS' if the client successfully authenticated, and anything else otherwise. Note that the name of the HTTP header gets munged by the web server common gateway inteface: an `HTTP_` prefix is added, dashes are converted to underscores, and all letters are uppercased. Thus, to use the `X-Client-Verify` header, this setting should be `HTTP_X_CLIENT_VERIFY`.", }, # To make sure this directory is created before we try to use it on the server, we need # it to be in the server section (#1138). :yamldir => { :default => "$vardir/yaml", :type => :directory, :owner => "service", :group => "service", :mode => "0750", :desc => "The directory in which YAML data is stored, usually in a subdirectory."}, :server_datadir => { :default => "$vardir/server_data", :type => :directory, :owner => "service", :group => "service", :mode => "0750", :desc => "The directory in which serialized data is stored, usually in a subdirectory."}, :reports => { :default => "store", :desc => "The list of report handlers to use. When using multiple report handlers, their names should be comma-separated, with whitespace allowed. (For example, `reports = http, store`.) This setting is relevant to puppet master and puppet apply. The puppet master will call these report handlers with the reports it receives from agent nodes, and puppet apply will call them with its own report. (In all cases, the node applying the catalog must have `report = true`.) See the report reference for information on the built-in report handlers; custom report handlers can also be loaded from modules. (Report handlers are loaded from the lib directory, at `puppet/reports/NAME.rb`.)", }, :reportdir => { :default => "$vardir/reports", :type => :directory, :mode => "0750", :owner => "service", :group => "service", :desc => "The directory in which to store reports. Each node gets a separate subdirectory in this directory. This setting is only used when the `store` report processor is enabled (see the `reports` setting)."}, :reporturl => { :default => "http://localhost:3000/reports/upload", :desc => "The URL that reports should be forwarded to. This setting is only used when the `http` report processor is enabled (see the `reports` setting).", }, :fileserverconfig => { :default => "$confdir/fileserver.conf", :type => :file, :desc => "Where the fileserver configuration is stored.", }, :strict_hostname_checking => { :default => false, :desc => "Whether to only search for the complete hostname as it is in the certificate when searching for node information in the catalogs.", } ) define_settings(:device, :devicedir => { :default => "$vardir/devices", :type => :directory, :mode => "0750", :desc => "The root directory of devices' $vardir.", }, :deviceconfig => { :default => "$confdir/device.conf", :desc => "Path to the device config file for puppet device.", } ) define_settings(:agent, :node_name_value => { :default => "$certname", :desc => "The explicit value used for the node name for all requests the agent makes to the master. WARNING: This setting is mutually exclusive with node_name_fact. Changing this setting also requires changes to the default auth.conf configuration on the Puppet Master. Please see http://links.puppetlabs.com/node_name_value for more information." }, :node_name_fact => { :default => "", :desc => "The fact name used to determine the node name used for all requests the agent makes to the master. WARNING: This setting is mutually exclusive with node_name_value. Changing this setting also requires changes to the default auth.conf configuration on the Puppet Master. Please see http://links.puppetlabs.com/node_name_fact for more information.", :hook => proc do |value| if !value.empty? and Puppet[:node_name_value] != Puppet[:certname] raise "Cannot specify both the node_name_value and node_name_fact settings" end end }, :statefile => { :default => "$statedir/state.yaml", :type => :file, :mode => "0660", :desc => "Where puppet agent and puppet master store state associated with the running configuration. In the case of puppet master, this file reflects the state discovered through interacting with clients." }, :clientyamldir => { :default => "$vardir/client_yaml", :type => :directory, :mode => "0750", :desc => "The directory in which client-side YAML data is stored." }, :client_datadir => { :default => "$vardir/client_data", :type => :directory, :mode => "0750", :desc => "The directory in which serialized data is stored on the client." }, :classfile => { :default => "$statedir/classes.txt", :type => :file, :owner => "root", :mode => "0640", :desc => "The file in which puppet agent stores a list of the classes associated with the retrieved configuration. Can be loaded in the separate `puppet` executable using the `--loadclasses` option."}, :resourcefile => { :default => "$statedir/resources.txt", :type => :file, :owner => "root", :mode => "0640", :desc => "The file in which puppet agent stores a list of the resources associated with the retrieved configuration." }, :puppetdlog => { :default => "$logdir/puppetd.log", :type => :file, :owner => "root", :mode => "0640", :desc => "The fallback log file. This is only used when the `--logdest` option is not specified AND Puppet is running on an operating system where both the POSIX syslog service and the Windows Event Log are unavailable. (Currently, no supported operating systems match that description.) Despite the name, both puppet agent and puppet master will use this file as the fallback logging destination. For control over logging destinations, see the `--logdest` command line option in the manual pages for puppet master, puppet agent, and puppet apply. You can see man pages by running `puppet --help`, or read them online at http://docs.puppetlabs.com/references/latest/man/." }, :server => { :default => "puppet", :desc => "The puppet master server to which the puppet agent should connect." }, :use_srv_records => { :default => false, :type => :boolean, :desc => "Whether the server will search for SRV records in DNS for the current domain.", }, :srv_domain => { :default => lambda { Puppet::Settings.domain_fact }, :desc => "The domain which will be queried to find the SRV records of servers to use.", }, :ignoreschedules => { :default => false, :type => :boolean, :desc => "Boolean; whether puppet agent should ignore schedules. This is useful for initial puppet agent runs.", }, :default_schedules => { :default => true, :type => :boolean, :desc => "Boolean; whether to generate the default schedule resources. Setting this to false is useful for keeping external report processors clean of skipped schedule resources.", }, :noop => { :default => false, :type => :boolean, :desc => "Whether to apply catalogs in noop mode, which allows Puppet to partially simulate a normal run. This setting affects puppet agent and puppet apply. When running in noop mode, Puppet will check whether each resource is in sync, like it does when running normally. However, if a resource attribute is not in the desired state (as declared in the catalog), Puppet will take no action, and will instead report the changes it _would_ have made. These simulated changes will appear in the report sent to the puppet master, or be shown on the console if running puppet agent or puppet apply in the foreground. The simulated changes will not send refresh events to any subscribing or notified resources, although Puppet will log that a refresh event _would_ have been sent. **Important note:** [The `noop` metaparameter](http://docs.puppetlabs.com/references/latest/metaparameter.html#noop) allows you to apply individual resources in noop mode, and will override the global value of the `noop` setting. This means a resource with `noop => false` _will_ be changed if necessary, even when running puppet agent with `noop = true` or `--noop`. (Conversely, a resource with `noop => true` will only be simulated, even when noop mode is globally disabled.)", }, :runinterval => { :default => "30m", :type => :duration, :desc => "How often puppet agent applies the catalog. Note that a runinterval of 0 means \"run continuously\" rather than \"never run.\" If you want puppet agent to never run, you should start it with the `--no-client` option. #{AS_DURATION}", }, :ca_server => { :default => "$server", :desc => "The server to use for certificate authority requests. It's a separate server because it cannot and does not need to horizontally scale.", }, :ca_port => { :default => "$masterport", :desc => "The port to use for the certificate authority.", }, :preferred_serialization_format => { :default => "pson", :desc => "The preferred means of serializing ruby instances for passing over the wire. This won't guarantee that all instances will be serialized using this method, since not all classes can be guaranteed to support this format, but it will be used for all classes that support it.", }, :agent_catalog_run_lockfile => { :default => "$statedir/agent_catalog_run.lock", :type => :string, # (#2888) Ensure this file is not added to the settings catalog. :desc => "A lock file to indicate that a puppet agent catalog run is currently in progress. The file contains the pid of the process that holds the lock on the catalog run.", }, :agent_disabled_lockfile => { :default => "$statedir/agent_disabled.lock", :type => :file, :desc => "A lock file to indicate that puppet agent runs have been administratively disabled. File contains a JSON object with state information.", }, :usecacheonfailure => { :default => true, :type => :boolean, :desc => "Whether to use the cached configuration when the remote configuration will not compile. This option is useful for testing new configurations, where you want to fix the broken configuration rather than reverting to a known-good one.", }, :use_cached_catalog => { :default => false, :type => :boolean, :desc => "Whether to only use the cached catalog rather than compiling a new catalog on every run. Puppet can be run with this enabled by default and then selectively disabled when a recompile is desired.", }, :ignoremissingtypes => { :default => false, :type => :boolean, :desc => "Skip searching for classes and definitions that were missing during a prior compilation. The list of missing objects is maintained per-environment and persists until the environment is cleared or the master is restarted.", }, :ignorecache => { :default => false, :type => :boolean, :desc => "Ignore cache and always recompile the configuration. This is useful for testing new configurations, where the local cache may in fact be stale even if the timestamps are up to date - if the facts change or if the server changes.", }, :splaylimit => { :default => "$runinterval", :type => :duration, :desc => "The maximum time to delay before runs. Defaults to being the same as the run interval. #{AS_DURATION}", }, :splay => { :default => false, :type => :boolean, :desc => "Whether to sleep for a pseudo-random (but consistent) amount of time before a run.", }, :clientbucketdir => { :default => "$vardir/clientbucket", :type => :directory, :mode => "0750", :desc => "Where FileBucket files are stored locally." }, :configtimeout => { :default => "2m", :type => :duration, :desc => "How long the client should wait for the configuration to be retrieved before considering it a failure. This setting is deprecated and has been replaced by http_connect_timeout and http_read_timeout. #{AS_DURATION}", :deprecated => :completely, :hook => proc do |value| Puppet[:http_connect_timeout] = value Puppet[:http_read_timeout] = value end }, :report_server => { :default => "$server", :desc => "The server to send transaction reports to.", }, :report_port => { :default => "$masterport", :desc => "The port to communicate with the report_server.", }, :report => { :default => true, :type => :boolean, :desc => "Whether to send reports after every transaction.", }, :lastrunfile => { :default => "$statedir/last_run_summary.yaml", :type => :file, :mode => "0644", :desc => "Where puppet agent stores the last run report summary in yaml format." }, :lastrunreport => { :default => "$statedir/last_run_report.yaml", :type => :file, :mode => "0640", :desc => "Where puppet agent stores the last run report in yaml format." }, :graph => { :default => false, :type => :boolean, :desc => "Whether to create dot graph files for the different configuration graphs. These dot files can be interpreted by tools like OmniGraffle or dot (which is part of ImageMagick).", }, :graphdir => { :default => "$statedir/graphs", :type => :directory, :desc => "Where to store dot-outputted graphs.", }, :waitforcert => { :default => "2m", :type => :duration, :desc => "How frequently puppet agent should ask for a signed certificate. When starting for the first time, puppet agent will submit a certificate signing request (CSR) to the server named in the `ca_server` setting (usually the puppet master); this may be autosigned, or may need to be approved by a human, depending on the CA server's configuration. Puppet agent cannot apply configurations until its approved certificate is available. Since the certificate may or may not be available immediately, puppet agent will repeatedly try to fetch it at this interval. You can turn off waiting for certificates by specifying a time of 0, in which case puppet agent will exit if it cannot get a cert. #{AS_DURATION}", }, :ordering => { :type => :enum, :values => ["manifest", "title-hash", "random"], :default => "manifest", :desc => "How unrelated resources should be ordered when applying a catalog. Allowed values are `title-hash`, `manifest`, and `random`. This setting affects puppet agent and puppet apply, but not puppet master. * `manifest` (the default) will use the order in which the resources were declared in their manifest files. * `title-hash` (the default in 3.x) will order resources randomly, but will use the same order across runs and across nodes. It is only of value if you're migrating from 3.x and have errors running with `manifest`. * `random` will order resources randomly and change their order with each run. This can work like a fuzzer for shaking out undeclared dependencies. Regardless of this setting's value, Puppet will always obey explicit dependencies set with the before/require/notify/subscribe metaparameters and the `->`/`~>` chaining arrows; this setting only affects the relative ordering of _unrelated_ resources." } ) define_settings(:inspect, :archive_files => { :type => :boolean, :default => false, :desc => "During an inspect run, whether to archive files whose contents are audited to a file bucket.", }, :archive_file_server => { :default => "$server", :desc => "During an inspect run, the file bucket server to archive files to if archive_files is set.", } ) # Plugin information. define_settings( :main, :plugindest => { :type => :directory, :default => "$libdir", :desc => "Where Puppet should store plugins that it pulls down from the central server.", }, :pluginsource => { :default => "puppet:///plugins", :desc => "From where to retrieve plugins. The standard Puppet `file` type is used for retrieval, so anything that is a valid file source can be used here.", }, :pluginfactdest => { :type => :directory, :default => "$vardir/facts.d", :desc => "Where Puppet should store external facts that are being handled by pluginsync", }, :pluginfactsource => { :default => "puppet:///pluginfacts", :desc => "Where to retrieve external facts for pluginsync", }, :pluginsync => { :default => true, :type => :boolean, :desc => "Whether plugins should be synced with the central server.", }, :pluginsignore => { :default => ".svn CVS .git", :desc => "What files to ignore when pulling down plugins.", } ) # Central fact information. define_settings( :main, :factpath => { :type => :path, :default => "$vardir/lib/facter#{File::PATH_SEPARATOR}$vardir/facts", :desc => "Where Puppet should look for facts. Multiple directories should be separated by the system path separator character. (The POSIX path separator is ':', and the Windows path separator is ';'.)", :call_hook => :on_initialize_and_write, # Call our hook with the default value, so we always get the value added to facter. :hook => proc do |value| paths = value.split(File::PATH_SEPARATOR) Facter.search(*paths) end } ) define_settings( :transaction, :tags => { :default => "", :desc => "Tags to use to find resources. If this is set, then only resources tagged with the specified tags will be applied. Values must be comma-separated.", }, :evaltrace => { :default => false, :type => :boolean, :desc => "Whether each resource should log when it is being evaluated. This allows you to interactively see exactly what is being done.", }, :summarize => { :default => false, :type => :boolean, :desc => "Whether to print a transaction summary.", } ) define_settings( :main, :external_nodes => { :default => "none", :desc => "An external command that can produce node information. The command's output must be a YAML dump of a hash, and that hash must have a `classes` key and/or a `parameters` key, where `classes` is an array or hash and `parameters` is a hash. For unknown nodes, the command should exit with a non-zero exit code. This command makes it straightforward to store your node mapping information in other data sources like databases.", } ) define_settings( :ldap, :ldapssl => { :default => false, :type => :boolean, :desc => "Whether SSL should be used when searching for nodes. Defaults to false because SSL usually requires certificates to be set up on the client side.", }, :ldaptls => { :default => false, :type => :boolean, :desc => "Whether TLS should be used when searching for nodes. Defaults to false because TLS usually requires certificates to be set up on the client side.", }, :ldapserver => { :default => "ldap", :desc => "The LDAP server. Only used if `node_terminus` is set to `ldap`.", }, :ldapport => { :default => 389, :desc => "The LDAP port. Only used if `node_terminus` is set to `ldap`.", }, :ldapstring => { :default => "(&(objectclass=puppetClient)(cn=%s))", :desc => "The search string used to find an LDAP node.", }, :ldapclassattrs => { :default => "puppetclass", :desc => "The LDAP attributes to use to define Puppet classes. Values should be comma-separated.", }, :ldapstackedattrs => { :default => "puppetvar", :desc => "The LDAP attributes that should be stacked to arrays by adding the values in all hierarchy elements of the tree. Values should be comma-separated.", }, :ldapattrs => { :default => "all", :desc => "The LDAP attributes to include when querying LDAP for nodes. All returned attributes are set as variables in the top-level scope. Multiple values should be comma-separated. The value 'all' returns all attributes.", }, :ldapparentattr => { :default => "parentnode", :desc => "The attribute to use to define the parent node.", }, :ldapuser => { :default => "", :desc => "The user to use to connect to LDAP. Must be specified as a full DN.", }, :ldappassword => { :default => "", :desc => "The password to use to connect to LDAP.", }, :ldapbase => { :default => "", :desc => "The search base for LDAP searches. It's impossible to provide a meaningful default here, although the LDAP libraries might have one already set. Generally, it should be the 'ou=Hosts' branch under your main directory.", } ) define_settings(:master, :storeconfigs => { :default => false, :type => :boolean, :desc => "Whether to store each client's configuration, including catalogs, facts, and related data. This also enables the import and export of resources in the Puppet language - a mechanism for exchange resources between nodes. By default this uses the 'puppetdb' backend. You can adjust the backend using the storeconfigs_backend setting.", # Call our hook with the default value, so we always get the libdir set. :call_hook => :on_initialize_and_write, :hook => proc do |value| require 'puppet/node' require 'puppet/node/facts' if value Puppet::Resource::Catalog.indirection.cache_class = :store_configs Puppet.settings.override_default(:catalog_cache_terminus, :store_configs) Puppet::Node::Facts.indirection.cache_class = :store_configs Puppet::Resource.indirection.terminus_class = :store_configs end end }, :storeconfigs_backend => { :type => :terminus, :default => "puppetdb", :desc => "Configure the backend terminus used for StoreConfigs. By default, this uses the PuppetDB store, which must be installed and configured before turning on StoreConfigs." } ) define_settings(:parser, :max_errors => { :default => 10, :desc => <<-'EOT' Sets the max number of logged/displayed parser validation errors in case multiple errors have been detected. A value of 0 is the same as a value of 1; a minimum of one error is always raised. The count is per manifest. EOT }, :max_warnings => { :default => 10, :desc => <<-'EOT' Sets the max number of logged/displayed parser validation warnings in case multiple warnings have been detected. A value of 0 blocks logging of warnings. The count is per manifest. EOT }, :max_deprecations => { :default => 10, :desc => <<-'EOT' Sets the max number of logged/displayed parser validation deprecation warnings in case multiple deprecation warnings have been detected. A value of 0 blocks the logging of deprecation warnings. The count is per manifest. EOT }, :strict_variables => { :default => false, :type => :boolean, :desc => <<-'EOT' Makes the parser raise errors when referencing unknown variables. (This does not affect referencing variables that are explicitly set to undef). EOT } ) define_settings(:puppetdoc, :document_all => { :default => false, :type => :boolean, :desc => "Whether to document all resources when using `puppet doc` to generate manifest documentation.", } ) end diff --git a/lib/puppet/reference/configuration.rb b/lib/puppet/reference/configuration.rb index c4b4c6db7..0475067a3 100644 --- a/lib/puppet/reference/configuration.rb +++ b/lib/puppet/reference/configuration.rb @@ -1,73 +1,73 @@ config = Puppet::Util::Reference.newreference(:configuration, :depth => 1, :doc => "A reference for all settings") do docs = {} Puppet.settings.each do |name, object| docs[name] = object end str = "" docs.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |name, object| # Make each name an anchor header = name.to_s str << markdown_header(header, 3) # Print the doc string itself begin str << Puppet::Util::Docs.scrub(object.desc) rescue => detail Puppet.log_exception(detail) end str << "\n\n" # Now print the data about the item. val = object.default if name.to_s == "vardir" - val = "/opt/puppetlabs/agent/cache" + val = "/var/lib/puppet" elsif name.to_s == "confdir" - val = "/etc/puppetlabs/agent" + val = "/etc/puppet" end # Leave out the section information; it was apparently confusing people. #str << "- **Section**: #{object.section}\n" unless val == "" str << "- *Default*: #{val}\n" end str << "\n" end return str end config.header = <?\fR will always attempt to load the feature (which can be an expensive operation) unless it has already been loaded successfully\. This makes it possible for a single agent run to, e\.g\., install a package that provides the underlying capabilities for a feature, and then later load that feature during the same run (even if the feature had been tested earlier and had not been available)\. . .P If this setting is set to true, then features will only be checked once, and if they are not available, the negative result is cached and returned for all subsequent attempts to load the feature\. This behavior is almost always appropriate for the server, and can result in a significant performance improvement for features that are checked frequently\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "archive_file_server" During an inspect run, the file bucket server to archive files to if archive_files is set\. . .IP "\(bu" 4 \fIDefault\fR: $server . .IP "" 0 . .SS "archive_files" During an inspect run, whether to archive files whose contents are audited to a file bucket\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "autoflush" Whether log files should always flush to disk\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .SS "autosign" Whether (and how) to autosign certificate requests\. This setting is only relevant on a puppet master acting as a certificate authority (CA)\. . .P Valid values are true (autosigns all certificate requests; not recommended), false (disables autosigning certificates), or the absolute path to a file\. . .P The file specified in this setting may be either a \fBconfiguration file\fR or a \fBcustom policy executable\.\fR Puppet will automatically determine what it is: If the Puppet user (see the \fBuser\fR setting) can execute the file, it will be treated as a policy executable; otherwise, it will be treated as a config file\. . .P If a custom policy executable is configured, the CA puppet master will run it every time it receives a CSR\. The executable will be passed the subject CN of the request \fIas a command line argument,\fR and the contents of the CSR in PEM format \fIon stdin\.\fR It should exit with a status of 0 if the cert should be autosigned and non\-zero if the cert should not be autosigned\. . .P If a certificate request is not autosigned, it will persist for review\. An admin user can use the \fBpuppet cert sign\fR command to manually sign it, or can delete the request\. . .P For info on autosign configuration files, see the guide to Puppet\'s config files \fIhttp://docs\.puppetlabs\.com/guides/configuring\.html\fR\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/autosign\.conf . .IP "" 0 . .SS "basemodulepath" The search path for \fBglobal\fR modules\. Should be specified as a list of directories separated by the system path separator character\. (The POSIX path separator is \':\', and the Windows path separator is \';\'\.) . .P These are the modules that will be used by \fIall\fR environments\. Note that the \fBmodules\fR directory of the active environment will have priority over any global directories\. For more info, see http://docs\.puppetlabs\.com/puppet/latest/reference/environments\.html . .IP "\(bu" 4 \fIDefault\fR: $confdir/modules:/usr/share/puppet/modules . .IP "" 0 . .SS "bindaddress" The address a listening server should bind to\. . .IP "\(bu" 4 \fIDefault\fR: 0\.0\.0\.0 . .IP "" 0 . .SS "binder_config" The binder configuration file\. Puppet reads this file on each request to configure the bindings system\. If set to nil (the default), a $confdir/binder_config\.yaml is optionally loaded\. If it does not exists, a default configuration is used\. If the setting :binding_config is specified, it must reference a valid and existing yaml file\. . .TP \fIDefault\fR: . .SS "bucketdir" Where FileBucket files are stored\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/bucket . .IP "" 0 . .SS "ca" Whether the master should function as a certificate authority\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .SS "ca_name" The name to use the Certificate Authority certificate\. . .IP "\(bu" 4 \fIDefault\fR: Puppet CA: $certname . .IP "" 0 . .SS "ca_port" The port to use for the certificate authority\. . .IP "\(bu" 4 \fIDefault\fR: $masterport . .IP "" 0 . .SS "ca_server" The server to use for certificate authority requests\. It\'s a separate server because it cannot and does not need to horizontally scale\. . .IP "\(bu" 4 \fIDefault\fR: $server . .IP "" 0 . .SS "ca_ttl" The default TTL for new certificates\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. . .IP "\(bu" 4 \fIDefault\fR: 5y . .IP "" 0 . .SS "cacert" The CA certificate\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/ca_crt\.pem . .IP "" 0 . .SS "cacrl" The certificate revocation list (CRL) for the CA\. Will be used if present but otherwise ignored\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/ca_crl\.pem . .IP "" 0 . .SS "cadir" The root directory for the certificate authority\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/ca . .IP "" 0 . .SS "cakey" The CA private key\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/ca_key\.pem . .IP "" 0 . .SS "capass" Where the CA stores the password for the private key\. . .IP "\(bu" 4 \fIDefault\fR: $caprivatedir/ca\.pass . .IP "" 0 . .SS "caprivatedir" Where the CA stores private certificate information\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/private . .IP "" 0 . .SS "capub" The CA public key\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/ca_pub\.pem . .IP "" 0 . .SS "catalog_cache_terminus" How to store cached catalogs\. Valid values are \'json\', \'msgpack\' and \'yaml\'\. The agent application defaults to \'json\'\. . .TP \fIDefault\fR: . .SS "catalog_terminus" Where to get node catalogs\. This is useful to change if, for instance, you\'d like to pre\-compile catalogs and store them in memcached or some other easily\-accessed store\. . .IP "\(bu" 4 \fIDefault\fR: compiler . .IP "" 0 . .SS "cert_inventory" The inventory file\. This is a text file to which the CA writes a complete listing of all certificates\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/inventory\.txt . .IP "" 0 . .SS "certdir" The certificate directory\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/certs . .IP "" 0 . .SS "certificate_revocation" Whether certificate revocation should be supported by downloading a Certificate Revocation List (CRL) to all clients\. If enabled, CA chaining will almost definitely not work\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .SS "certname" The name to use when handling certificates\. When a node requests a certificate from the CA puppet master, it uses the value of the \fBcertname\fR setting as its requested Subject CN\. . .P This is the name used when managing a node\'s permissions in auth\.conf \fIhttp://docs\.puppetlabs\.com/puppet/latest/reference/config_file_auth\.html\fR\. In most cases, it is also used as the node\'s name when matching node definitions \fIhttp://docs\.puppetlabs\.com/puppet/latest/reference/lang_node_definitions\.html\fR and requesting data from an ENC\. (This can be changed with the \fBnode_name_value\fR and \fBnode_name_fact\fR settings, although you should only do so if you have a compelling reason\.) . .P A node\'s certname is available in Puppet manifests as \fB$trusted[\'certname\']\fR\. (See Facts and Built\-In Variables \fIhttp://docs\.puppetlabs\.com/puppet/latest/reference/lang_facts_and_builtin_vars\.html\fR for more details\.) . .IP "\(bu" 4 For best compatibility, you should limit the value of \fBcertname\fR to only use letters, numbers, periods, underscores, and dashes\. (That is, it should match \fB/A[a\-z0\-9\._\-]+Z/\fR\.) . .IP "\(bu" 4 The special value \fBca\fR is reserved, and can\'t be used as the certname for a normal node\. . .IP "" 0 . .P Defaults to the node\'s fully qualified domain name\. . .IP "\(bu" 4 \fIDefault\fR: kylo\.corp\.puppetlabs\.net . .IP "" 0 . .SS "cfacter" Whether or not to use the native facter (cfacter) implementation instead of the Ruby one (facter)\. Defaults to false\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "classfile" The file in which puppet agent stores a list of the classes associated with the retrieved configuration\. Can be loaded in the separate \fBpuppet\fR executable using the \fB\-\-loadclasses\fR option\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/classes\.txt . .IP "" 0 . .SS "client_datadir" The directory in which serialized data is stored on the client\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/client_data . .IP "" 0 . .SS "clientbucketdir" Where FileBucket files are stored locally\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/clientbucket . .IP "" 0 . .SS "clientyamldir" The directory in which client\-side YAML data is stored\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/client_yaml . .IP "" 0 . .SS "code" Code to parse directly\. This is essentially only used by \fBpuppet\fR, and should only be set if you\'re writing your own Puppet executable\. . .SS "color" Whether to use colors when logging to the console\. Valid values are \fBansi\fR (equivalent to \fBtrue\fR), \fBhtml\fR, and \fBfalse\fR, which produces no color\. Defaults to false on Windows, as its console does not support ansi colors\. . .IP "\(bu" 4 \fIDefault\fR: ansi . .IP "" 0 . .SS "confdir" The main Puppet configuration directory\. The default for this setting is calculated based on the user\. If the process is running as root or the user that Puppet is supposed to run as, it defaults to a system directory, but if it\'s running as any other user, it defaults to being in the user\'s home directory\. . .IP "\(bu" 4 -\fIDefault\fR: /etc/puppetlabs/agent +\fIDefault\fR: /etc/puppet . .IP "" 0 . .SS "config" The configuration file for the current puppet application\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/${config_file_name} . .IP "" 0 . .SS "config_file_name" The name of the puppet config file\. . .IP "\(bu" 4 \fIDefault\fR: puppet\.conf . .IP "" 0 . .SS "config_version" How to determine the configuration version\. By default, it will be the time that the configuration is parsed, but you can provide a shell script to override how the version is determined\. The output of this script will be added to every log message in the reports, allowing you to correlate changes on your hosts to the source version on the server\. . .P Setting a global value for config_version in puppet\.conf is not allowed (but it can be overridden from the commandline)\. Please set a per\-environment value in environment\.conf instead\. For more info, see http://docs\.puppetlabs\.com/puppet/latest/reference/environments\.html . .SS "configprint" Print the value of a specific configuration setting\. If the name of a setting is provided for this, then the value is printed and puppet exits\. Comma\-separate multiple values\. For a list of all values, specify \'all\'\. . .SS "configtimeout" How long the client should wait for the configuration to be retrieved before considering it a failure\. This setting is deprecated and has been replaced by http_connect_timeout and http_read_timeout\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. . .IP "\(bu" 4 \fIDefault\fR: 2m . .IP "" 0 . .SS "csr_attributes" An optional file containing custom attributes to add to certificate signing requests (CSRs)\. You should ensure that this file does not exist on your CA puppet master; if it does, unwanted certificate extensions may leak into certificates created with the \fBpuppet cert generate\fR command\. . .P If present, this file must be a YAML hash containing a \fBcustom_attributes\fR key and/or an \fBextension_requests\fR key\. The value of each key must be a hash, where each key is a valid OID and each value is an object that can be cast to a string\. . .P Custom attributes can be used by the CA when deciding whether to sign the certificate, but are then discarded\. Attribute OIDs can be any OID value except the standard CSR attributes (i\.e\. attributes described in RFC 2985 section 5\.4)\. This is useful for embedding a pre\-shared key for autosigning policy executables (see the \fBautosign\fR setting), often by using the \fB1\.2\.840\.113549\.1\.9\.7\fR ("challenge password") OID\. . .P Extension requests will be permanently embedded in the final certificate\. Extension OIDs must be in the "ppRegCertExt" (\fB1\.3\.6\.1\.4\.1\.34380\.1\.1\fR) or "ppPrivCertExt" (\fB1\.3\.6\.1\.4\.1\.34380\.1\.2\fR) OID arcs\. The ppRegCertExt arc is reserved for four of the most common pieces of data to embed: \fBpp_uuid\fR (\fB\.1\fR), \fBpp_instance_id\fR (\fB\.2\fR), \fBpp_image_name\fR (\fB\.3\fR), and \fBpp_preshared_key\fR (\fB\.4\fR) \-\-\- in the YAML file, these can be referred to by their short descriptive names instead of their full OID\. The ppPrivCertExt arc is unregulated, and can be used for site\-specific extensions\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/csr_attributes\.yaml . .IP "" 0 . .SS "csrdir" Where the CA stores certificate requests . .IP "\(bu" 4 \fIDefault\fR: $cadir/requests . .IP "" 0 . .SS "daemonize" Whether to send the process into the background\. This defaults to true on POSIX systems, and to false on Windows (where Puppet currently cannot daemonize)\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .SS "data_binding_terminus" Where to retrive information about data\. . .IP "\(bu" 4 \fIDefault\fR: hiera . .IP "" 0 . .SS "default_file_terminus" The default source for files if no server is given in a uri, e\.g\. puppet:///file\. The default of \fBrest\fR causes the file to be retrieved using the \fBserver\fR setting\. When running \fBapply\fR the default is \fBfile_server\fR, causing requests to be filled locally\. . .IP "\(bu" 4 \fIDefault\fR: rest . .IP "" 0 . .SS "default_manifest" The default main manifest for directory environments\. Any environment that doesn\'t set the \fBmanifest\fR setting in its \fBenvironment\.conf\fR file will use this manifest\. . .P This setting\'s value can be an absolute or relative path\. An absolute path will make all environments default to the same main manifest; a relative path will allow each environment to use its own manifest, and Puppet will resolve the path relative to each environment\'s main directory\. . .P In either case, the path can point to a single file or to a directory of manifests to be evaluated in alphabetical order\. . .IP "\(bu" 4 \fIDefault\fR: \./manifests . .IP "" 0 . .SS "default_schedules" Boolean; whether to generate the default schedule resources\. Setting this to false is useful for keeping external report processors clean of skipped schedule resources\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .SS "deviceconfig" Path to the device config file for puppet device\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/device\.conf . .IP "" 0 . .SS "devicedir" The root directory of devices\' $vardir\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/devices . .IP "" 0 . .SS "diff" Which diff command to use when printing differences between files\. This setting has no default value on Windows, as standard \fBdiff\fR is not available, but Puppet can use many third\-party diff tools\. . .IP "\(bu" 4 \fIDefault\fR: diff . .IP "" 0 . .SS "diff_args" Which arguments to pass to the diff command when printing differences between files\. The command to use can be chosen with the \fBdiff\fR setting\. . .IP "\(bu" 4 \fIDefault\fR: \-u . .IP "" 0 . .SS "digest_algorithm" Which digest algorithm to use for file resources and the filebucket\. Valid values are md5, sha256\. Default is md5\. . .IP "\(bu" 4 \fIDefault\fR: md5 . .IP "" 0 . .SS "disable_per_environment_manifest" Whether to disallow an environment\-specific main manifest\. When set to \fBtrue\fR, Puppet will use the manifest specified in the \fBdefault_manifest\fR setting for all environments\. If an environment specifies a different main manifest in its \fBenvironment\.conf\fR file, catalog requests for that environment will fail with an error\. . .P This setting requires \fBdefault_manifest\fR to be set to an absolute path\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "disable_warnings" A comma\-separated list of warning types to suppress\. If large numbers of warnings are making Puppet\'s logs too large or difficult to use, you can temporarily silence them with this setting\. . .P If you are preparing to upgrade Puppet to a new major version, you should re\-enable all warnings for a while\. . .P Valid values for this setting are: . .IP "\(bu" 4 \fBdeprecations\fR \-\-\- disables deprecation warnings\. . .IP "\(bu" 4 \fIDefault\fR: [] . .IP "" 0 . .SS "dns_alt_names" The comma\-separated list of alternative DNS names to use for the local host\. . .P When the node generates a CSR for itself, these are added to the request as the desired \fBsubjectAltName\fR in the certificate: additional DNS labels that the certificate is also valid answering as\. . .P This is generally required if you use a non\-hostname \fBcertname\fR, or if you want to use \fBpuppet kick\fR or \fBpuppet resource \-H\fR and the primary certname does not match the DNS name you use to communicate with the host\. . .P This is unnecessary for agents, unless you intend to use them as a server for \fBpuppet kick\fR or remote \fBpuppet resource\fR management\. . .P It is rarely necessary for servers; it is usually helpful only if you need to have a pool of multiple load balanced masters, or for the same master to respond on two physically separate networks under different names\. . .SS "document_all" Whether to document all resources when using \fBpuppet doc\fR to generate manifest documentation\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "environment" The environment Puppet is running in\. For clients (e\.g\., \fBpuppet agent\fR) this determines the environment itself, which is used to find modules and much more\. For servers (i\.e\., \fBpuppet master\fR) this provides the default environment for nodes we know nothing about\. . .IP "\(bu" 4 \fIDefault\fR: production . .IP "" 0 . .SS "environment_data_provider" The name of a registered environment data provider\. The two built in and registered providers are \'none\' (no environment specific data), and \'function\' (environment specific data obtained by calling the function \'environment::data()\')\. Other environment data providers may be registered in modules on the module path\. For such custom data providers see the respective module documentation\. . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . .SS "environment_timeout" The time to live for a cached environment\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. This setting can also be set to \fBunlimited\fR, which causes the environment to be cached until the master is restarted\. . .IP "\(bu" 4 \fIDefault\fR: unlimited . .IP "" 0 . .SS "environmentpath" A search path for directory environments, as a list of directories separated by the system path separator character\. (The POSIX path separator is \':\', and the Windows path separator is \';\'\.) . .P This setting must have a value set to enable \fBdirectory environments\.\fR The recommended value is \fB$confdir/environments\fR\. For more details, see http://docs\.puppetlabs\.com/puppet/latest/reference/environments\.html . .IP "\(bu" 4 \fIDefault\fR: $confdir/environments . .IP "" 0 . .SS "evaltrace" Whether each resource should log when it is being evaluated\. This allows you to interactively see exactly what is being done\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "external_nodes" An external command that can produce node information\. The command\'s output must be a YAML dump of a hash, and that hash must have a \fBclasses\fR key and/or a \fBparameters\fR key, where \fBclasses\fR is an array or hash and \fBparameters\fR is a hash\. For unknown nodes, the command should exit with a non\-zero exit code\. . .P This command makes it straightforward to store your node mapping information in other data sources like databases\. . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . .SS "factpath" Where Puppet should look for facts\. Multiple directories should be separated by the system path separator character\. (The POSIX path separator is \':\', and the Windows path separator is \';\'\.) . .IP "\(bu" 4 \fIDefault\fR: $vardir/lib/facter:$vardir/facts . .IP "" 0 . .SS "facts_terminus" The node facts terminus\. . .IP "\(bu" 4 \fIDefault\fR: facter . .IP "" 0 . .SS "fileserverconfig" Where the fileserver configuration is stored\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/fileserver\.conf . .IP "" 0 . .SS "filetimeout" The minimum time to wait between checking for updates in configuration files\. This timeout determines how quickly Puppet checks whether a file (such as manifests or templates) has changed on disk\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. . .IP "\(bu" 4 \fIDefault\fR: 15s . .IP "" 0 . .SS "forge_authorization" The authorization key to connect to the Puppet Forge\. Leave blank for unauthorized or license based connections . .TP \fIDefault\fR: . .SS "freeze_main" Freezes the \'main\' class, disallowing any code to be added to it\. This essentially means that you can\'t have any code outside of a node, class, or definition other than in the site manifest\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "genconfig" When true, causes Puppet applications to print an example config file to stdout and exit\. The example will include descriptions of each setting, and the current (or default) value of each setting, incorporating any settings overridden on the CLI (with the exception of \fBgenconfig\fR itself)\. This setting only makes sense when specified on the command line as \fB\-\-genconfig\fR\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "genmanifest" Whether to just print a manifest to stdout and exit\. Only makes sense when specified on the command line as \fB\-\-genmanifest\fR\. Takes into account arguments specified on the CLI\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "graph" Whether to create dot graph files for the different configuration graphs\. These dot files can be interpreted by tools like OmniGraffle or dot (which is part of ImageMagick)\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "graphdir" Where to store dot\-outputted graphs\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/graphs . .IP "" 0 . .SS "group" The group puppet master should run as\. . .IP "\(bu" 4 \fIDefault\fR: puppet . .IP "" 0 . .SS "hiera_config" The hiera configuration file\. Puppet only reads this file on startup, so you must restart the puppet master every time you edit it\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/hiera\.yaml . .IP "" 0 . .SS "hostcert" Where individual hosts store and look for their certificates\. . .IP "\(bu" 4 \fIDefault\fR: $certdir/$certname\.pem . .IP "" 0 . .SS "hostcrl" Where the host\'s certificate revocation list can be found\. This is distinct from the certificate authority\'s CRL\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/crl\.pem . .IP "" 0 . .SS "hostcsr" Where individual hosts store and look for their certificate requests\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/csr_$certname\.pem . .IP "" 0 . .SS "hostprivkey" Where individual hosts store and look for their private key\. . .IP "\(bu" 4 \fIDefault\fR: $privatekeydir/$certname\.pem . .IP "" 0 . .SS "hostpubkey" Where individual hosts store and look for their public key\. . .IP "\(bu" 4 \fIDefault\fR: $publickeydir/$certname\.pem . .IP "" 0 . .SS "http_connect_timeout" The maximum amount of time to wait when establishing an HTTP connection\. The default value is 2 minutes\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. . .IP "\(bu" 4 \fIDefault\fR: 2m . .IP "" 0 . .SS "http_debug" Whether to write HTTP request and responses to stderr\. This should never be used in a production environment\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "http_keepalive_timeout" The maximum amount of time a persistent HTTP connection can remain idle in the connection pool, before it is closed\. This timeout should be shorter than the keepalive timeout used on the HTTP server, e\.g\. Apache KeepAliveTimeout directive\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. . .IP "\(bu" 4 \fIDefault\fR: 4s . .IP "" 0 . .SS "http_proxy_host" The HTTP proxy host to use for outgoing connections\. Note: You may need to use a FQDN for the server hostname when using a proxy\. Environment variable http_proxy or HTTP_PROXY will override this value . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . .SS "http_proxy_password" The password for the user of an authenticated HTTP proxy\. Requires the \fBhttp_proxy_user\fR setting\. . .P Note that passwords must be valid when used as part of a URL\. If a password contains any characters with special meanings in URLs (as specified by RFC 3986 section 2\.2), they must be URL\-encoded\. (For example, \fB#\fR would become \fB%23\fR\.) . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . .SS "http_proxy_port" The HTTP proxy port to use for outgoing connections . .IP "\(bu" 4 \fIDefault\fR: 3128 . .IP "" 0 . .SS "http_proxy_user" The user name for an authenticated HTTP proxy\. Requires the \fBhttp_proxy_host\fR setting\. . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . .SS "http_read_timeout" The time to wait for one block to be read from an HTTP connection\. If nothing is read after the elapsed interval then the connection will be closed\. The default value is unlimited\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. . .TP \fIDefault\fR: . .SS "ignorecache" Ignore cache and always recompile the configuration\. This is useful for testing new configurations, where the local cache may in fact be stale even if the timestamps are up to date \- if the facts change or if the server changes\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "ignoreimport" If true, allows the parser to continue without requiring all files referenced with \fBimport\fR statements to exist\. This setting was primarily designed for use with commit hooks for parse\-checking\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "ignoremissingtypes" Skip searching for classes and definitions that were missing during a prior compilation\. The list of missing objects is maintained per\-environment and persists until the environment is cleared or the master is restarted\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "ignoreschedules" Boolean; whether puppet agent should ignore schedules\. This is useful for initial puppet agent runs\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "keylength" The bit length of keys\. . .IP "\(bu" 4 \fIDefault\fR: 4096 . .IP "" 0 . .SS "lastrunfile" Where puppet agent stores the last run report summary in yaml format\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/last_run_summary\.yaml . .IP "" 0 . .SS "lastrunreport" Where puppet agent stores the last run report in yaml format\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/last_run_report\.yaml . .IP "" 0 . .SS "ldapattrs" The LDAP attributes to include when querying LDAP for nodes\. All returned attributes are set as variables in the top\-level scope\. Multiple values should be comma\-separated\. The value \'all\' returns all attributes\. . .IP "\(bu" 4 \fIDefault\fR: all . .IP "" 0 . .SS "ldapbase" The search base for LDAP searches\. It\'s impossible to provide a meaningful default here, although the LDAP libraries might have one already set\. Generally, it should be the \'ou=Hosts\' branch under your main directory\. . .SS "ldapclassattrs" The LDAP attributes to use to define Puppet classes\. Values should be comma\-separated\. . .IP "\(bu" 4 \fIDefault\fR: puppetclass . .IP "" 0 . .SS "ldapparentattr" The attribute to use to define the parent node\. . .IP "\(bu" 4 \fIDefault\fR: parentnode . .IP "" 0 . .SS "ldappassword" The password to use to connect to LDAP\. . .SS "ldapport" The LDAP port\. Only used if \fBnode_terminus\fR is set to \fBldap\fR\. . .IP "\(bu" 4 \fIDefault\fR: 389 . .IP "" 0 . .SS "ldapserver" The LDAP server\. Only used if \fBnode_terminus\fR is set to \fBldap\fR\. . .IP "\(bu" 4 \fIDefault\fR: ldap . .IP "" 0 . .SS "ldapssl" Whether SSL should be used when searching for nodes\. Defaults to false because SSL usually requires certificates to be set up on the client side\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "ldapstackedattrs" The LDAP attributes that should be stacked to arrays by adding the values in all hierarchy elements of the tree\. Values should be comma\-separated\. . .IP "\(bu" 4 \fIDefault\fR: puppetvar . .IP "" 0 . .SS "ldapstring" The search string used to find an LDAP node\. . .IP "\(bu" 4 \fIDefault\fR: (&(objectclass=puppetClient)(cn=%s)) . .IP "" 0 . .SS "ldaptls" Whether TLS should be used when searching for nodes\. Defaults to false because TLS usually requires certificates to be set up on the client side\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "ldapuser" The user to use to connect to LDAP\. Must be specified as a full DN\. . .SS "libdir" An extra search path for Puppet\. This is only useful for those files that Puppet will load on demand, and is only guaranteed to work for those cases\. In fact, the autoload mechanism is responsible for making sure this directory is in Ruby\'s search path . .IP "\(bu" 4 \fIDefault\fR: $vardir/lib . .IP "" 0 . .SS "localcacert" Where each client stores the CA certificate\. . .IP "\(bu" 4 \fIDefault\fR: $certdir/ca\.pem . .IP "" 0 . .SS "log_level" Default logging level for messages from Puppet\. Allowed values are: . .IP "\(bu" 4 debug . .IP "\(bu" 4 info . .IP "\(bu" 4 notice . .IP "\(bu" 4 warning . .IP "\(bu" 4 err . .IP "\(bu" 4 alert . .IP "\(bu" 4 emerg . .IP "\(bu" 4 crit . .IP "\(bu" 4 \fIDefault\fR: notice . .IP "" 0 . .SS "logdir" The directory in which to store log files . .TP \fIDefault\fR: . .SS "manage_internal_file_permissions" Whether Puppet should manage the owner, group, and mode of files it uses internally . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .SS "manifest" The entry\-point manifest for puppet master\. This can be one file or a directory of manifests to be evaluated in alphabetical order\. Puppet manages this path as a directory if one exists or if the path ends with a / or \. . .P Setting a global value for \fBmanifest\fR in puppet\.conf is not allowed (but it can be overridden from them commandline)\. Please use directory environments instead\. If you need to use something other than the environment\'s \fBmanifests\fR directory as the main manifest, you can set \fBmanifest\fR in environment\.conf\. For more info, see http://docs\.puppetlabs\.com/puppet/latest/reference/environments\.html . .TP \fIDefault\fR: . .SS "masterhttplog" Where the puppet master web server saves its access log\. This is only used when running a WEBrick puppet master\. When puppet master is running under a Rack server like Passenger, that web server will have its own logging behavior\. . .IP "\(bu" 4 \fIDefault\fR: $logdir/masterhttp\.log . .IP "" 0 . .SS "masterport" The port for puppet master traffic\. For puppet master, this is the port to listen on; for puppet agent, this is the port to make requests on\. Both applications use this setting to get the port\. . .IP "\(bu" 4 \fIDefault\fR: 8140 . .IP "" 0 . .SS "max_deprecations" Sets the max number of logged/displayed parser validation deprecation warnings in case multiple deprecation warnings have been detected\. A value of 0 blocks the logging of deprecation warnings\. The count is per manifest\. . .IP "\(bu" 4 \fIDefault\fR: 10 . .IP "" 0 . .SS "max_errors" Sets the max number of logged/displayed parser validation errors in case multiple errors have been detected\. A value of 0 is the same as a value of 1; a minimum of one error is always raised\. The count is per manifest\. . .IP "\(bu" 4 \fIDefault\fR: 10 . .IP "" 0 . .SS "max_warnings" Sets the max number of logged/displayed parser validation warnings in case multiple warnings have been detected\. A value of 0 blocks logging of warnings\. The count is per manifest\. . .IP "\(bu" 4 \fIDefault\fR: 10 . .IP "" 0 . .SS "maximum_uid" The maximum allowed UID\. Some platforms use negative UIDs but then ship with tools that do not know how to handle signed ints, so the UIDs show up as huge numbers that can then not be fed back into the system\. This is a hackish way to fail in a slightly more useful way when that happens\. . .IP "\(bu" 4 \fIDefault\fR: 4294967290 . .IP "" 0 . .SS "mkusers" Whether to create the necessary user and group that puppet agent will run as\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "module_groups" Extra module groups to request from the Puppet Forge . .TP \fIDefault\fR: . .SS "module_repository" The module repository . .IP "\(bu" 4 \fIDefault\fR: https://forgeapi\.puppetlabs\.com . .IP "" 0 . .SS "module_skeleton_dir" The directory which the skeleton for module tool generate is stored\. . .IP "\(bu" 4 \fIDefault\fR: $module_working_dir/skeleton . .IP "" 0 . .SS "module_working_dir" The directory into which module tool data is stored . .IP "\(bu" 4 \fIDefault\fR: $vardir/puppet\-module . .IP "" 0 . .SS "modulepath" The search path for modules, as a list of directories separated by the system path separator character\. (The POSIX path separator is \':\', and the Windows path separator is \';\'\.) . .P Setting a global value for \fBmodulepath\fR in puppet\.conf is not allowed (but it can be overridden from the commandline)\. Please use directory environments instead\. If you need to use something other than the default modulepath of \fB:$basemodulepath\fR, you can set \fBmodulepath\fR in environment\.conf\. For more info, see http://docs\.puppetlabs\.com/puppet/latest/reference/environments\.html . .SS "name" The name of the application, if we are running as one\. The default is essentially $0 without the path or \fB\.rb\fR\. . .TP \fIDefault\fR: . .SS "node_cache_terminus" How to store cached nodes\. Valid values are (none), \'json\', \'msgpack\', \'yaml\' or write only yaml (\'write_only_yaml\')\. The master application defaults to \'write_only_yaml\', all others to none\. . .TP \fIDefault\fR: . .SS "node_name" How the puppet master determines the client\'s identity and sets the \'hostname\', \'fqdn\' and \'domain\' facts for use in the manifest, in particular for determining which \'node\' statement applies to the client\. Possible values are \'cert\' (use the subject\'s CN in the client\'s certificate) and \'facter\' (use the hostname that the client reported in its facts) . .IP "\(bu" 4 \fIDefault\fR: cert . .IP "" 0 . .SS "node_name_fact" The fact name used to determine the node name used for all requests the agent makes to the master\. WARNING: This setting is mutually exclusive with node_name_value\. Changing this setting also requires changes to the default auth\.conf configuration on the Puppet Master\. Please see http://links\.puppetlabs\.com/node_name_fact for more information\. . .SS "node_name_value" The explicit value used for the node name for all requests the agent makes to the master\. WARNING: This setting is mutually exclusive with node_name_fact\. Changing this setting also requires changes to the default auth\.conf configuration on the Puppet Master\. Please see http://links\.puppetlabs\.com/node_name_value for more information\. . .IP "\(bu" 4 \fIDefault\fR: $certname . .IP "" 0 . .SS "node_terminus" Where to find information about nodes\. . .IP "\(bu" 4 \fIDefault\fR: plain . .IP "" 0 . .SS "noop" Whether to apply catalogs in noop mode, which allows Puppet to partially simulate a normal run\. This setting affects puppet agent and puppet apply\. . .P When running in noop mode, Puppet will check whether each resource is in sync, like it does when running normally\. However, if a resource attribute is not in the desired state (as declared in the catalog), Puppet will take no action, and will instead report the changes it \fIwould\fR have made\. These simulated changes will appear in the report sent to the puppet master, or be shown on the console if running puppet agent or puppet apply in the foreground\. The simulated changes will not send refresh events to any subscribing or notified resources, although Puppet will log that a refresh event \fIwould\fR have been sent\. . .P \fBImportant note:\fR The \fBnoop\fR metaparameter \fIhttp://docs\.puppetlabs\.com/references/latest/metaparameter\.html#noop\fR allows you to apply individual resources in noop mode, and will override the global value of the \fBnoop\fR setting\. This means a resource with \fBnoop => false\fR \fIwill\fR be changed if necessary, even when running puppet agent with \fBnoop = true\fR or \fB\-\-noop\fR\. (Conversely, a resource with \fBnoop => true\fR will only be simulated, even when noop mode is globally disabled\.) . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "onetime" Perform one configuration run and exit, rather than spawning a long\-running daemon\. This is useful for interactively running puppet agent, or running puppet agent from cron\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "ordering" How unrelated resources should be ordered when applying a catalog\. Allowed values are \fBtitle\-hash\fR, \fBmanifest\fR, and \fBrandom\fR\. This setting affects puppet agent and puppet apply, but not puppet master\. . .IP "\(bu" 4 \fBmanifest\fR (the default) will use the order in which the resources were declared in their manifest files\. . .IP "\(bu" 4 \fBtitle\-hash\fR (the default in 3\.x) will order resources randomly, but will use the same order across runs and across nodes\. It is only of value if you\'re migrating from 3\.x and have errors running with \fBmanifest\fR\. . .IP "\(bu" 4 \fBrandom\fR will order resources randomly and change their order with each run\. This can work like a fuzzer for shaking out undeclared dependencies\. . .IP "" 0 . .P Regardless of this setting\'s value, Puppet will always obey explicit dependencies set with the before/require/notify/subscribe metaparameters and the \fB\->\fR/\fB~>\fR chaining arrows; this setting only affects the relative ordering of \fIunrelated\fR resources\. . .IP "\(bu" 4 \fIDefault\fR: manifest . .IP "" 0 . .SS "passfile" Where puppet agent stores the password for its private key\. Generally unused\. . .IP "\(bu" 4 \fIDefault\fR: $privatedir/password . .IP "" 0 . .SS "path" The shell search path\. Defaults to whatever is inherited from the parent process\. . .P This setting can only be set in the \fB[main]\fR section of puppet\.conf; it cannot be set in \fB[master]\fR, \fB[agent]\fR, or an environment config section\. . .IP "\(bu" 4 \fIDefault\fR: none . .IP "" 0 . .SS "pidfile" The file containing the PID of a running process\. This file is intended to be used by service management frameworks and monitoring systems to determine if a puppet process is still in the process table\. . .IP "\(bu" 4 \fIDefault\fR: $rundir/${run_mode}\.pid . .IP "" 0 . .SS "plugindest" Where Puppet should store plugins that it pulls down from the central server\. . .IP "\(bu" 4 \fIDefault\fR: $libdir . .IP "" 0 . .SS "pluginfactdest" Where Puppet should store external facts that are being handled by pluginsync . .IP "\(bu" 4 \fIDefault\fR: $vardir/facts\.d . .IP "" 0 . .SS "pluginfactsource" Where to retrieve external facts for pluginsync . .IP "\(bu" 4 \fIDefault\fR: puppet:///pluginfacts . .IP "" 0 . .SS "pluginsignore" What files to ignore when pulling down plugins\. . .IP "\(bu" 4 \fIDefault\fR: \.svn CVS \.git . .IP "" 0 . .SS "pluginsource" From where to retrieve plugins\. The standard Puppet \fBfile\fR type is used for retrieval, so anything that is a valid file source can be used here\. . .IP "\(bu" 4 \fIDefault\fR: puppet:///plugins . .IP "" 0 . .SS "pluginsync" Whether plugins should be synced with the central server\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .SS "postrun_command" A command to run after every agent run\. If this command returns a non\-zero return code, the entire Puppet run will be considered to have failed, even though it might have performed work during the normal run\. . .SS "preferred_serialization_format" The preferred means of serializing ruby instances for passing over the wire\. This won\'t guarantee that all instances will be serialized using this method, since not all classes can be guaranteed to support this format, but it will be used for all classes that support it\. . .IP "\(bu" 4 \fIDefault\fR: pson . .IP "" 0 . .SS "prerun_command" A command to run before every agent run\. If this command returns a non\-zero return code, the entire Puppet run will fail\. . .SS "priority" The scheduling priority of the process\. Valid values are \'high\', \'normal\', \'low\', or \'idle\', which are mapped to platform\-specific values\. The priority can also be specified as an integer value and will be passed as is, e\.g\. \-5\. Puppet must be running as a privileged user in order to increase scheduling priority\. . .TP \fIDefault\fR: . .SS "privatedir" Where the client stores private certificate information\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/private . .IP "" 0 . .SS "privatekeydir" The private key directory\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/private_keys . .IP "" 0 . .SS "profile" Whether to enable experimental performance profiling . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "publickeydir" The public key directory\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/public_keys . .IP "" 0 . .SS "puppetdlog" The fallback log file\. This is only used when the \fB\-\-logdest\fR option is not specified AND Puppet is running on an operating system where both the POSIX syslog service and the Windows Event Log are unavailable\. (Currently, no supported operating systems match that description\.) . .P Despite the name, both puppet agent and puppet master will use this file as the fallback logging destination\. . .P For control over logging destinations, see the \fB\-\-logdest\fR command line option in the manual pages for puppet master, puppet agent, and puppet apply\. You can see man pages by running \fBpuppet \-\-help\fR, or read them online at http://docs\.puppetlabs\.com/references/latest/man/\. . .IP "\(bu" 4 \fIDefault\fR: $logdir/puppetd\.log . .IP "" 0 . .SS "report" Whether to send reports after every transaction\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .SS "report_port" The port to communicate with the report_server\. . .IP "\(bu" 4 \fIDefault\fR: $masterport . .IP "" 0 . .SS "report_server" The server to send transaction reports to\. . .IP "\(bu" 4 \fIDefault\fR: $server . .IP "" 0 . .SS "reportdir" The directory in which to store reports\. Each node gets a separate subdirectory in this directory\. This setting is only used when the \fBstore\fR report processor is enabled (see the \fBreports\fR setting)\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/reports . .IP "" 0 . .SS "reports" The list of report handlers to use\. When using multiple report handlers, their names should be comma\-separated, with whitespace allowed\. (For example, \fBreports = http, store\fR\.) . .P This setting is relevant to puppet master and puppet apply\. The puppet master will call these report handlers with the reports it receives from agent nodes, and puppet apply will call them with its own report\. (In all cases, the node applying the catalog must have \fBreport = true\fR\.) . .P See the report reference for information on the built\-in report handlers; custom report handlers can also be loaded from modules\. (Report handlers are loaded from the lib directory, at \fBpuppet/reports/NAME\.rb\fR\.) . .IP "\(bu" 4 \fIDefault\fR: store . .IP "" 0 . .SS "reporturl" The URL that reports should be forwarded to\. This setting is only used when the \fBhttp\fR report processor is enabled (see the \fBreports\fR setting)\. . .IP "\(bu" 4 \fIDefault\fR: http://localhost:3000/reports/upload . .IP "" 0 . .SS "req_bits" The bit length of the certificates\. . .IP "\(bu" 4 \fIDefault\fR: 4096 . .IP "" 0 . .SS "requestdir" Where host certificate requests are stored\. . .IP "\(bu" 4 \fIDefault\fR: $ssldir/certificate_requests . .IP "" 0 . .SS "resourcefile" The file in which puppet agent stores a list of the resources associated with the retrieved configuration\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/resources\.txt . .IP "" 0 . .SS "rest_authconfig" The configuration file that defines the rights to the different rest indirections\. This can be used as a fine\-grained authorization system for \fBpuppet master\fR\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/auth\.conf . .IP "" 0 . .SS "route_file" The YAML file containing indirector route configuration\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/routes\.yaml . .IP "" 0 . .SS "rundir" Where Puppet PID files are kept\. . .TP \fIDefault\fR: . .SS "runinterval" How often puppet agent applies the catalog\. Note that a runinterval of 0 means "run continuously" rather than "never run\." If you want puppet agent to never run, you should start it with the \fB\-\-no\-client\fR option\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. . .IP "\(bu" 4 \fIDefault\fR: 30m . .IP "" 0 . .SS "serial" Where the serial number for certificates is stored\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/serial . .IP "" 0 . .SS "server" The puppet master server to which the puppet agent should connect\. . .IP "\(bu" 4 \fIDefault\fR: puppet . .IP "" 0 . .SS "server_datadir" The directory in which serialized data is stored, usually in a subdirectory\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/server_data . .IP "" 0 . .SS "show_diff" Whether to log and report a contextual diff when files are being replaced\. This causes partial file contents to pass through Puppet\'s normal logging and reporting system, so this setting should be used with caution if you are sending Puppet\'s reports to an insecure destination\. This feature currently requires the \fBdiff/lcs\fR Ruby library\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "signeddir" Where the CA stores signed certificates\. . .IP "\(bu" 4 \fIDefault\fR: $cadir/signed . .IP "" 0 . .SS "splay" Whether to sleep for a pseudo\-random (but consistent) amount of time before a run\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "splaylimit" The maximum time to delay before runs\. Defaults to being the same as the run interval\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. . .IP "\(bu" 4 \fIDefault\fR: $runinterval . .IP "" 0 . .SS "srv_domain" The domain which will be queried to find the SRV records of servers to use\. . .IP "\(bu" 4 \fIDefault\fR: corp\.puppetlabs\.net . .IP "" 0 . .SS "ssl_client_ca_auth" Certificate authorities who issue server certificates\. SSL servers will not be considered authentic unless they possess a certificate issued by an authority listed in this file\. If this setting has no value then the Puppet master\'s CA certificate (localcacert) will be used\. . .TP \fIDefault\fR: . .SS "ssl_client_header" The header containing an authenticated client\'s SSL DN\. This header must be set by the proxy to the authenticated client\'s SSL DN (e\.g\., \fB/CN=puppet\.puppetlabs\.com\fR)\. Puppet will parse out the Common Name (CN) from the Distinguished Name (DN) and use the value of the CN field for authorization\. . .P Note that the name of the HTTP header gets munged by the web server common gateway inteface: an \fBHTTP_\fR prefix is added, dashes are converted to underscores, and all letters are uppercased\. Thus, to use the \fBX\-Client\-DN\fR header, this setting should be \fBHTTP_X_CLIENT_DN\fR\. . .IP "\(bu" 4 \fIDefault\fR: HTTP_X_CLIENT_DN . .IP "" 0 . .SS "ssl_client_verify_header" The header containing the status message of the client verification\. This header must be set by the proxy to \'SUCCESS\' if the client successfully authenticated, and anything else otherwise\. . .P Note that the name of the HTTP header gets munged by the web server common gateway inteface: an \fBHTTP_\fR prefix is added, dashes are converted to underscores, and all letters are uppercased\. Thus, to use the \fBX\-Client\-Verify\fR header, this setting should be \fBHTTP_X_CLIENT_VERIFY\fR\. . .IP "\(bu" 4 \fIDefault\fR: HTTP_X_CLIENT_VERIFY . .IP "" 0 . .SS "ssl_server_ca_auth" Certificate authorities who issue client certificates\. SSL clients will not be considered authentic unless they possess a certificate issued by an authority listed in this file\. If this setting has no value then the Puppet master\'s CA certificate (localcacert) will be used\. . .TP \fIDefault\fR: . .SS "ssldir" Where SSL certificates are kept\. . .IP "\(bu" 4 \fIDefault\fR: $confdir/ssl . .IP "" 0 . .SS "statedir" The directory where Puppet state is stored\. Generally, this directory can be removed without causing harm (although it might result in spurious service restarts)\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/state . .IP "" 0 . .SS "statefile" Where puppet agent and puppet master store state associated with the running configuration\. In the case of puppet master, this file reflects the state discovered through interacting with clients\. . .IP "\(bu" 4 \fIDefault\fR: $statedir/state\.yaml . .IP "" 0 . .SS "storeconfigs" Whether to store each client\'s configuration, including catalogs, facts, and related data\. This also enables the import and export of resources in the Puppet language \- a mechanism for exchange resources between nodes\. . .P By default this uses the \'puppetdb\' backend\. . .P You can adjust the backend using the storeconfigs_backend setting\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "storeconfigs_backend" Configure the backend terminus used for StoreConfigs\. By default, this uses the PuppetDB store, which must be installed and configured before turning on StoreConfigs\. . .IP "\(bu" 4 \fIDefault\fR: puppetdb . .IP "" 0 . .SS "strict_hostname_checking" Whether to only search for the complete hostname as it is in the certificate when searching for node information in the catalogs\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "strict_variables" Makes the parser raise errors when referencing unknown variables\. (This does not affect referencing variables that are explicitly set to undef)\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "summarize" Whether to print a transaction summary\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "syslogfacility" What syslog facility to use when logging to syslog\. Syslog has a fixed list of valid facilities, and you must choose one of those; you cannot just make one up\. . .IP "\(bu" 4 \fIDefault\fR: daemon . .IP "" 0 . .SS "tags" Tags to use to find resources\. If this is set, then only resources tagged with the specified tags will be applied\. Values must be comma\-separated\. . .SS "trace" Whether to print stack traces on some errors . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "trusted_oid_mapping_file" File that provides mapping between custom SSL oids and user\-friendly names . .IP "\(bu" 4 \fIDefault\fR: $confdir/custom_trusted_oid_mapping\.yaml . .IP "" 0 . .SS "use_cached_catalog" Whether to only use the cached catalog rather than compiling a new catalog on every run\. Puppet can be run with this enabled by default and then selectively disabled when a recompile is desired\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "use_srv_records" Whether the server will search for SRV records in DNS for the current domain\. . .IP "\(bu" 4 \fIDefault\fR: false . .IP "" 0 . .SS "usecacheonfailure" Whether to use the cached configuration when the remote configuration will not compile\. This option is useful for testing new configurations, where you want to fix the broken configuration rather than reverting to a known\-good one\. . .IP "\(bu" 4 \fIDefault\fR: true . .IP "" 0 . .SS "user" The user puppet master should run as\. . .IP "\(bu" 4 \fIDefault\fR: puppet . .IP "" 0 . .SS "vardir" Where Puppet stores dynamic and growing data\. The default for this setting is calculated specially, like \fBconfdir\fR_\. . .IP "\(bu" 4 -\fIDefault\fR: /opt/puppetlabs/agent/cache +\fIDefault\fR: /var/lib/puppet . .IP "" 0 . .SS "waitforcert" How frequently puppet agent should ask for a signed certificate\. . .P When starting for the first time, puppet agent will submit a certificate signing request (CSR) to the server named in the \fBca_server\fR setting (usually the puppet master); this may be autosigned, or may need to be approved by a human, depending on the CA server\'s configuration\. . .P Puppet agent cannot apply configurations until its approved certificate is available\. Since the certificate may or may not be available immediately, puppet agent will repeatedly try to fetch it at this interval\. You can turn off waiting for certificates by specifying a time of 0, in which case puppet agent will exit if it cannot get a cert\. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y)\. . .IP "\(bu" 4 \fIDefault\fR: 2m . .IP "" 0 . .SS "yamldir" The directory in which YAML data is stored, usually in a subdirectory\. . .IP "\(bu" 4 \fIDefault\fR: $vardir/yaml . .IP "" 0 . .P \fIThis page autogenerated on 2014\-12\-05 17:21:41 \-0800\fR diff --git a/spec/unit/indirector/catalog/static_compiler_spec.rb b/spec/unit/indirector/catalog/static_compiler_spec.rb index 823963d84..d08f3402c 100644 --- a/spec/unit/indirector/catalog/static_compiler_spec.rb +++ b/spec/unit/indirector/catalog/static_compiler_spec.rb @@ -1,237 +1,237 @@ #! /usr/bin/env ruby require 'spec_helper' require 'puppet/indirector/catalog/static_compiler' require 'puppet/file_serving/metadata' require 'puppet/file_serving/content' require 'yaml' describe Puppet::Resource::Catalog::StaticCompiler do before :all do @num_file_resources = 10 end before :each do Facter.stubs(:loadfacts) Facter.stubs(:to_hash).returns({}) Facter.stubs(:value) end around(:each) do |example| Puppet.override({ :current_environment => Puppet::Node::Environment.create(:app, []), }, "Ensure we are using an environment other than root" ) do example.run end end let(:request) do Puppet::Indirector::Request.new(:the_indirection_named_foo, :find, "the-node-named-foo", :environment => "production") end describe "#find" do it "returns a catalog" do expect(subject.find(request)).to be_a_kind_of(Puppet::Resource::Catalog) end it "returns nil if there is no compiled catalog" do subject.expects(:compile).returns(nil) expect(subject.find(request)).to be_nil end describe "a catalog with file resources containing source parameters with puppet:// URIs" do it "filters file resource source URI's to checksums" do stub_the_compiler resource_catalog = subject.find(request) resource_catalog.resources.each do |resource| next unless resource.type == "File" expect(resource[:content]).to eq("{md5}361fadf1c712e812d198c4cab5712a79") expect(resource[:source]).to be_nil end end it "does not modify file resources with non-puppet:// URI's" do uri = "/this/is/not/a/puppet/uri.txt" stub_the_compiler(:source => uri) resource_catalog = subject.find(request) resource_catalog.resources.each do |resource| next unless resource.type == "File" expect(resource[:content]).to be_nil expect(resource[:source]).to eq(uri) end end it "copies the owner, group and mode from the fileserer" do stub_the_compiler resource_catalog = subject.find(request) resource_catalog.resources.each do |resource| next unless resource.type == "File" expect(resource[:owner]).to eq(0) expect(resource[:group]).to eq(0) expect(resource[:mode]).to eq(420) end end end end describe "(#15193) when storing content to the filebucket" do it "explicitly uses the indirection method" do # We expect the content to be retrieved from the FileServer ... fake_content = mock('FileServer Content') fake_content.expects(:content).returns("HELLO WORLD") # Mock the FileBucket to behave as if the file content does not exist. # NOTE, we're simulating the first call returning false, indicating the # file is not present, then all subsequent calls returning true. This # mocked behavior is intended to replicate the real behavior of the same # file being stored to the filebucket multiple times. Puppet::FileBucket::File.indirection. expects(:find).times(@num_file_resources). returns(false).then.returns(true) Puppet::FileServing::Content.indirection. expects(:find).once. returns(fake_content) # Once retrived from the FileServer, we expect the file to be stored into # the FileBucket only once. All of the file resources in the fake # catalog have the same content. Puppet::FileBucket::File.indirection.expects(:save).once.with do |file| file.contents == "HELLO WORLD" end # Obtain the Static Catalog subject.stubs(:compile).returns(build_catalog) resource_catalog = subject.find(request) # Ensure all of the file resources were filtered resource_catalog.resources.each do |resource| next unless resource.type == "File" expect(resource[:content]).to eq("{md5}361fadf1c712e812d198c4cab5712a79") expect(resource[:source]).to be_nil end end end # Spec helper methods def stub_the_compiler(options = {:stub_methods => [:store_content]}) # Build a resource catalog suitable for specifying the behavior of the # static compiler. compiler = mock('indirection terminus compiler') compiler.stubs(:find).returns(build_catalog(options)) subject.stubs(:compiler).returns(compiler) # Mock the store content method to prevent copying the contents to the # file bucket. (options[:stub_methods] || []).each do |mthd| subject.stubs(mthd) end end def build_catalog(options = {}) options = options.dup options[:source] ||= 'puppet:///modules/mymodule/config_file.txt' options[:request] ||= request # Build a catalog suitable for the static compiler to operate on environment = Puppet::Node::Environment.remote(:testing) catalog = Puppet::Resource::Catalog.new("#{options[:request].key}", environment) # Mock out the fileserver, otherwise converting the catalog to a fake_fileserver_metadata = fileserver_metadata(options) # Stub the call to the FileServer metadata API so we don't have to have # a real fileserver initialized for testing. Puppet::FileServing::Metadata. indirection.stubs(:find).with do |uri, opts| expect(uri).to eq options[:source].sub('puppet:///','') expect(opts[:links]).to eq :manage expect(opts[:environment]).to eq environment end.returns(fake_fileserver_metadata) # I want a resource that all the file resources require and another # that requires them. resources = Array.new resources << Puppet::Resource.new("notify", "alpha") resources << Puppet::Resource.new("notify", "omega") # Create some File resources with source parameters. 1.upto(@num_file_resources) do |idx| parameters = { :ensure => 'file', :source => options[:source], :require => "Notify[alpha]", :before => "Notify[omega]" } # The static compiler does not operate on a RAL catalog, so we're # using Puppet::Resource to produce a resource catalog. agnostic_path = File.expand_path("/tmp/file_#{idx}.txt") # Windows Friendly rsrc = Puppet::Resource.new("file", agnostic_path, :parameters => parameters) rsrc.file = 'site.pp' rsrc.line = idx resources << rsrc end resources.each do |rsrc| catalog.add_resource(rsrc) end # Return the resource catalog catalog end describe "(#22744) when filtering resources" do let(:catalog) { stub_everything 'catalog' } it "should delegate to the catalog instance filtering" do catalog.expects(:filter) subject.filter(catalog) end it "should filter out virtual resources" do resource = mock 'resource', :virtual? => true catalog.stubs(:filter).yields(resource) subject.filter(catalog) end it "should return the same catalog if it doesn't support filtering" do catalog.stubs(:respond_to?).with(:filter) expect(subject.filter(catalog)).to eq(catalog) end it "should return the filtered catalog" do filtered_catalog = stub 'filtered catalog' catalog.stubs(:filter).returns(filtered_catalog) expect(subject.filter(catalog)).to eq(filtered_catalog) end end def fileserver_metadata(options = {}) yaml = < Puppet.features.microsoft_windows? do before do @run_mode = Puppet::Util::UnixRunMode.new('fake') end describe "#conf_dir" do - describe "when run as root" do - it "has confdir /etc/puppetlabs/agent" do - as_root { expect(@run_mode.conf_dir).to eq(File.expand_path('/etc/puppetlabs/agent')) } - end + it "has confdir /etc/puppet when run as root" do + as_root { expect(@run_mode.conf_dir).to eq(File.expand_path('/etc/puppet')) } end - describe "when run as non-root" do - it "has confdir ~/.puppet" do - as_non_root { expect(@run_mode.conf_dir).to eq(File.expand_path('~/.puppet')) } - end - - it "fails when asking for the conf_dir as non-root and there is no $HOME" do - as_non_root do - without_home do - expect { @run_mode.conf_dir }.to raise_error ArgumentError, /couldn't find HOME/ - end - end - end + it "has confdir ~/.puppet when run as non-root" do + as_non_root { expect(@run_mode.conf_dir).to eq(File.expand_path('~/.puppet')) } end context "master run mode" do before do @run_mode = Puppet::Util::UnixRunMode.new('master') end it "has confdir ~/.puppet when run as non-root and master run mode (#16337)" do as_non_root { expect(@run_mode.conf_dir).to eq(File.expand_path('~/.puppet')) } end end - end - - describe "#var_dir" do - before :each do - Puppet[:vardir] = nil - end - describe "when run as root" do - it "has vardir /opt/puppetlabs/agent/cache" do - as_root { expect(@run_mode.var_dir).to eq(File.expand_path('/opt/puppetlabs/agent/cache')) } - end - end - - describe "when run as non-root" do - it "has default vardir ~/.puppet/var" do - as_non_root { expect(@run_mode.var_dir).to eq(File.expand_path('~/.puppet/var')) } - end - - it "has user defined vardir when vardir specified via the commandline" do - Puppet[:vardir] = "~/.myvar/puppet" - as_non_root { expect(@run_mode.var_dir).to eq(File.expand_path('~/.myvar/puppet')) } - end - - it "fails when asking for the var_dir and there is no $HOME" do - as_non_root do - without_home do - expect { @run_mode.var_dir }.to raise_error ArgumentError, /couldn't find HOME/ - end + it "fails when asking for the conf_dir as non-root and there is no $HOME" do + as_non_root do + without_home do + expect { @run_mode.conf_dir }.to raise_error ArgumentError, /couldn't find HOME/ end end end end - describe "#run_dir" do - before :each do - Puppet[:vardir] = nil - end - - describe "when run as root" do - it "has rundir /var/run/puppetlabs" do - as_root { expect(@run_mode.run_dir).to eq(File.expand_path('/var/run/puppetlabs')) } - end - end - - describe "when run as non-root" do - it "has default rundir ~/.puppet/var/run" do - as_non_root { expect(@run_mode.run_dir).to eq(File.expand_path('~/.puppet/var/run')) } - end - - it "has rundir based on vardir when vardir is passed via commandline" do - Puppet[:vardir] = "~/.myvar/puppet" - as_non_root { expect(@run_mode.run_dir).to eq(File.expand_path('~/.myvar/puppet/run')) } - end - - it "fails when asking for the run_dir and there is no $HOME" do - as_non_root do - without_home do - expect { @run_mode.run_dir }.to raise_error ArgumentError, /couldn't find HOME/ - end - end - end - end - end - - describe "#log_dir" do - before :each do - Puppet[:vardir] = nil + describe "#var_dir" do + it "has vardir /var/lib/puppet when run as root" do + as_root { expect(@run_mode.var_dir).to eq(File.expand_path('/var/lib/puppet')) } end - describe "when run as root" do - it "has logdir /var/log/puppetlabs/agent" do - as_root { expect(@run_mode.log_dir).to eq(File.expand_path('/var/log/puppetlabs/agent')) } - end + it "has vardir ~/.puppet/var when run as non-root" do + as_non_root { expect(@run_mode.var_dir).to eq(File.expand_path('~/.puppet/var')) } end - describe "when run as non-root" do - it "has default logdir ~/.puppet/var/log" do - as_non_root { expect(@run_mode.log_dir).to eq(File.expand_path('~/.puppet/var/log')) } - end - - it "has logdir based on vardir when vardir is passed via commandline" do - Puppet[:vardir] = "~/.myvar/puppet" - as_non_root { expect(@run_mode.log_dir).to eq(File.expand_path('~/.myvar/puppet/log')) } - end - - it "fails when asking for the log_dir and there is no $HOME" do - as_non_root do - without_home do - expect { @run_mode.log_dir }.to raise_error ArgumentError, /couldn't find HOME/ - end + it "fails when asking for the var_dir as non-root and there is no $HOME" do + as_non_root do + without_home do + expect { @run_mode.var_dir }.to raise_error ArgumentError, /couldn't find HOME/ end end end end end describe Puppet::Util::WindowsRunMode, :if => Puppet.features.microsoft_windows? do before do if not Dir.const_defined? :COMMON_APPDATA Dir.const_set :COMMON_APPDATA, "/CommonFakeBase" @remove_const = true end @run_mode = Puppet::Util::WindowsRunMode.new('fake') end after do if @remove_const Dir.send :remove_const, :COMMON_APPDATA end end describe "#conf_dir" do - describe "when run as root" do - it "has confdir /etc/puppet" do - as_root { expect(@run_mode.conf_dir).to eq(File.expand_path(File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc"))) } - end + it "has confdir /etc/puppet when run as root" do + as_root { expect(@run_mode.conf_dir).to eq(File.expand_path(File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc"))) } end - describe "when run as non-root" do - it "has confdir in ~/.puppet" do - as_non_root { expect(@run_mode.conf_dir).to eq(File.expand_path("~/.puppet")) } - end + it "has confdir in ~/.puppet when run as non-root" do + as_non_root { expect(@run_mode.conf_dir).to eq(File.expand_path("~/.puppet")) } + end - it "fails when asking for the conf_dir and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%" do - as_non_root do - without_env('HOME') do - without_env('HOMEDRIVE') do - without_env('USERPROFILE') do - expect { @run_mode.conf_dir }.to raise_error ArgumentError, /couldn't find HOME/ - end + it "fails when asking for the conf_dir as non-root and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%" do + as_non_root do + without_env('HOME') do + without_env('HOMEDRIVE') do + without_env('USERPROFILE') do + expect { @run_mode.conf_dir }.to raise_error ArgumentError, /couldn't find HOME/ end end end end end end describe "#var_dir" do - describe "when run as root" do - it "has vardir /var/lib/puppet" do - as_root { expect(@run_mode.var_dir).to eq(File.expand_path(File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var"))) } - end + it "has vardir /var/lib/puppet when run as root" do + as_root { expect(@run_mode.var_dir).to eq(File.expand_path(File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var"))) } end - describe "when run as non-root" do - it "has vardir in ~/.puppet/var" do - as_non_root { expect(@run_mode.var_dir).to eq(File.expand_path("~/.puppet/var")) } - end + it "has vardir in ~/.puppet/var when run as non-root" do + as_non_root { expect(@run_mode.var_dir).to eq(File.expand_path("~/.puppet/var")) } + end - it "fails when asking for the conf_dir and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%" do - as_non_root do - without_env('HOME') do - without_env('HOMEDRIVE') do - without_env('USERPROFILE') do - expect { @run_mode.var_dir }.to raise_error ArgumentError, /couldn't find HOME/ - end + it "fails when asking for the conf_dir as non-root and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%" do + as_non_root do + without_env('HOME') do + without_env('HOMEDRIVE') do + without_env('USERPROFILE') do + expect { @run_mode.var_dir }.to raise_error ArgumentError, /couldn't find HOME/ end end end end end end end def as_root Puppet.features.stubs(:root?).returns(true) yield end def as_non_root Puppet.features.stubs(:root?).returns(false) yield end def without_env(name, &block) saved = ENV[name] ENV.delete name yield ensure ENV[name] = saved end def without_home(&block) without_env('HOME', &block) end end diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb index e11b233cb..625c947c7 100755 --- a/spec/unit/util/selinux_spec.rb +++ b/spec/unit/util/selinux_spec.rb @@ -1,311 +1,311 @@ #! /usr/bin/env ruby require 'spec_helper' require 'pathname' require 'puppet/util/selinux' include Puppet::Util::SELinux unless defined?(Selinux) module Selinux def self.is_selinux_enabled false end end end describe Puppet::Util::SELinux do describe "selinux_support?" do before do end it "should return :true if this system has SELinux enabled" do Selinux.expects(:is_selinux_enabled).returns 1 expect(selinux_support?).to be_truthy end it "should return :false if this system lacks SELinux" do Selinux.expects(:is_selinux_enabled).returns 0 expect(selinux_support?).to be_falsey end it "should return nil if /proc/mounts does not exist" do File.stubs(:open).with("/proc/mounts").raises("No such file or directory - /proc/mounts") expect(read_mounts).to eq(nil) end end describe "read_mounts" do before :each do fh = stub 'fh', :close => nil File.stubs(:open).with("/proc/mounts").returns fh fh.expects(:read_nonblock).times(2).returns("rootfs / rootfs rw 0 0\n/dev/root / ext3 rw,relatime,errors=continue,user_xattr,acl,data=ordered 0 0\n/dev /dev tmpfs rw,relatime,mode=755 0 0\n/proc /proc proc rw,relatime 0 0\n/sys /sys sysfs rw,relatime 0 0\n192.168.1.1:/var/export /mnt/nfs nfs rw,relatime,vers=3,rsize=32768,wsize=32768,namlen=255,hard,nointr,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.1.1,mountvers=3,mountproto=udp,addr=192.168.1.1 0 0\n").then.raises EOFError end it "should parse the contents of /proc/mounts" do expect(read_mounts).to eq({ '/' => 'ext3', '/sys' => 'sysfs', '/mnt/nfs' => 'nfs', '/proc' => 'proc', '/dev' => 'tmpfs' }) end end describe "filesystem detection" do before :each do self.stubs(:read_mounts).returns({ '/' => 'ext3', '/sys' => 'sysfs', '/mnt/nfs' => 'nfs', '/proc' => 'proc', '/dev' => 'tmpfs' }) end it "should match a path on / to ext3" do - expect(find_fs('/etc/puppetlabs/testfile')).to eq("ext3") + expect(find_fs('/etc/puppet/testfile')).to eq("ext3") end it "should match a path on /mnt/nfs to nfs" do expect(find_fs('/mnt/nfs/testfile/foobar')).to eq("nfs") end it "should return true for a capable filesystem" do - expect(selinux_label_support?('/etc/puppetlabs/testfile')).to be_truthy + expect(selinux_label_support?('/etc/puppet/testfile')).to be_truthy end it "should return false for a noncapable filesystem" do expect(selinux_label_support?('/mnt/nfs/testfile')).to be_falsey end it "(#8714) don't follow symlinks when determining file systems", :unless => Puppet.features.microsoft_windows? do scratch = Pathname(PuppetSpec::Files.tmpdir('selinux')) self.stubs(:read_mounts).returns({ '/' => 'ext3', scratch + 'nfs' => 'nfs', }) (scratch + 'foo').make_symlink('nfs/bar') expect(selinux_label_support?(scratch + 'foo')).to be_truthy end it "should handle files that don't exist" do scratch = Pathname(PuppetSpec::Files.tmpdir('selinux')) expect(selinux_label_support?(scratch + 'nonesuch')).to be_truthy end end describe "get_selinux_current_context" do it "should return nil if no SELinux support" do self.expects(:selinux_support?).returns false expect(get_selinux_current_context("/foo")).to be_nil end it "should return a context" do self.expects(:selinux_support?).returns true Selinux.expects(:lgetfilecon).with("/foo").returns [0, "user_u:role_r:type_t:s0"] expect(get_selinux_current_context("/foo")).to eq("user_u:role_r:type_t:s0") end it "should return nil if lgetfilecon fails" do self.expects(:selinux_support?).returns true Selinux.expects(:lgetfilecon).with("/foo").returns -1 expect(get_selinux_current_context("/foo")).to be_nil end end describe "get_selinux_default_context" do it "should return nil if no SELinux support" do self.expects(:selinux_support?).returns false expect(get_selinux_default_context("/foo")).to be_nil end it "should return a context if a default context exists" do self.expects(:selinux_support?).returns true fstat = stub 'File::Stat', :mode => 0 Puppet::FileSystem.expects(:lstat).with('/foo').returns(fstat) self.expects(:find_fs).with("/foo").returns "ext3" Selinux.expects(:matchpathcon).with("/foo", 0).returns [0, "user_u:role_r:type_t:s0"] expect(get_selinux_default_context("/foo")).to eq("user_u:role_r:type_t:s0") end it "handles permission denied errors by issuing a warning" do self.stubs(:selinux_support?).returns true self.stubs(:selinux_label_support?).returns true Selinux.stubs(:matchpathcon).with("/root/chuj", 0).returns(-1) self.stubs(:file_lstat).with("/root/chuj").raises(Errno::EACCES, "/root/chuj") expect(get_selinux_default_context("/root/chuj")).to be_nil end it "handles no such file or directory errors by issuing a warning" do self.stubs(:selinux_support?).returns true self.stubs(:selinux_label_support?).returns true Selinux.stubs(:matchpathcon).with("/root/chuj", 0).returns(-1) self.stubs(:file_lstat).with("/root/chuj").raises(Errno::ENOENT, "/root/chuj") expect(get_selinux_default_context("/root/chuj")).to be_nil end it "should return nil if matchpathcon returns failure" do self.expects(:selinux_support?).returns true fstat = stub 'File::Stat', :mode => 0 Puppet::FileSystem.expects(:lstat).with('/foo').returns(fstat) self.expects(:find_fs).with("/foo").returns "ext3" Selinux.expects(:matchpathcon).with("/foo", 0).returns -1 expect(get_selinux_default_context("/foo")).to be_nil end it "should return nil if selinux_label_support returns false" do self.expects(:selinux_support?).returns true self.expects(:find_fs).with("/foo").returns "nfs" expect(get_selinux_default_context("/foo")).to be_nil end end describe "parse_selinux_context" do it "should return nil if no context is passed" do expect(parse_selinux_context(:seluser, nil)).to be_nil end it "should return nil if the context is 'unlabeled'" do expect(parse_selinux_context(:seluser, "unlabeled")).to be_nil end it "should return the user type when called with :seluser" do expect(parse_selinux_context(:seluser, "user_u:role_r:type_t:s0")).to eq("user_u") expect(parse_selinux_context(:seluser, "user-withdash_u:role_r:type_t:s0")).to eq("user-withdash_u") end it "should return the role type when called with :selrole" do expect(parse_selinux_context(:selrole, "user_u:role_r:type_t:s0")).to eq("role_r") expect(parse_selinux_context(:selrole, "user_u:role-withdash_r:type_t:s0")).to eq("role-withdash_r") end it "should return the type type when called with :seltype" do expect(parse_selinux_context(:seltype, "user_u:role_r:type_t:s0")).to eq("type_t") expect(parse_selinux_context(:seltype, "user_u:role_r:type-withdash_t:s0")).to eq("type-withdash_t") end describe "with spaces in the components" do it "should raise when user contains a space" do expect{parse_selinux_context(:seluser, "user with space_u:role_r:type_t:s0")}.to raise_error Puppet::Error end it "should raise when role contains a space" do expect{parse_selinux_context(:selrole, "user_u:role with space_r:type_t:s0")}.to raise_error Puppet::Error end it "should raise when type contains a space" do expect{parse_selinux_context(:seltype, "user_u:role_r:type with space_t:s0")}.to raise_error Puppet::Error end it "should return the range when range contains a space" do expect(parse_selinux_context(:selrange, "user_u:role_r:type_t:s0 s1")).to eq("s0 s1") end end it "should return nil for :selrange when no range is returned" do expect(parse_selinux_context(:selrange, "user_u:role_r:type_t")).to be_nil end it "should return the range type when called with :selrange" do expect(parse_selinux_context(:selrange, "user_u:role_r:type_t:s0")).to eq("s0") expect(parse_selinux_context(:selrange, "user_u:role_r:type-withdash_t:s0")).to eq("s0") end describe "with a variety of SELinux range formats" do ['s0', 's0:c3', 's0:c3.c123', 's0:c3,c5,c8', 'TopSecret', 'TopSecret,Classified', 'Patient_Record'].each do |range| it "should parse range '#{range}'" do expect(parse_selinux_context(:selrange, "user_u:role_r:type_t:#{range}")).to eq(range) end end end end describe "set_selinux_context" do before :each do fh = stub 'fh', :close => nil File.stubs(:open).with("/proc/mounts").returns fh fh.stubs(:read_nonblock).returns( "rootfs / rootfs rw 0 0\n/dev/root / ext3 rw,relatime,errors=continue,user_xattr,acl,data=ordered 0 0\n"+ "/dev /dev tmpfs rw,relatime,mode=755 0 0\n/proc /proc proc rw,relatime 0 0\n"+ "/sys /sys sysfs rw,relatime 0 0\n" ).then.raises EOFError end it "should return nil if there is no SELinux support" do self.expects(:selinux_support?).returns false expect(set_selinux_context("/foo", "user_u:role_r:type_t:s0")).to be_nil end it "should return nil if selinux_label_support returns false" do self.expects(:selinux_support?).returns true self.expects(:selinux_label_support?).with("/foo").returns false expect(set_selinux_context("/foo", "user_u:role_r:type_t:s0")).to be_nil end it "should use lsetfilecon to set a context" do self.expects(:selinux_support?).returns true Selinux.expects(:lsetfilecon).with("/foo", "user_u:role_r:type_t:s0").returns 0 expect(set_selinux_context("/foo", "user_u:role_r:type_t:s0")).to be_truthy end it "should use lsetfilecon to set user_u user context" do self.expects(:selinux_support?).returns true Selinux.expects(:lgetfilecon).with("/foo").returns [0, "foo:role_r:type_t:s0"] Selinux.expects(:lsetfilecon).with("/foo", "user_u:role_r:type_t:s0").returns 0 expect(set_selinux_context("/foo", "user_u", :seluser)).to be_truthy end it "should use lsetfilecon to set role_r role context" do self.expects(:selinux_support?).returns true Selinux.expects(:lgetfilecon).with("/foo").returns [0, "user_u:foo:type_t:s0"] Selinux.expects(:lsetfilecon).with("/foo", "user_u:role_r:type_t:s0").returns 0 expect(set_selinux_context("/foo", "role_r", :selrole)).to be_truthy end it "should use lsetfilecon to set type_t type context" do self.expects(:selinux_support?).returns true Selinux.expects(:lgetfilecon).with("/foo").returns [0, "user_u:role_r:foo:s0"] Selinux.expects(:lsetfilecon).with("/foo", "user_u:role_r:type_t:s0").returns 0 expect(set_selinux_context("/foo", "type_t", :seltype)).to be_truthy end it "should use lsetfilecon to set s0:c3,c5 range context" do self.expects(:selinux_support?).returns true Selinux.expects(:lgetfilecon).with("/foo").returns [0, "user_u:role_r:type_t:s0"] Selinux.expects(:lsetfilecon).with("/foo", "user_u:role_r:type_t:s0:c3,c5").returns 0 expect(set_selinux_context("/foo", "s0:c3,c5", :selrange)).to be_truthy end end describe "set_selinux_default_context" do it "should return nil if there is no SELinux support" do self.expects(:selinux_support?).returns false expect(set_selinux_default_context("/foo")).to be_nil end it "should return nil if no default context exists" do self.expects(:get_selinux_default_context).with("/foo").returns nil expect(set_selinux_default_context("/foo")).to be_nil end it "should do nothing and return nil if the current context matches the default context" do self.expects(:get_selinux_default_context).with("/foo").returns "user_u:role_r:type_t" self.expects(:get_selinux_current_context).with("/foo").returns "user_u:role_r:type_t" expect(set_selinux_default_context("/foo")).to be_nil end it "should set and return the default context if current and default do not match" do self.expects(:get_selinux_default_context).with("/foo").returns "user_u:role_r:type_t" self.expects(:get_selinux_current_context).with("/foo").returns "olduser_u:role_r:type_t" self.expects(:set_selinux_context).with("/foo", "user_u:role_r:type_t").returns true expect(set_selinux_default_context("/foo")).to eq("user_u:role_r:type_t") end end end