puppet 0.24.5 → 0.24.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +206 -0
- data/Rakefile +53 -0
- data/bin/filebucket +0 -0
- data/bin/puppet +32 -11
- data/bin/puppetca +1 -0
- data/bin/puppetd +0 -0
- data/bin/puppetdoc +0 -0
- data/bin/puppetmasterd +0 -0
- data/bin/puppetrun +16 -8
- data/bin/ralsh +0 -0
- data/conf/debian/rules +0 -0
- data/conf/gentoo/init.d/puppetmaster +0 -0
- data/conf/osx/PackageInfo.plist +36 -0
- data/conf/osx/createpackage.sh +167 -0
- data/conf/osx/preflight +12 -0
- data/conf/redhat/client.init +1 -1
- data/conf/redhat/puppet.spec +34 -6
- data/conf/redhat/server.init +42 -7
- data/conf/redhat/server.sysconfig +22 -0
- data/conf/solaris/smf/svc-puppetd +0 -0
- data/conf/solaris/smf/svc-puppetmasterd +0 -0
- data/examples/etc/init.d/sleeper +0 -0
- data/examples/mac_dscl.pp +0 -0
- data/examples/mac_dscl_revert.pp +0 -0
- data/examples/mac_netinfo.pp +0 -0
- data/examples/mac_pkgdmg.pp +0 -0
- data/ext/bin/sleeper +0 -0
- data/ext/module_puppet +0 -0
- data/ext/nagios/check_puppet.rb +0 -0
- data/ext/passenger/README +63 -0
- data/ext/passenger/apache2.conf +29 -0
- data/ext/passenger/config.ru +40 -0
- data/ext/puppet-test +0 -0
- data/ext/puppetlast +6 -31
- data/ext/puppetstoredconfigclean.rb +87 -0
- data/install.rb +75 -20
- data/lib/puppet.rb +1 -1
- data/lib/puppet/daemon.rb +0 -0
- data/lib/puppet/defaults.rb +3 -7
- data/lib/puppet/external/base64.rb +0 -0
- data/lib/puppet/external/nagios.rb +0 -0
- data/lib/puppet/external/nagios/base.rb +0 -0
- data/lib/puppet/file_serving/fileset.rb +2 -2
- data/lib/puppet/file_serving/metadata.rb +3 -3
- data/lib/puppet/indirector/facts/facter.rb +3 -2
- data/lib/puppet/indirector/yaml.rb +10 -1
- data/lib/puppet/module.rb +36 -12
- data/lib/puppet/network/authstore.rb +0 -0
- data/lib/puppet/network/client/master.rb +12 -11
- data/lib/puppet/network/handler/filebucket.rb +0 -0
- data/lib/puppet/network/handler/fileserver.rb +38 -46
- data/lib/puppet/network/handler/master.rb +1 -1
- data/lib/puppet/network/handler/report.rb +0 -0
- data/lib/puppet/network/handler/resource.rb +0 -0
- data/lib/puppet/network/handler/runner.rb +0 -0
- data/lib/puppet/network/http_server/rack.rb +148 -0
- data/lib/puppet/network/rights.rb +0 -0
- data/lib/puppet/network/xmlrpc/client.rb +5 -5
- data/lib/puppet/node.rb +5 -9
- data/lib/puppet/node/environment.rb +1 -17
- data/lib/puppet/node/facts.rb +0 -0
- data/lib/puppet/parameter.rb +1 -28
- data/lib/puppet/parser/ast.rb +6 -0
- data/lib/puppet/parser/ast/arithmetic_operator.rb +41 -0
- data/lib/puppet/parser/ast/boolean_operator.rb +48 -0
- data/lib/puppet/parser/ast/collexpr.rb +6 -1
- data/lib/puppet/parser/ast/comparison_operator.rb +37 -0
- data/lib/puppet/parser/ast/minus.rb +23 -0
- data/lib/puppet/parser/ast/nop.rb +11 -0
- data/lib/puppet/parser/ast/not.rb +19 -0
- data/lib/puppet/parser/ast/resource_override.rb +23 -16
- data/lib/puppet/parser/ast/resource_reference.rb +10 -6
- data/lib/puppet/parser/ast/vardef.rb +2 -2
- data/lib/puppet/parser/collector.rb +2 -1
- data/lib/puppet/parser/functions.rb +7 -217
- data/lib/puppet/parser/functions/defined.rb +27 -0
- data/lib/puppet/parser/functions/fail.rb +4 -0
- data/lib/puppet/parser/functions/file.rb +21 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +15 -0
- data/lib/puppet/parser/functions/generate.rb +35 -0
- data/lib/puppet/parser/functions/include.rb +26 -0
- data/lib/puppet/parser/functions/realize.rb +14 -0
- data/lib/puppet/parser/functions/search.rb +7 -0
- data/lib/puppet/parser/functions/sha1.rb +6 -0
- data/lib/puppet/parser/functions/tag.rb +6 -0
- data/lib/puppet/parser/functions/tagged.rb +18 -0
- data/lib/puppet/parser/functions/template.rb +22 -0
- data/lib/puppet/parser/lexer.rb +15 -5
- data/lib/puppet/parser/parser.rb +1073 -715
- data/lib/puppet/parser/parser_support.rb +18 -13
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/parser/resource/param.rb +10 -2
- data/lib/puppet/parser/scope.rb +63 -5
- data/lib/puppet/parser/templatewrapper.rb +61 -15
- data/lib/puppet/property.rb +7 -1
- data/lib/puppet/property/keyvalue.rb +96 -0
- data/lib/puppet/property/list.rb +78 -0
- data/lib/puppet/provider/confine.rb +1 -1
- data/lib/puppet/provider/confine/variable.rb +10 -1
- data/lib/puppet/provider/cron/crontab.rb +0 -0
- data/lib/puppet/provider/mailalias/aliases.rb +0 -0
- data/lib/puppet/provider/maillist/mailman.rb +0 -0
- data/lib/puppet/provider/mount/parsed.rb +0 -0
- data/lib/puppet/provider/nameservice.rb +24 -39
- data/lib/puppet/provider/nameservice/directoryservice.rb +12 -3
- data/lib/puppet/provider/nameservice/netinfo.rb +12 -2
- data/lib/puppet/provider/nameservice/objectadd.rb +1 -10
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/apple.rb +0 -0
- data/lib/puppet/provider/package/apt.rb +14 -21
- data/lib/puppet/provider/package/aptitude.rb +0 -0
- data/lib/puppet/provider/package/blastwave.rb +2 -0
- data/lib/puppet/provider/package/darwinport.rb +0 -0
- data/lib/puppet/provider/package/dpkg.rb +33 -51
- data/lib/puppet/provider/package/fink.rb +1 -1
- data/lib/puppet/provider/package/freebsd.rb +0 -0
- data/lib/puppet/provider/package/gem.rb +0 -0
- data/lib/puppet/provider/package/hpux.rb +46 -0
- data/lib/puppet/provider/package/openbsd.rb +0 -0
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +3 -1
- data/lib/puppet/provider/package/ports.rb +3 -3
- data/lib/puppet/provider/package/rpm.rb +8 -1
- data/lib/puppet/provider/package/rug.rb +2 -2
- data/lib/puppet/provider/package/sun.rb +2 -0
- data/lib/puppet/provider/package/sunfreeware.rb +3 -0
- data/lib/puppet/provider/package/yum.rb +24 -17
- data/lib/puppet/provider/package/yumhelper.py +92 -11
- data/lib/puppet/provider/parsedfile.rb +0 -0
- data/lib/puppet/provider/port/parsed.rb +0 -0
- data/lib/puppet/provider/selboolean/getsetsebool.rb +47 -0
- data/lib/puppet/provider/selmodule/semodule.rb +143 -0
- data/lib/puppet/provider/service/base.rb +0 -0
- data/lib/puppet/provider/service/daemontools.rb +154 -0
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/freebsd.rb +2 -0
- data/lib/puppet/provider/service/gentoo.rb +2 -0
- data/lib/puppet/provider/service/init.rb +0 -0
- data/lib/puppet/provider/service/redhat.rb +1 -1
- data/lib/puppet/provider/service/runit.rb +93 -0
- data/lib/puppet/provider/service/smf.rb +2 -0
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -1
- data/lib/puppet/provider/sshkey/parsed.rb +0 -0
- data/lib/puppet/provider/user/hpux.rb +30 -0
- data/lib/puppet/provider/user/user_role_add.rb +156 -0
- data/lib/puppet/provider/user/useradd.rb +23 -14
- data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +17 -0
- data/lib/puppet/rails/database/schema.rb +0 -8
- data/lib/puppet/rails/resource.rb +6 -6
- data/lib/puppet/reference/configuration.rb +0 -7
- data/lib/puppet/reports.rb +0 -0
- data/lib/puppet/reports/rrdgraph.rb +3 -2
- data/lib/puppet/sslcertificates.rb +0 -0
- data/lib/puppet/sslcertificates/inventory.rb +3 -2
- data/lib/puppet/sslcertificates/support.rb +3 -0
- data/lib/puppet/transaction/report.rb +1 -7
- data/lib/puppet/transportable.rb +10 -7
- data/lib/puppet/type.rb +2110 -14
- data/lib/puppet/type/cron.rb +0 -0
- data/lib/puppet/type/exec.rb +0 -0
- data/lib/puppet/type/file.rb +12 -2
- data/lib/puppet/type/file/checksum.rb +4 -0
- data/lib/puppet/type/file/content.rb +0 -0
- data/lib/puppet/type/file/ensure.rb +0 -0
- data/lib/puppet/type/file/group.rb +30 -43
- data/lib/puppet/type/file/mode.rb +0 -0
- data/lib/puppet/type/file/owner.rb +0 -0
- data/lib/puppet/type/file/selcontext.rb +104 -0
- data/lib/puppet/type/file/source.rb +0 -0
- data/lib/puppet/type/file/type.rb +0 -0
- data/lib/puppet/type/filebucket.rb +0 -0
- data/lib/puppet/type/group.rb +0 -8
- data/lib/puppet/type/host.rb +0 -0
- data/lib/puppet/type/mailalias.rb +0 -0
- data/lib/puppet/type/maillist.rb +0 -0
- data/lib/puppet/type/mount.rb +0 -0
- data/lib/puppet/type/package.rb +2 -2
- data/lib/puppet/type/port.rb +0 -0
- data/lib/puppet/type/schedule.rb +0 -0
- data/lib/puppet/type/selboolean.rb +31 -0
- data/lib/puppet/type/selmodule.rb +54 -0
- data/lib/puppet/type/ssh_authorized_key.rb +3 -3
- data/lib/puppet/type/sshkey.rb +0 -0
- data/lib/puppet/type/tidy.rb +0 -0
- data/lib/puppet/type/user.rb +153 -137
- data/lib/puppet/type/yumrepo.rb +18 -2
- data/lib/puppet/type/zone.rb +5 -1
- data/lib/puppet/util.rb +7 -7
- data/lib/puppet/util/filetype.rb +7 -0
- data/lib/puppet/util/instance_loader.rb +0 -0
- data/lib/puppet/util/ldap/connection.rb +11 -1
- data/lib/puppet/util/ldap/manager.rb +1 -1
- data/lib/puppet/util/loadedfile.rb +0 -0
- data/lib/puppet/util/log.rb +42 -43
- data/lib/puppet/util/metric.rb +23 -9
- data/lib/puppet/util/posix.rb +69 -18
- data/lib/puppet/util/selinux.rb +139 -0
- data/lib/puppet/util/settings.rb +5 -7
- data/lib/puppet/util/user_attr.rb +21 -0
- data/test/certmgr/ca.rb +0 -0
- data/test/certmgr/certmgr.rb +0 -0
- data/test/certmgr/inventory.rb +0 -0
- data/test/certmgr/support.rb +0 -0
- data/test/data/providers/ssh_authorized_key/parsed/authorized_keys1 +3 -0
- data/test/data/snippets/append.pp +11 -0
- data/test/data/snippets/arithmetic_expression.pp +8 -0
- data/test/data/snippets/arraytrailingcomma.pp +3 -0
- data/test/data/snippets/emptyifelse.pp +9 -0
- data/test/data/snippets/funccomma.pp +5 -0
- data/test/data/snippets/ifexpression.rb +6 -0
- data/test/data/snippets/subclass_name_duplication.pp +0 -0
- data/test/executables/filebucket.rb +0 -0
- data/test/executables/puppetbin.rb +0 -0
- data/test/executables/puppetca.rb +0 -0
- data/test/executables/puppetd.rb +0 -0
- data/test/executables/puppetmasterd.rb +0 -0
- data/test/executables/puppetmodule.rb +0 -0
- data/test/language/ast.rb +0 -0
- data/test/language/ast/casestatement.rb +0 -0
- data/test/language/ast/resource.rb +0 -0
- data/test/language/ast/resource_reference.rb +0 -28
- data/test/language/ast/selector.rb +0 -0
- data/test/language/ast/variable.rb +0 -0
- data/test/language/functions.rb +91 -12
- data/test/language/parser.rb +21 -0
- data/test/language/resource.rb +0 -0
- data/test/language/scope.rb +28 -0
- data/test/language/snippets.rb +14 -0
- data/test/language/transportable.rb +0 -0
- data/test/lib/puppettest.rb +0 -0
- data/test/lib/puppettest/reporttesting.rb +0 -2
- data/test/lib/puppettest/runnable_test.rb +2 -0
- data/test/lib/puppettest/support/resources.rb +0 -0
- data/test/network/authconfig.rb +0 -0
- data/test/network/authorization.rb +0 -0
- data/test/network/authstore.rb +0 -0
- data/test/network/client/ca.rb +0 -0
- data/test/network/client/client.rb +0 -0
- data/test/network/client/dipper.rb +0 -0
- data/test/network/client/master.rb +2 -6
- data/test/network/client/resource.rb +0 -0
- data/test/network/client_request.rb +0 -0
- data/test/network/daemon.rb +0 -0
- data/test/network/handler/bucket.rb +0 -0
- data/test/network/handler/ca.rb +0 -0
- data/test/network/handler/fileserver.rb +8 -0
- data/test/network/handler/handler.rb +0 -0
- data/test/network/handler/master.rb +3 -1
- data/test/network/handler/report.rb +0 -0
- data/test/network/handler/resource.rb +0 -0
- data/test/network/handler/runner.rb +0 -0
- data/test/network/rights.rb +0 -0
- data/test/network/server/mongrel_test.rb +0 -0
- data/test/network/server/webrick.rb +0 -0
- data/test/network/xmlrpc/client.rb +0 -0
- data/test/network/xmlrpc/processor.rb +0 -0
- data/test/network/xmlrpc/server.rb +0 -0
- data/test/network/xmlrpc/webrick_servlet.rb +0 -0
- data/test/other/dsl.rb +0 -0
- data/test/other/events.rb +0 -0
- data/test/other/overrides.rb +0 -0
- data/test/other/provider.rb +0 -0
- data/test/other/puppet.rb +0 -0
- data/test/other/relationships.rb +0 -0
- data/test/other/report.rb +2 -4
- data/test/other/transactions.rb +1 -1
- data/test/puppet/conffiles.rb +0 -0
- data/test/puppet/defaults.rb +0 -0
- data/test/puppet/errortest.rb +0 -0
- data/test/puppet/tc_suidmanager.rb +0 -0
- data/test/rails/ast.rb +0 -0
- data/test/rails/configuration.rb +0 -0
- data/test/rails/host.rb +0 -0
- data/test/rails/rails.rb +0 -0
- data/test/rails/railsparameter.rb +0 -0
- data/test/rails/railsresource.rb +0 -0
- data/test/ral/manager/attributes.rb +0 -0
- data/test/ral/manager/instances.rb +0 -0
- data/test/ral/manager/manager.rb +0 -0
- data/test/ral/manager/provider.rb +0 -0
- data/test/ral/manager/type.rb +0 -0
- data/test/ral/providers/cron/crontab.rb +0 -0
- data/test/ral/providers/group.rb +14 -13
- data/test/ral/providers/host/netinfo.rb +0 -0
- data/test/ral/providers/host/parsed.rb +0 -0
- data/test/ral/providers/mailalias/aliases.rb +0 -0
- data/test/ral/providers/mount/netinfo.rb +0 -0
- data/test/ral/providers/nameservice.rb +0 -0
- data/test/ral/providers/package.rb +0 -31
- data/test/ral/providers/package/aptitude.rb +1 -2
- data/test/ral/providers/package/aptrpm.rb +2 -2
- data/test/ral/providers/parsedfile.rb +0 -0
- data/test/ral/providers/port/parsed.rb +0 -0
- data/test/ral/providers/provider.rb +0 -0
- data/test/ral/providers/service/base.rb +0 -0
- data/test/ral/providers/service/debian.rb +0 -0
- data/test/ral/providers/sshkey/parsed.rb +0 -0
- data/test/ral/providers/user.rb +8 -8
- data/test/ral/providers/user/useradd.rb +0 -0
- data/test/ral/type/basic.rb +0 -0
- data/test/ral/type/cron.rb +0 -0
- data/test/ral/type/exec.rb +0 -0
- data/test/ral/type/file.rb +0 -0
- data/test/ral/type/file/target.rb +0 -0
- data/test/ral/type/filebucket.rb +0 -0
- data/test/ral/type/fileignoresource.rb +0 -0
- data/test/ral/type/filesources.rb +1 -3
- data/test/ral/type/group.rb +0 -0
- data/test/ral/type/host.rb +0 -0
- data/test/ral/type/mailalias.rb +1 -2
- data/test/ral/type/parameter.rb +0 -0
- data/test/ral/type/port.rb +0 -0
- data/test/ral/type/property.rb +0 -0
- data/test/ral/type/resources.rb +0 -0
- data/test/ral/type/service.rb +0 -0
- data/test/ral/type/sshkey.rb +0 -0
- data/test/ral/type/tidy.rb +0 -0
- data/test/ral/type/user.rb +0 -50
- data/test/ral/type/yumrepo.rb +7 -1
- data/test/ral/type/zone.rb +0 -0
- data/test/test +0 -0
- data/test/util/autoload.rb +0 -0
- data/test/util/classgen.rb +0 -0
- data/test/util/execution.rb +0 -0
- data/test/util/features.rb +0 -0
- data/test/util/fileparsing.rb +0 -0
- data/test/util/filetype.rb +0 -0
- data/test/util/inifile.rb +0 -0
- data/test/util/instance_loader.rb +0 -0
- data/test/util/log.rb +0 -59
- data/test/util/metrics.rb +0 -0
- data/test/util/package.rb +0 -0
- data/test/util/pidlock.rb +0 -0
- data/test/util/settings.rb +0 -0
- data/test/util/storage.rb +0 -0
- data/test/util/subclass_loader.rb +0 -0
- data/test/util/utiltest.rb +0 -0
- metadata +54 -19
- data/lib/puppet/metatype/attributes.rb +0 -685
- data/lib/puppet/metatype/closure.rb +0 -49
- data/lib/puppet/metatype/container.rb +0 -50
- data/lib/puppet/metatype/evaluation.rb +0 -163
- data/lib/puppet/metatype/instances.rb +0 -305
- data/lib/puppet/metatype/metaparams.rb +0 -423
- data/lib/puppet/metatype/providers.rb +0 -247
- data/lib/puppet/metatype/relationships.rb +0 -115
- data/lib/puppet/metatype/schedules.rb +0 -33
- data/lib/puppet/metatype/tags.rb +0 -38
- data/lib/puppet/util/plist.rb +0 -23
- data/lib/puppet/util/plist/generator.rb +0 -225
- data/lib/puppet/util/plist/parser.rb +0 -226
- data/test/ral/providers/package/apt.rb +0 -169
- data/test/ral/providers/package/dpkg.rb +0 -64
- data/test/util/posixtest.rb +0 -169
data/lib/puppet/util/filetype.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# Basic classes for reading, writing, and emptying files. Not much
|
2
2
|
# to see here.
|
3
|
+
|
4
|
+
require 'puppet/util/selinux'
|
5
|
+
|
3
6
|
class Puppet::Util::FileType
|
4
7
|
attr_accessor :loaded, :path, :synced
|
5
8
|
|
9
|
+
include Puppet::Util::SELinux
|
10
|
+
|
6
11
|
class << self
|
7
12
|
attr_accessor :name
|
8
13
|
include Puppet::Util::ClassGen
|
@@ -109,6 +114,8 @@ class Puppet::Util::FileType
|
|
109
114
|
tf.print text; tf.flush
|
110
115
|
FileUtils.cp(tf.path, @path)
|
111
116
|
tf.close
|
117
|
+
# If SELinux is present, we need to ensure the file has its expected context
|
118
|
+
set_selinux_default_context(@path)
|
112
119
|
end
|
113
120
|
end
|
114
121
|
|
File without changes
|
@@ -17,7 +17,17 @@ class Puppet::Util::Ldap::Connection
|
|
17
17
|
else
|
18
18
|
false
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
|
+
options = {}
|
22
|
+
options[:ssl] = ssl
|
23
|
+
if user = Puppet.settings[:ldapuser] and user != ""
|
24
|
+
options[:user] = user
|
25
|
+
if pass = Puppet.settings[:ldappassword] and pass != ""
|
26
|
+
options[:password] = pass
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
new(Puppet[:ldapserver], Puppet[:ldapport], options)
|
21
31
|
end
|
22
32
|
|
23
33
|
def close
|
File without changes
|
data/lib/puppet/util/log.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'syslog'
|
2
|
+
require 'puppet/util/tagging'
|
2
3
|
|
3
4
|
# Pass feedback to the user. Log levels are modeled after syslog's, and it is
|
4
5
|
# expected that that will be the most common log destination. Supports
|
5
6
|
# multiple destinations, one of which is a remote server.
|
6
7
|
class Puppet::Util::Log
|
7
8
|
include Puppet::Util
|
9
|
+
include Puppet::Util::Tagging
|
8
10
|
|
9
11
|
@levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit]
|
10
12
|
@loglevel = 2
|
@@ -244,23 +246,31 @@ class Puppet::Util::Log
|
|
244
246
|
newdesttype :console do
|
245
247
|
|
246
248
|
|
247
|
-
|
248
|
-
GREEN
|
249
|
-
YELLOW
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
249
|
+
RED = {:console => "[0;31m", :html => "FFA0A0"}
|
250
|
+
GREEN = {:console => "[0;32m", :html => "00CD00"}
|
251
|
+
YELLOW = {:console => "[0;33m", :html => "FFFF60"}
|
252
|
+
BLUE = {:console => "[0;34m", :html => "80A0FF"}
|
253
|
+
PURPLE = {:console => "[0;35m", :html => "FFA500"}
|
254
|
+
CYAN = {:console => "[0;36m", :html => "40FFFF"}
|
255
|
+
WHITE = {:console => "[0;37m", :html => "FFFFFF"}
|
256
|
+
HRED = {:console => "[1;31m", :html => "FFA0A0"}
|
257
|
+
HGREEN = {:console => "[1;32m", :html => "00CD00"}
|
258
|
+
HYELLOW = {:console => "[1;33m", :html => "FFFF60"}
|
259
|
+
HBLUE = {:console => "[1;34m", :html => "80A0FF"}
|
260
|
+
HPURPLE = {:console => "[1;35m", :html => "FFA500"}
|
261
|
+
HCYAN = {:console => "[1;36m", :html => "40FFFF"}
|
262
|
+
HWHITE = {:console => "[1;37m", :html => "FFFFFF"}
|
263
|
+
RESET = {:console => "[0m", :html => ""}
|
254
264
|
|
255
265
|
@@colormap = {
|
256
|
-
:debug =>
|
266
|
+
:debug => WHITE,
|
257
267
|
:info => GREEN,
|
258
|
-
:notice =>
|
259
|
-
:warning =>
|
260
|
-
:err =>
|
261
|
-
:alert =>
|
262
|
-
:emerg =>
|
263
|
-
:crit =>
|
268
|
+
:notice => CYAN,
|
269
|
+
:warning => YELLOW,
|
270
|
+
:err => HPURPLE,
|
271
|
+
:alert => RED,
|
272
|
+
:emerg => HRED,
|
273
|
+
:crit => HRED
|
264
274
|
}
|
265
275
|
|
266
276
|
def colorize(level, str)
|
@@ -462,12 +472,12 @@ class Puppet::Util::Log
|
|
462
472
|
@levels.include?(level)
|
463
473
|
end
|
464
474
|
|
465
|
-
attr_accessor :level, :message, :time, :
|
475
|
+
attr_accessor :level, :message, :time, :remote
|
466
476
|
attr_reader :source
|
467
477
|
|
468
478
|
def initialize(args)
|
469
479
|
unless args.include?(:level) && args.include?(:message)
|
470
|
-
raise
|
480
|
+
raise ArgumentError, "Puppet::Util::Log called incorrectly"
|
471
481
|
end
|
472
482
|
|
473
483
|
if args[:level].class == String
|
@@ -475,35 +485,27 @@ class Puppet::Util::Log
|
|
475
485
|
elsif args[:level].class == Symbol
|
476
486
|
@level = args[:level]
|
477
487
|
else
|
478
|
-
raise
|
479
|
-
"Level is not a string or symbol: #{args[:level].class}"
|
488
|
+
raise ArgumentError, "Level is not a string or symbol: #{args[:level].class}"
|
480
489
|
end
|
481
490
|
|
482
|
-
# Just return unless we're actually at a level we should send
|
483
|
-
#return unless self.class.sendlevel?(@level)
|
484
|
-
|
485
491
|
@message = args[:message].to_s
|
486
492
|
@time = Time.now
|
487
|
-
# this should include the host name, and probly lots of other
|
488
|
-
# stuff, at some point
|
489
|
-
unless self.class.validlevel?(level)
|
490
|
-
raise Puppet::DevError, "Invalid message level #{level}"
|
491
|
-
end
|
492
493
|
|
493
|
-
|
494
|
-
@tags = args[:tags]
|
495
|
-
end
|
494
|
+
raise ArgumentError, "Invalid log level %s" % level unless self.class.validlevel?(level)
|
496
495
|
|
497
|
-
if args
|
498
|
-
self.
|
499
|
-
else
|
500
|
-
@source = "Puppet"
|
496
|
+
if tags = args[:tags]
|
497
|
+
tags.each { |t| self.tag(t) }
|
501
498
|
end
|
502
499
|
|
500
|
+
self.source = args[:source] || "Puppet"
|
501
|
+
|
502
|
+
# Tag myself with my log level
|
503
|
+
tag(level)
|
504
|
+
|
503
505
|
Log.newmessage(self)
|
504
506
|
end
|
505
507
|
|
506
|
-
# Was the source of this log
|
508
|
+
# Was the source of this log a Puppet resource or parameter?
|
507
509
|
def objectsource?
|
508
510
|
if defined? @objectsource and @objectsource
|
509
511
|
@objectsource
|
@@ -525,17 +527,11 @@ class Puppet::Util::Log
|
|
525
527
|
@objectsource = false
|
526
528
|
@source = source.to_s
|
527
529
|
end
|
528
|
-
|
529
|
-
|
530
|
-
@tags = source.tags
|
531
|
-
end
|
530
|
+
if source.respond_to?(:tags)
|
531
|
+
source.tags.each { |t| tag(t) }
|
532
532
|
end
|
533
533
|
end
|
534
534
|
|
535
|
-
def tagged?(tag)
|
536
|
-
@tags.detect { |t| t.to_s == tag.to_s }
|
537
|
-
end
|
538
|
-
|
539
535
|
def to_report
|
540
536
|
"%s %s (%s): %s" % [self.time, self.source, self.level, self.to_s]
|
541
537
|
end
|
@@ -544,5 +540,8 @@ class Puppet::Util::Log
|
|
544
540
|
return @message
|
545
541
|
end
|
546
542
|
end
|
547
|
-
Puppet::Log = Puppet::Util::Log
|
548
543
|
|
544
|
+
# This is for backward compatibility from when we changed the constant to Puppet::Util::Log
|
545
|
+
# because the reports include the constant name. Apparently the alias was created in
|
546
|
+
# March 2007, should could probably be removed soon.
|
547
|
+
Puppet::Log = Puppet::Util::Log
|
data/lib/puppet/util/metric.rb
CHANGED
@@ -5,6 +5,8 @@ require 'puppet'
|
|
5
5
|
class Puppet::Util::Metric
|
6
6
|
|
7
7
|
# Load the library as a feature, so we can test its presence.
|
8
|
+
# It's only used by this class, so there's no reason to move it
|
9
|
+
# to the main feature list.
|
8
10
|
Puppet.features.add :rrd, :libs => 'RRDtool'
|
9
11
|
|
10
12
|
attr_accessor :type, :name, :value, :label
|
@@ -12,6 +14,15 @@ class Puppet::Util::Metric
|
|
12
14
|
|
13
15
|
attr_writer :basedir
|
14
16
|
|
17
|
+
# Return a specific value
|
18
|
+
def [](name)
|
19
|
+
if value = @values.find { |v| v[0] == name }
|
20
|
+
return value[2]
|
21
|
+
else
|
22
|
+
return nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
15
26
|
def basedir
|
16
27
|
if defined? @basedir
|
17
28
|
@basedir
|
@@ -93,11 +104,7 @@ class Puppet::Util::Metric
|
|
93
104
|
def initialize(name,label = nil)
|
94
105
|
@name = name.to_s
|
95
106
|
|
96
|
-
|
97
|
-
@label = label
|
98
|
-
else
|
99
|
-
@label = name.to_s.capitalize.gsub("_", " ")
|
100
|
-
end
|
107
|
+
@label = label || labelize(name)
|
101
108
|
|
102
109
|
@values = []
|
103
110
|
end
|
@@ -107,9 +114,7 @@ class Puppet::Util::Metric
|
|
107
114
|
end
|
108
115
|
|
109
116
|
def newvalue(name,value,label = nil)
|
110
|
-
|
111
|
-
label = name.to_s.capitalize.gsub("_", " ")
|
112
|
-
end
|
117
|
+
label ||= labelize(name)
|
113
118
|
@values.push [name,label,value]
|
114
119
|
end
|
115
120
|
|
@@ -145,7 +150,16 @@ class Puppet::Util::Metric
|
|
145
150
|
def values
|
146
151
|
@values.sort { |a, b| a[1] <=> b[1] }
|
147
152
|
end
|
153
|
+
|
154
|
+
private
|
155
|
+
|
156
|
+
# Convert a name into a label.
|
157
|
+
def labelize(name)
|
158
|
+
name.to_s.capitalize.gsub("_", " ")
|
159
|
+
end
|
148
160
|
end
|
149
161
|
|
162
|
+
# This is necessary because we changed the class path in early 2007,
|
163
|
+
# and reports directly yaml-dump these metrics, so both client and server
|
164
|
+
# have to agree on the class name.
|
150
165
|
Puppet::Metric = Puppet::Util::Metric
|
151
|
-
|
data/lib/puppet/util/posix.rb
CHANGED
@@ -3,23 +3,20 @@ module Puppet::Util::POSIX
|
|
3
3
|
|
4
4
|
# Retrieve a field from a POSIX Etc object. The id can be either an integer
|
5
5
|
# or a name. This only works for users and groups. It's also broken on
|
6
|
-
# some platforms, unfortunately
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
id = Integer(id)
|
13
|
-
end
|
14
|
-
prefix = "get" + space.to_s
|
6
|
+
# some platforms, unfortunately, which is why we fall back to the other
|
7
|
+
# method search_posix_field in the gid and uid methods if a sanity check
|
8
|
+
# fails
|
9
|
+
def get_posix_field(space, field, id)
|
10
|
+
raise Puppet::DevError, "Did not get id from caller" unless id
|
11
|
+
|
15
12
|
if id.is_a?(Integer)
|
16
13
|
if id > Puppet[:maximum_uid].to_i
|
17
14
|
Puppet.err "Tried to get %s field for silly id %s" % [field, id]
|
18
15
|
return nil
|
19
16
|
end
|
20
|
-
method = (
|
17
|
+
method = methodbyid(space)
|
21
18
|
else
|
22
|
-
method = (
|
19
|
+
method = methodbyname(space)
|
23
20
|
end
|
24
21
|
|
25
22
|
begin
|
@@ -31,13 +28,11 @@ module Puppet::Util::POSIX
|
|
31
28
|
end
|
32
29
|
|
33
30
|
# A degenerate method of retrieving name/id mappings. The job of this method is
|
34
|
-
# to
|
35
|
-
|
31
|
+
# to retrieve all objects of a certain type, search for a specific entry
|
32
|
+
# and then return a given field from that entry.
|
33
|
+
def search_posix_field(type, field, id)
|
36
34
|
idmethod = idfield(type)
|
37
35
|
integer = false
|
38
|
-
if id =~ /^\d+$/
|
39
|
-
id = Integer(id)
|
40
|
-
end
|
41
36
|
if id.is_a?(Integer)
|
42
37
|
integer = true
|
43
38
|
if id > Puppet[:maximum_uid].to_i
|
@@ -112,14 +107,70 @@ module Puppet::Util::POSIX
|
|
112
107
|
end
|
113
108
|
end
|
114
109
|
|
110
|
+
# Determine what the method is to get users and groups by id
|
111
|
+
def methodbyid(space)
|
112
|
+
case Puppet::Util.symbolize(space)
|
113
|
+
when :gr, :group: return :getgrgid
|
114
|
+
when :pw, :user, :passwd: return :getpwuid
|
115
|
+
else
|
116
|
+
raise ArgumentError.new("Can only handle users and groups")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Determine what the method is to get users and groups by name
|
121
|
+
def methodbyname(space)
|
122
|
+
case Puppet::Util.symbolize(space)
|
123
|
+
when :gr, :group: return :getgrnam
|
124
|
+
when :pw, :user, :passwd: return :getpwnam
|
125
|
+
else
|
126
|
+
raise ArgumentError.new("Can only handle users and groups")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
115
130
|
# Get the GID of a given group, provided either a GID or a name
|
116
131
|
def gid(group)
|
117
|
-
|
132
|
+
begin
|
133
|
+
group = Integer(group)
|
134
|
+
rescue ArgumentError
|
135
|
+
# pass
|
136
|
+
end
|
137
|
+
if group.is_a?(Integer)
|
138
|
+
return nil unless name = get_posix_field(:group, :name, group)
|
139
|
+
gid = get_posix_field(:group, :gid, name)
|
140
|
+
check_value = gid
|
141
|
+
else
|
142
|
+
return nil unless gid = get_posix_field(:group, :gid, group)
|
143
|
+
name = get_posix_field(:group, :name, gid)
|
144
|
+
check_value = name
|
145
|
+
end
|
146
|
+
if check_value != group
|
147
|
+
return search_posix_field(:group, :gid, group)
|
148
|
+
else
|
149
|
+
return gid
|
150
|
+
end
|
118
151
|
end
|
119
152
|
|
120
153
|
# Get the UID of a given user, whether a UID or name is provided
|
121
154
|
def uid(user)
|
122
|
-
|
155
|
+
begin
|
156
|
+
user = Integer(user)
|
157
|
+
rescue ArgumentError
|
158
|
+
# pass
|
159
|
+
end
|
160
|
+
if user.is_a?(Integer)
|
161
|
+
return nil unless name = get_posix_field(:passwd, :name, user)
|
162
|
+
uid = get_posix_field(:passwd, :uid, name)
|
163
|
+
check_value = uid
|
164
|
+
else
|
165
|
+
return nil unless uid = get_posix_field(:passwd, :uid, user)
|
166
|
+
name = get_posix_field(:passwd, :name, uid)
|
167
|
+
check_value = name
|
168
|
+
end
|
169
|
+
if check_value != user
|
170
|
+
return search_posix_field(:passwd, :uid, user)
|
171
|
+
else
|
172
|
+
return uid
|
173
|
+
end
|
123
174
|
end
|
124
175
|
end
|
125
176
|
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# Provides utility functions to help interfaces Puppet to SELinux.
|
2
|
+
#
|
3
|
+
# Currently this is implemented via the command line tools. At some
|
4
|
+
# point support should be added to use the new SELinux ruby bindings
|
5
|
+
# as that will be faster and more reliable then shelling out when they
|
6
|
+
# are available. At this time (2008-09-26) these bindings aren't bundled on
|
7
|
+
# any SELinux-using distribution I know of.
|
8
|
+
|
9
|
+
require 'puppet/util'
|
10
|
+
|
11
|
+
module Puppet::Util::SELinux
|
12
|
+
|
13
|
+
include Puppet::Util
|
14
|
+
|
15
|
+
def selinux_support?
|
16
|
+
FileTest.exists?("/selinux/enforce")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Retrieve and return the full context of the file. If we don't have
|
20
|
+
# SELinux support or if the stat call fails then return nil.
|
21
|
+
def get_selinux_current_context(file)
|
22
|
+
unless selinux_support?
|
23
|
+
return nil
|
24
|
+
end
|
25
|
+
context = ""
|
26
|
+
begin
|
27
|
+
execpipe("/usr/bin/stat -c %C #{file}") do |out|
|
28
|
+
out.each do |line|
|
29
|
+
context << line
|
30
|
+
end
|
31
|
+
end
|
32
|
+
rescue Puppet::ExecutionFailure
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
context.chomp!
|
36
|
+
# Handle the case that the system seems to have SELinux support but
|
37
|
+
# stat finds unlabled files.
|
38
|
+
if context == "(null)"
|
39
|
+
return nil
|
40
|
+
end
|
41
|
+
return context
|
42
|
+
end
|
43
|
+
|
44
|
+
# Use the matchpathcon command, if present, to return the SELinux context
|
45
|
+
# which the SELinux policy on the system expects the file to have. We can
|
46
|
+
# use this to obtain a good default context. If the command does not
|
47
|
+
# exist or the call fails return nil.
|
48
|
+
#
|
49
|
+
# Note: For this command to work a full, non-relative, filesystem path
|
50
|
+
# should be given.
|
51
|
+
def get_selinux_default_context(file)
|
52
|
+
unless selinux_support?
|
53
|
+
return nil
|
54
|
+
end
|
55
|
+
unless FileTest.executable?("/usr/sbin/matchpathcon")
|
56
|
+
return nil
|
57
|
+
end
|
58
|
+
context = ""
|
59
|
+
begin
|
60
|
+
execpipe("/usr/sbin/matchpathcon #{file}") do |out|
|
61
|
+
out.each do |line|
|
62
|
+
context << line
|
63
|
+
end
|
64
|
+
end
|
65
|
+
rescue Puppet::ExecutionFailure
|
66
|
+
return nil
|
67
|
+
end
|
68
|
+
# For a successful match, matchpathcon returns two fields separated by
|
69
|
+
# a variable amount of whitespace. The second field is the full context.
|
70
|
+
context = context.split(/\s/)[1]
|
71
|
+
return context
|
72
|
+
end
|
73
|
+
|
74
|
+
# Take the full SELinux context returned from the tools and parse it
|
75
|
+
# out to the three (or four) component parts. Supports :seluser, :selrole,
|
76
|
+
# :seltype, and on systems with range support, :selrange.
|
77
|
+
def parse_selinux_context(component, context)
|
78
|
+
if context.nil? or context == "unlabeled"
|
79
|
+
return nil
|
80
|
+
end
|
81
|
+
unless context =~ /^([a-z0-9_]+):([a-z0-9_]+):([a-z0-9_]+)(?::([a-zA-Z0-9:,._-]+))?/
|
82
|
+
raise Puppet::Error, "Invalid context to parse: #{context}"
|
83
|
+
end
|
84
|
+
ret = {
|
85
|
+
:seluser => $1,
|
86
|
+
:selrole => $2,
|
87
|
+
:seltype => $3,
|
88
|
+
:selrange => $4,
|
89
|
+
}
|
90
|
+
return ret[component]
|
91
|
+
end
|
92
|
+
|
93
|
+
# This updates the actual SELinux label on the file. You can update
|
94
|
+
# only a single component or update the entire context. It is just a
|
95
|
+
# wrapper around the chcon command.
|
96
|
+
def set_selinux_context(file, value, component = false)
|
97
|
+
unless selinux_support?
|
98
|
+
return nil
|
99
|
+
end
|
100
|
+
case component
|
101
|
+
when :seluser
|
102
|
+
flag = "-u"
|
103
|
+
when :selrole
|
104
|
+
flag = "-r"
|
105
|
+
when :seltype
|
106
|
+
flag = "-t"
|
107
|
+
when :selrange
|
108
|
+
flag = "-l"
|
109
|
+
else
|
110
|
+
flag = nil
|
111
|
+
end
|
112
|
+
|
113
|
+
if flag.nil?
|
114
|
+
cmd = ["/usr/bin/chcon","-h",value,file]
|
115
|
+
else
|
116
|
+
cmd = ["/usr/bin/chcon","-h",flag,value,file]
|
117
|
+
end
|
118
|
+
execute(cmd)
|
119
|
+
return true
|
120
|
+
end
|
121
|
+
|
122
|
+
# Since this call relies on get_selinux_default_context it also needs a
|
123
|
+
# full non-relative path to the file. Fortunately, that seems to be all
|
124
|
+
# Puppet uses. This will set the file's SELinux context to the policy's
|
125
|
+
# default context (if any) if it differs from the context currently on
|
126
|
+
# the file.
|
127
|
+
def set_selinux_default_context(file)
|
128
|
+
new_context = get_selinux_default_context(file)
|
129
|
+
unless new_context
|
130
|
+
return nil
|
131
|
+
end
|
132
|
+
cur_context = get_selinux_current_context(file)
|
133
|
+
if new_context != cur_context
|
134
|
+
set_selinux_context(file, new_context)
|
135
|
+
return new_context
|
136
|
+
end
|
137
|
+
return nil
|
138
|
+
end
|
139
|
+
end
|