diff options
Diffstat (limited to 'lib/puppet')
37 files changed, 91 insertions, 162 deletions
diff --git a/lib/puppet/feature/base.rb b/lib/puppet/feature/base.rb index b1988278e..cecc1b9ad 100644 --- a/lib/puppet/feature/base.rb +++ b/lib/puppet/feature/base.rb @@ -1,10 +1,35 @@ -# Created by Luke Kanies on 2006-04-30. -# Copyright (c) 2006. All rights reserved. - require 'puppet/util/feature' # Add the simple features, all in one file. +# Order is important as some features depend on others + +# We have a syslog implementation +Puppet.features.add(:syslog, :libs => ["syslog"]) + +# We can use POSIX user functions +Puppet.features.add(:posix) do + require 'etc' + Etc.getpwuid(0) != nil && Puppet.features.syslog? +end + +# We can use Microsoft Windows functions +Puppet.features.add(:microsoft_windows) do + begin + require 'sys/admin' + require 'win32/process' + require 'win32/dir' + require 'win32/service' + require 'win32ole' + require 'win32/api' + true + rescue LoadError => err + warn "Cannot run on Microsoft Windows without the sys-admin, win32-process, win32-dir & win32-service gems: #{err}" unless Puppet.features.posix? + end +end + +raise Puppet::Error,"Cannot determine basic system flavour" unless Puppet.features.posix? or Puppet.features.microsoft_windows? + # We've got LDAP available. Puppet.features.add(:ldap, :libs => ["ldap"]) @@ -33,32 +58,6 @@ Puppet.features.add(:rrd, :libs => ["RRD"]) # We have OpenSSL Puppet.features.add(:openssl, :libs => ["openssl"]) -# We have a syslog implementation -Puppet.features.add(:syslog, :libs => ["syslog"]) - -# We can use POSIX user functions -Puppet.features.add(:posix) do - require 'etc' - Etc.getpwuid(0) != nil && Puppet.features.syslog? -end - -# We can use Microsoft Windows functions -Puppet.features.add(:microsoft_windows) do - begin - require 'sys/admin' - require 'win32/process' - require 'win32/dir' - require 'win32/service' - require 'win32ole' - require 'win32/api' - true - rescue LoadError => err - warn "Cannot run on Microsoft Windows without the sys-admin, win32-process, win32-dir & win32-service gems: #{err}" unless Puppet.features.posix? - end -end - -raise Puppet::Error,"Cannot determine basic system flavour" unless Puppet.features.posix? or Puppet.features.microsoft_windows? - # We have CouchDB Puppet.features.add(:couchdb, :libs => ["couchrest"]) diff --git a/lib/puppet/feature/rails.rb b/lib/puppet/feature/rails.rb index 74ed09aa6..fe5cb0f8a 100644 --- a/lib/puppet/feature/rails.rb +++ b/lib/puppet/feature/rails.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-07. -# Copyright (c) 2006. All rights reserved. - require 'puppet/util/feature' Puppet.features.rubygems? diff --git a/lib/puppet/feature/rubygems.rb b/lib/puppet/feature/rubygems.rb index 639524ffe..7cfbbc6d3 100644 --- a/lib/puppet/feature/rubygems.rb +++ b/lib/puppet/feature/rubygems.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-07. -# Copyright (c) 2006. All rights reserved. - require 'puppet/util/feature' Puppet.features.add(:rubygems, :libs => "rubygems") diff --git a/lib/puppet/file_serving.rb b/lib/puppet/file_serving.rb index e7e2b898e..0adbac9cf 100644 --- a/lib/puppet/file_serving.rb +++ b/lib/puppet/file_serving.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - # Just a stub class. class Puppet::FileServing # :nodoc: end diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index 706f67af9..e936b5e75 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-22. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving' # The base class for Content and Metadata; provides common diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index d88d57cb0..02bca1bea 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'monitor' require 'puppet' require 'puppet/file_serving' diff --git a/lib/puppet/file_serving/content.rb b/lib/puppet/file_serving/content.rb index 9cfae7ded..25361c668 100644 --- a/lib/puppet/file_serving/content.rb +++ b/lib/puppet/file_serving/content.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet/indirector' require 'puppet/file_serving' require 'puppet/file_serving/base' diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index b4f1457df..8bc5e256d 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-22. -# Copyright (c) 2007. All rights reserved. - require 'find' require 'puppet/file_serving' require 'puppet/file_serving/metadata' diff --git a/lib/puppet/file_serving/indirection_hooks.rb b/lib/puppet/file_serving/indirection_hooks.rb index 2a0dc1792..bdcc8865e 100644 --- a/lib/puppet/file_serving/indirection_hooks.rb +++ b/lib/puppet/file_serving/indirection_hooks.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'uri' require 'puppet/file_serving' diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 6656b124a..382ac9c96 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet' require 'puppet/indirector' require 'puppet/file_serving' diff --git a/lib/puppet/file_serving/mount.rb b/lib/puppet/file_serving/mount.rb index 79290ab81..da7102fd8 100644 --- a/lib/puppet/file_serving/mount.rb +++ b/lib/puppet/file_serving/mount.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet/network/authstore' require 'puppet/util/logging' require 'puppet/file_serving' diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb index 4da285258..b36ec55f8 100644 --- a/lib/puppet/file_serving/terminus_helper.rb +++ b/lib/puppet/file_serving/terminus_helper.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-22. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving' require 'puppet/file_serving/fileset' diff --git a/lib/puppet/indirector/direct_file_server.rb b/lib/puppet/indirector/direct_file_server.rb index 80c84eab5..62234e360 100644 --- a/lib/puppet/indirector/direct_file_server.rb +++ b/lib/puppet/indirector/direct_file_server.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-24. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/terminus_helper' require 'puppet/indirector/terminus' diff --git a/lib/puppet/indirector/file_content/file.rb b/lib/puppet/indirector/file_content/file.rb index 75fc9981c..0bb7106d5 100644 --- a/lib/puppet/indirector/file_content/file.rb +++ b/lib/puppet/indirector/file_content/file.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/content' require 'puppet/indirector/file_content' require 'puppet/indirector/direct_file_server' diff --git a/lib/puppet/indirector/file_content/file_server.rb b/lib/puppet/indirector/file_content/file_server.rb index 21cfe7324..741c70458 100644 --- a/lib/puppet/indirector/file_content/file_server.rb +++ b/lib/puppet/indirector/file_content/file_server.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/content' require 'puppet/indirector/file_content' require 'puppet/indirector/file_server' diff --git a/lib/puppet/indirector/file_content/rest.rb b/lib/puppet/indirector/file_content/rest.rb index 2fd39b7e5..59975d3ec 100644 --- a/lib/puppet/indirector/file_content/rest.rb +++ b/lib/puppet/indirector/file_content/rest.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/content' require 'puppet/indirector/file_content' require 'puppet/indirector/rest' diff --git a/lib/puppet/indirector/file_metadata/file.rb b/lib/puppet/indirector/file_metadata/file.rb index 4d6b0b335..9d8f839b3 100644 --- a/lib/puppet/indirector/file_metadata/file.rb +++ b/lib/puppet/indirector/file_metadata/file.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-16. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/metadata' require 'puppet/indirector/file_metadata' require 'puppet/indirector/direct_file_server' diff --git a/lib/puppet/indirector/file_metadata/file_server.rb b/lib/puppet/indirector/file_metadata/file_server.rb index cef81f0a5..d3622990a 100644 --- a/lib/puppet/indirector/file_metadata/file_server.rb +++ b/lib/puppet/indirector/file_metadata/file_server.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/metadata' require 'puppet/indirector/file_metadata' require 'puppet/indirector/file_server' diff --git a/lib/puppet/indirector/file_metadata/rest.rb b/lib/puppet/indirector/file_metadata/rest.rb index 023edb8ff..31de2698b 100644 --- a/lib/puppet/indirector/file_metadata/rest.rb +++ b/lib/puppet/indirector/file_metadata/rest.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-18. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/metadata' require 'puppet/indirector/file_metadata' require 'puppet/indirector/rest' diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb index d6a8ab872..9516a404c 100644 --- a/lib/puppet/indirector/file_server.rb +++ b/lib/puppet/indirector/file_server.rb @@ -1,7 +1,3 @@ -# -# Created by Luke Kanies on 2007-10-19. -# Copyright (c) 2007. All rights reserved. - require 'puppet/file_serving/configuration' require 'puppet/file_serving/fileset' require 'puppet/file_serving/terminus_helper' diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 06cd80a1e..a7bce69e2 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -1,6 +1,3 @@ -# Created by Luke A. Kanies on 2007-08-13. -# Copyright (c) 2007. All rights reserved. - require 'puppet/node' require 'puppet/resource/catalog' require 'puppet/util/errors' diff --git a/lib/puppet/parser/functions/create_resources.rb b/lib/puppet/parser/functions/create_resources.rb index 3b8bb3543..646761957 100644 --- a/lib/puppet/parser/functions/create_resources.rb +++ b/lib/puppet/parser/functions/create_resources.rb @@ -1,12 +1,24 @@ -Puppet::Parser::Functions::newfunction(:create_resources, :doc => ' -Converts a hash into a set of resources and adds them to the catalog. -Takes two parameters: - create_resource($type, $resources) - Creates resources of type $type from the $resources hash. Assumes that - hash is in the following form: - {title=>{parameters}} - This is currently tested for defined resources, classes, as well as native types -') do |args| +Puppet::Parser::Functions::newfunction(:create_resources, :doc => <<-'ENDHEREDOC') do |args| + Converts a hash into a set of resources and adds them to the catalog. + + This function takes two arguments: a resource type, and a hash describing + a set of resources. The hash should be in the form `{title => {parameters} }`: + + # A hash of user resources: + $myusers = { + 'nick' => { uid => '1330', + group => allstaff, + groups => ['developers', 'operations', 'release'], } + 'dan' => { uid => '1308', + group => allstaff, + groups => ['developers', 'prosvc', 'release'], } + } + + create_resource(user, $myusers) + + This function can be used to create defined resources and classes, as well + as native resources. + ENDHEREDOC raise ArgumentError, ("create_resources(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2 #raise ArgumentError, 'requires resource type and param hash' if args.size < 2 # figure out what kind of resource we are @@ -19,7 +31,7 @@ Takes two parameters: type_of_resource = :type elsif resource = find_definition(type_name.downcase) type_of_resource = :define - else + else raise ArgumentError, "could not create resource of unknown type #{type_name}" end end diff --git a/lib/puppet/provider/mount.rb b/lib/puppet/provider/mount.rb index 65296eed2..e2aba8076 100644 --- a/lib/puppet/provider/mount.rb +++ b/lib/puppet/provider/mount.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-12. -# Copyright (c) 2006. All rights reserved. - require 'puppet' # A module just to store the mount/unmount methods. Individual providers diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb index 17cc24086..c84f75c98 100644 --- a/lib/puppet/provider/naginator.rb +++ b/lib/puppet/provider/naginator.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2007-11-27. -# Copyright (c) 2007. All rights reserved. - require 'puppet' require 'puppet/provider/parsedfile' require 'puppet/external/nagios' diff --git a/lib/puppet/provider/package.rb b/lib/puppet/provider/package.rb index 2f5f67547..f5bfa1216 100644 --- a/lib/puppet/provider/package.rb +++ b/lib/puppet/provider/package.rb @@ -1,6 +1,3 @@ -# Created by Luke A. Kanies on 2007-06-05. -# Copyright (c) 2007. All rights reserved. - class Puppet::Provider::Package < Puppet::Provider # Prefetch our package list, yo. def self.prefetch(packages) diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb index 08d7d042b..2ffcd298f 100644..100755 --- a/lib/puppet/relationship.rb +++ b/lib/puppet/relationship.rb @@ -1,7 +1,4 @@ #!/usr/bin/env ruby -# -# Created by Luke A. Kanies on 2006-11-24. -# Copyright (c) 2006. All rights reserved. # subscriptions are permanent associations determining how different # objects react to an event diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index fc4926581..d3c66bc02 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -89,16 +89,18 @@ Puppet::Type.newtype(:file) do Puppet automatically creates a local filebucket named `puppet` and defaults to backing up there. To use a server-based filebucket, - you must specify one in your configuration + you must specify one in your configuration. filebucket { main: - server => puppet + server => puppet, + path => false, + # The path => false line works around a known issue with the filebucket type. } The `puppet master` daemon creates a filebucket by default, so you can usually back up to your main server with this configuration. Once you've described the bucket in your - configuration, you can use it in any file + configuration, you can use it in any file's backup attribute: file { \"/my/file\": source => \"/path/in/nfs/or/something\", @@ -107,12 +109,12 @@ Puppet::Type.newtype(:file) do This will back the file up to the central server. - At this point, the benefits of using a filebucket are that you do not - have backup files lying around on each of your machines, a given - version of a file is only backed up once, and you can restore - any given file manually, no matter how old. Eventually, - transactional support will be able to automatically restore - filebucketed files. + At this point, the benefits of using a central filebucket are that you + do not have backup files lying around on each of your machines, a given + version of a file is only backed up once, you can restore any given file + manually (no matter how old), and you can use Puppet Dashboard to view + file contents. Eventually, transactional support will be able to + automatically restore filebucketed files. " defaultto "puppet" diff --git a/lib/puppet/type/filebucket.rb b/lib/puppet/type/filebucket.rb index 7fd2ef46b..59174161b 100755 --- a/lib/puppet/type/filebucket.rb +++ b/lib/puppet/type/filebucket.rb @@ -11,15 +11,20 @@ module Puppet it can be specified as the value of *backup* in a **file** object. Currently, filebuckets are only useful for manual retrieval of - accidentally removed files (e.g., you look in the log for the md5 sum and retrieve the file with that sum from the filebucket), but - when transactions are fully supported filebuckets will be used to - undo transactions. + accidentally removed files (e.g., you look in the log for the md5 sum + and retrieve the file with that sum from the filebucket), but when + transactions are fully supported filebuckets will be used to undo + transactions. You will normally want to define a single filebucket for your whole network and then use that as the default backup location: # Define the bucket - filebucket { main: server => puppet } + filebucket { 'main': + server => puppet, + path => false, + # Due to a known issue, path must be set to false for remote filebuckets. + } # Specify it as the default target File { backup => main } @@ -36,7 +41,10 @@ module Puppet desc "The server providing the remote filebucket. If this is not specified then *path* is checked. If it is set, then the bucket is local. Otherwise the puppetmaster server specified - in the config or at the commandline is used." + in the config or at the commandline is used. + + Due to a known issue, you currently must set the `path` attribute to + false if you wish to specify a `server` attribute." defaultto { Puppet[:server] } end diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb index 2f704104a..5a7fbf773 100644 --- a/lib/puppet/util/feature.rb +++ b/lib/puppet/util/feature.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-07. -# Copyright (c) 2006. All rights reserved. - class Puppet::Util::Feature attr_reader :path diff --git a/lib/puppet/util/graph.rb b/lib/puppet/util/graph.rb index 9598d281e..58ca1ab4d 100644 --- a/lib/puppet/util/graph.rb +++ b/lib/puppet/util/graph.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2006-11-16. -# Copyright (c) 2006. All rights reserved. - require 'puppet' require 'puppet/simple_graph' diff --git a/lib/puppet/util/ldap.rb b/lib/puppet/util/ldap.rb index 33f01f789..71d6a178c 100644 --- a/lib/puppet/util/ldap.rb +++ b/lib/puppet/util/ldap.rb @@ -1,5 +1,2 @@ -# -# Created by Luke Kanies on 2008-3-23. -# Copyright (c) 2008. All rights reserved. module Puppet::Util::Ldap end diff --git a/lib/puppet/util/ldap/connection.rb b/lib/puppet/util/ldap/connection.rb index 03240eae9..ee39c08c9 100644 --- a/lib/puppet/util/ldap/connection.rb +++ b/lib/puppet/util/ldap/connection.rb @@ -1,6 +1,3 @@ -# -# Created by Luke Kanies on 2008-3-23. -# Copyright (c) 2008. All rights reserved. require 'puppet/util/ldap' class Puppet::Util::Ldap::Connection diff --git a/lib/puppet/util/ldap/generator.rb b/lib/puppet/util/ldap/generator.rb index 2aaa9c370..608d72974 100644 --- a/lib/puppet/util/ldap/generator.rb +++ b/lib/puppet/util/ldap/generator.rb @@ -1,6 +1,3 @@ -# -# Created by Luke Kanies on 2008-3-28. -# Copyright (c) 2008. All rights reserved. require 'puppet/util/ldap' class Puppet::Util::Ldap::Generator diff --git a/lib/puppet/util/log_paths.rb b/lib/puppet/util/log_paths.rb index 2fefd4505..c15acb663 100644 --- a/lib/puppet/util/log_paths.rb +++ b/lib/puppet/util/log_paths.rb @@ -1,6 +1,3 @@ -# Created by Luke Kanies on 2007-07-04. -# Copyright (c) 2007. All rights reserved. - module Puppet::Util::LogPaths # return the full path to us, for logging and rollback # some classes (e.g., FileTypeRecords) will have to override this diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index caaf61b7b..3039a7b0a 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -780,6 +780,7 @@ if @config.include?(:run_mode) # Create the transportable objects for users and groups. def add_user_resources(catalog, sections) return unless Puppet.features.root? + return if Puppet.features.microsoft_windows? return unless self[:mkusers] @config.each do |name, setting| diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb index 0fa65d846..f02a0c547 100644 --- a/lib/puppet/util/settings/file_setting.rb +++ b/lib/puppet/util/settings/file_setting.rb @@ -93,7 +93,8 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting if Puppet[:manage_internal_file_permissions] resource[:mode] = self.mode if self.mode - if Puppet.features.root? + # REMIND fails on Windows because chown/chgrp functionality not supported yet + if Puppet.features.root? and !Puppet.features.microsoft_windows? resource[:owner] = self.owner if self.owner resource[:group] = self.group if self.group end diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb index 697bce111..d2772002e 100644 --- a/lib/puppet/util/suidmanager.rb +++ b/lib/puppet/util/suidmanager.rb @@ -37,7 +37,20 @@ module Puppet::Util::SUIDManager module_function :groups= def self.root? - Process.uid == 0 + return Process.uid == 0 unless Puppet.features.microsoft_windows? + + require 'sys/admin' + require 'win32/security' + + # if Vista or later, check for unrestricted process token + begin + return Win32::Security.elevated_security? + rescue Win32::Security::Error => e + raise e unless e.to_s =~ /Incorrect function/i + end + + group = Sys::Admin.get_group("Administrators", :sid => Win32::Security::SID::BuiltinAdministrators) + group and group.members.index(Sys::Admin.get_login) != nil end # Runs block setting uid and gid if provided then restoring original ids |