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/settings.rb
CHANGED
@@ -114,12 +114,14 @@ class Puppet::Util::Settings
|
|
114
114
|
end
|
115
115
|
|
116
116
|
# Do variable interpolation on the value.
|
117
|
-
def convert(value)
|
117
|
+
def convert(value, environment = nil)
|
118
118
|
return value unless value
|
119
119
|
return value unless value.is_a? String
|
120
120
|
newval = value.gsub(/\$(\w+)|\$\{(\w+)\}/) do |value|
|
121
121
|
varname = $2 || $1
|
122
|
-
if
|
122
|
+
if varname == "environment" and environment
|
123
|
+
environment
|
124
|
+
elsif pval = self.value(varname)
|
123
125
|
pval
|
124
126
|
else
|
125
127
|
raise Puppet::DevError, "Could not find value for %s" % value
|
@@ -645,10 +647,6 @@ These parameters affect the required permissions of any files specified after
|
|
645
647
|
their specification. Puppet will sometimes use these parameters to check its
|
646
648
|
own configured state, so they can be used to make Puppet a bit more self-managing.
|
647
649
|
|
648
|
-
Note also that the section names are entirely for human-level organizational
|
649
|
-
purposes; they don't provide separate namespaces. All parameters are in a
|
650
|
-
single namespace.
|
651
|
-
|
652
650
|
Generated on #{Time.now}.
|
653
651
|
|
654
652
|
}.gsub(/^/, "# ")
|
@@ -785,7 +783,7 @@ Generated on #{Time.now}.
|
|
785
783
|
val = @config[param].default if val.nil?
|
786
784
|
|
787
785
|
# Convert it if necessary
|
788
|
-
val = convert(val)
|
786
|
+
val = convert(val, environment)
|
789
787
|
|
790
788
|
# And cache it
|
791
789
|
@cache[environment||"none"][param] = val
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class UserAttr
|
2
|
+
def self.get_attributes_by_name(name)
|
3
|
+
attributes = nil
|
4
|
+
|
5
|
+
File.readlines('/etc/user_attr').each do |line|
|
6
|
+
next if line =~ /^#/
|
7
|
+
|
8
|
+
token = line.split(':')
|
9
|
+
|
10
|
+
if token[0] == name
|
11
|
+
attributes = {:name => name}
|
12
|
+
token[4].split(';').each do |attr|
|
13
|
+
key_value = attr.split('=')
|
14
|
+
attributes[key_value[0].intern] = key_value[1].strip
|
15
|
+
end
|
16
|
+
break
|
17
|
+
end
|
18
|
+
end
|
19
|
+
return attributes
|
20
|
+
end
|
21
|
+
end
|
data/test/certmgr/ca.rb
CHANGED
File without changes
|
data/test/certmgr/certmgr.rb
CHANGED
File without changes
|
data/test/certmgr/inventory.rb
CHANGED
File without changes
|
data/test/certmgr/support.rb
CHANGED
File without changes
|
@@ -0,0 +1,3 @@
|
|
1
|
+
1024 35 167576894966720957580065952882142495543043407324667405194097438434880798807651864847570827148390962746149410384891026772700627764845955493549511618975091512997118590589399665757714186775228807376424903966072778732134483862302766419277581465932186641863495699668069439475320990051723279127881281145164415361627 francois@korn
|
2
|
+
2048 35 27332429396020032283276339339051507284036000350350092862949624519871013308460312287866673933080560923221560798334008554200019645416448528663000202951887890525621015333936122655294782671001073795264378070156670395703161543893088138531854776737799752600933431638059304355933305878665812555436198516842364330938321746086651639330436648850787370397302524667456837036413634152938122227368132322078811602953517461933179827432019932348409533535942749570969101453655028606209719023224268890314608444789012688070463327764203306501923404494017305972543000091038543051645924928018568725584728655193415567703220002707737714942757 francois@korn
|
3
|
+
from="192.168.1.1",command="/bin/false",no-pty,no-port-forwarding 2048 35 27332429396020032283276339339051507284036000350350092862949624519871013308460312287866673933080560923221560798334008554200019645416448528663000202951887890525621015333936122655294782671001073795264378070156670395703161543893088138531854776737799752600933431638059304355933305878665812555436198516842364330938321746086651639330436648850787370397302524667456837036413634152938122227368132322078811602953517461933179827432019932348409533535942749570969101453655028606209719023224268890314608444789012688070463327764203306501923404494017305972543000091038543051645924928018568725584728655193415567703220002707737714942757 francois@korn
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/executables/puppetd.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/test/language/ast.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
@@ -23,34 +23,6 @@ class TestASTResourceReference < Test::Unit::TestCase
|
|
23
23
|
@parser = @scope.compiler.parser
|
24
24
|
end
|
25
25
|
|
26
|
-
def test_evaluate
|
27
|
-
@parser.newdefine "one::two"
|
28
|
-
@parser.newdefine "one-two"
|
29
|
-
[%w{File /tmp/yay}, %w{One::Two three}, %w{One-two three}].each do |type, title|
|
30
|
-
ref = newref(type, title)
|
31
|
-
|
32
|
-
evaled = nil
|
33
|
-
assert_nothing_raised("Could not evaluate resource ref") do
|
34
|
-
evaled = ref.evaluate(@scope)
|
35
|
-
end
|
36
|
-
|
37
|
-
assert_equal(type, evaled.type, "Type did not translate correctly")
|
38
|
-
assert_equal(title, evaled.title, "Title did not translate correctly")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_finding_classes_for_reference
|
43
|
-
@parser.newclass "one"
|
44
|
-
ref = newref("Class", "one")
|
45
|
-
evaled = nil
|
46
|
-
assert_nothing_raised("Could not evaluate resource ref") do
|
47
|
-
evaled = ref.evaluate(@scope)
|
48
|
-
end
|
49
|
-
|
50
|
-
assert_equal("Class", evaled.type, "Did not set type to 'class'")
|
51
|
-
assert_equal("one", evaled.title, "Did not look up class corectly")
|
52
|
-
end
|
53
|
-
|
54
26
|
# Related to #706, make sure resource references correctly translate to qualified types.
|
55
27
|
def test_scoped_references
|
56
28
|
@parser.newdefine "one"
|
File without changes
|
File without changes
|
data/test/language/functions.rb
CHANGED
@@ -96,11 +96,12 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
96
96
|
twop = File.join(Puppet[:templatedir], "two")
|
97
97
|
|
98
98
|
File.open(onep, "w") do |f|
|
99
|
-
f.puts "
|
99
|
+
f.puts "<%- if @one.nil? then raise '@one undefined' end -%>" +
|
100
|
+
"template <%= @one %>"
|
100
101
|
end
|
101
102
|
|
102
103
|
File.open(twop, "w") do |f|
|
103
|
-
f.puts "template <%= two %>"
|
104
|
+
f.puts "template <%= @two %>"
|
104
105
|
end
|
105
106
|
func = nil
|
106
107
|
assert_nothing_raised do
|
@@ -116,15 +117,27 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
116
117
|
ast = varobj("output", func)
|
117
118
|
|
118
119
|
scope = mkscope
|
120
|
+
|
121
|
+
# Test that our manual exception throw fails the parse
|
119
122
|
assert_raise(Puppet::ParseError) do
|
120
123
|
ast.evaluate(scope)
|
121
124
|
end
|
122
125
|
|
126
|
+
# Test that our use of an undefined instance variable does not throw
|
127
|
+
# an exception, but only safely continues.
|
123
128
|
scope.setvar("one", "One")
|
124
|
-
|
129
|
+
assert_nothing_raised do
|
125
130
|
ast.evaluate(scope)
|
126
131
|
end
|
132
|
+
|
133
|
+
# Ensure that we got the output we expected from that evaluation.
|
134
|
+
assert_equal("template One\ntemplate \n", scope.lookupvar("output"),
|
135
|
+
"Undefined template variables do not raise exceptions")
|
136
|
+
|
137
|
+
# Now, fill in the last variable and make sure the whole thing
|
138
|
+
# evaluates correctly.
|
127
139
|
scope.setvar("two", "Two")
|
140
|
+
scope.unsetvar("output")
|
128
141
|
assert_nothing_raised do
|
129
142
|
ast.evaluate(scope)
|
130
143
|
end
|
@@ -138,7 +151,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
138
151
|
template = tempfile()
|
139
152
|
|
140
153
|
File.open(template, "w") do |f|
|
141
|
-
f.puts "template <%=
|
154
|
+
f.puts "template <%= @yay.nil?() ? raise('yay undefined') : @yay %>"
|
142
155
|
end
|
143
156
|
|
144
157
|
func = nil
|
@@ -158,17 +171,77 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
158
171
|
ast.evaluate(scope)
|
159
172
|
end
|
160
173
|
|
161
|
-
scope.setvar("
|
174
|
+
scope.setvar("yay", "this is yay")
|
162
175
|
|
163
176
|
assert_nothing_raised do
|
164
177
|
ast.evaluate(scope)
|
165
178
|
end
|
166
179
|
|
167
|
-
assert_equal("template this is
|
180
|
+
assert_equal("template this is yay\n", scope.lookupvar("output"),
|
168
181
|
"Templates were not handled correctly")
|
169
182
|
|
170
183
|
end
|
171
184
|
|
185
|
+
# Make sure that legacy template variable access works as expected.
|
186
|
+
def test_legacyvariables
|
187
|
+
template = tempfile()
|
188
|
+
|
189
|
+
File.open(template, "w") do |f|
|
190
|
+
f.puts "template <%= deprecated %>"
|
191
|
+
end
|
192
|
+
|
193
|
+
func = nil
|
194
|
+
assert_nothing_raised do
|
195
|
+
func = Puppet::Parser::AST::Function.new(
|
196
|
+
:name => "template",
|
197
|
+
:ftype => :rvalue,
|
198
|
+
:arguments => AST::ASTArray.new(
|
199
|
+
:children => [stringobj(template)]
|
200
|
+
)
|
201
|
+
)
|
202
|
+
end
|
203
|
+
ast = varobj("output", func)
|
204
|
+
|
205
|
+
# Verify that we get an exception using old-style accessors.
|
206
|
+
scope = mkscope
|
207
|
+
assert_raise(Puppet::ParseError) do
|
208
|
+
ast.evaluate(scope)
|
209
|
+
end
|
210
|
+
|
211
|
+
# Verify that we evaluate and return their value correctly.
|
212
|
+
scope.setvar("deprecated", "deprecated value")
|
213
|
+
assert_nothing_raised do
|
214
|
+
ast.evaluate(scope)
|
215
|
+
end
|
216
|
+
|
217
|
+
assert_equal("template deprecated value\n", scope.lookupvar("output"),
|
218
|
+
"Deprecated template variables were not handled correctly")
|
219
|
+
end
|
220
|
+
|
221
|
+
# Make sure that problems with kernel method visibility still exist.
|
222
|
+
def test_kernel_module_shadows_deprecated_var_lookup
|
223
|
+
template = tempfile()
|
224
|
+
File.open(template, "w").puts("<%= binding %>")
|
225
|
+
|
226
|
+
func = nil
|
227
|
+
assert_nothing_raised do
|
228
|
+
func = Puppet::Parser::AST::Function.new(
|
229
|
+
:name => "template",
|
230
|
+
:ftype => :rvalue,
|
231
|
+
:arguments => AST::ASTArray.new(
|
232
|
+
:children => [stringobj(template)]
|
233
|
+
)
|
234
|
+
)
|
235
|
+
end
|
236
|
+
ast = varobj("output", func)
|
237
|
+
|
238
|
+
# Verify that Kernel methods still shadow deprecated variable lookups.
|
239
|
+
scope = mkscope
|
240
|
+
assert_nothing_raised("No exception for Kernel shadowed variable names") do
|
241
|
+
ast.evaluate(scope)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
172
245
|
def test_tempatefunction_cannot_see_scopes
|
173
246
|
template = tempfile()
|
174
247
|
|
@@ -205,7 +278,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
205
278
|
file = tempfile()
|
206
279
|
|
207
280
|
Puppet[:code] = %{file { "#{file}": content => template("#{template}") }}
|
208
|
-
Puppet[:
|
281
|
+
Puppet[:environment] = "yay"
|
209
282
|
interp = Puppet::Parser::Interpreter.new
|
210
283
|
node = mknode
|
211
284
|
node.stubs(:environment).returns("yay")
|
@@ -243,7 +316,7 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
243
316
|
template = tempfile()
|
244
317
|
|
245
318
|
File.open(template, "w") do |f|
|
246
|
-
f.puts "template <%= yayness %>"
|
319
|
+
f.puts "template <%= @yayness %>"
|
247
320
|
end
|
248
321
|
|
249
322
|
func = nil
|
@@ -263,10 +336,6 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
263
336
|
false => "false",
|
264
337
|
}.each do |string, value|
|
265
338
|
scope = mkscope
|
266
|
-
assert_raise(Puppet::ParseError) do
|
267
|
-
ast.evaluate(scope)
|
268
|
-
end
|
269
|
-
|
270
339
|
scope.setvar("yayness", string)
|
271
340
|
assert_equal(string, scope.lookupvar("yayness", false))
|
272
341
|
|
@@ -310,6 +379,8 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
310
379
|
scope = mkscope
|
311
380
|
parser = scope.compiler.parser
|
312
381
|
|
382
|
+
realize = Puppet::Parser::Functions.function(:realize)
|
383
|
+
|
313
384
|
# Make a definition
|
314
385
|
parser.newdefine("mytype")
|
315
386
|
|
@@ -365,6 +436,8 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
365
436
|
def test_defined
|
366
437
|
scope = mkscope
|
367
438
|
parser = scope.compiler.parser
|
439
|
+
|
440
|
+
defined = Puppet::Parser::Functions.function(:defined)
|
368
441
|
|
369
442
|
parser.newclass("yayness")
|
370
443
|
parser.newdefine("rahness")
|
@@ -422,6 +495,8 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
422
495
|
scope = mkscope
|
423
496
|
parser = scope.compiler.parser
|
424
497
|
|
498
|
+
include = Puppet::Parser::Functions.function(:include)
|
499
|
+
|
425
500
|
assert_raise(Puppet::ParseError, "did not throw error on missing class") do
|
426
501
|
scope.function_include("nosuchclass")
|
427
502
|
end
|
@@ -439,6 +514,8 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
439
514
|
parser = mkparser
|
440
515
|
scope = mkscope(:parser => parser)
|
441
516
|
|
517
|
+
file = Puppet::Parser::Functions.function(:file)
|
518
|
+
|
442
519
|
file1 = tempfile
|
443
520
|
file2 = tempfile
|
444
521
|
file3 = tempfile
|
@@ -479,6 +556,8 @@ class TestLangFunctions < Test::Unit::TestCase
|
|
479
556
|
assert_equal("yay\n", %x{#{command}}, "command did not work")
|
480
557
|
assert_equal("yay-foo\n", %x{#{command} foo}, "command did not work")
|
481
558
|
|
559
|
+
generate = Puppet::Parser::Functions.function(:generate)
|
560
|
+
|
482
561
|
scope = mkscope
|
483
562
|
parser = scope.compiler.parser
|
484
563
|
|
data/test/language/parser.rb
CHANGED
@@ -66,6 +66,19 @@ class TestParser < Test::Unit::TestCase
|
|
66
66
|
}
|
67
67
|
end
|
68
68
|
|
69
|
+
def test_arrayrvalueswithtrailingcomma
|
70
|
+
parser = mkparser
|
71
|
+
ret = nil
|
72
|
+
file = tempfile()
|
73
|
+
assert_nothing_raised {
|
74
|
+
parser.string = "file { \"#{file}\": mode => [755, 640,] }"
|
75
|
+
}
|
76
|
+
|
77
|
+
assert_nothing_raised {
|
78
|
+
ret = parser.parse
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
69
82
|
def mkmanifest(file)
|
70
83
|
name = File.join(tmpdir, "file%s" % rand(100))
|
71
84
|
@@tmpfiles << name
|
@@ -1208,5 +1221,13 @@ file { "/tmp/yayness":
|
|
1208
1221
|
parser.import("test")
|
1209
1222
|
end
|
1210
1223
|
end
|
1224
|
+
|
1225
|
+
def test_watch_file_only_once
|
1226
|
+
FileTest.stubs(:exists?).returns(true)
|
1227
|
+
parser = mkparser
|
1228
|
+
parser.watch_file("doh")
|
1229
|
+
parser.watch_file("doh")
|
1230
|
+
assert_equal(1, parser.files.select { |name, file| file.file == "doh" }.length, "Length of watched 'doh' files was not 1")
|
1231
|
+
end
|
1211
1232
|
end
|
1212
1233
|
|
data/test/language/resource.rb
CHANGED
File without changes
|
data/test/language/scope.rb
CHANGED
@@ -53,6 +53,34 @@ class TestScope < Test::Unit::TestCase
|
|
53
53
|
assert_equal(:undefined, scopes[name].lookupvar("third", false), "Found child var in top scope")
|
54
54
|
end
|
55
55
|
assert_equal("botval", scopes[:bot].lookupvar("third", false), "Could not find var in bottom scope")
|
56
|
+
|
57
|
+
|
58
|
+
# Test that the scopes convert to hash structures correctly.
|
59
|
+
# For topscope recursive vs non-recursive should be identical
|
60
|
+
assert_equal(topscope.to_hash(false), topscope.to_hash(true),
|
61
|
+
"Recursive and non-recursive hash is identical for topscope")
|
62
|
+
|
63
|
+
# Check the variable we expect is present.
|
64
|
+
assert_equal({"first" => "topval"}, topscope.to_hash(),
|
65
|
+
"topscope returns the expected hash of variables")
|
66
|
+
|
67
|
+
# Now, check that midscope does the right thing in all cases.
|
68
|
+
assert_equal({"second" => "midval"},
|
69
|
+
midscope.to_hash(false),
|
70
|
+
"midscope non-recursive hash contains only midscope variable")
|
71
|
+
assert_equal({"first" => "topval", "second" => "midval"},
|
72
|
+
midscope.to_hash(true),
|
73
|
+
"midscope recursive hash contains topscope variable also")
|
74
|
+
|
75
|
+
# Finally, check the ability to shadow symbols by adding a shadow to
|
76
|
+
# bottomscope, then checking that we see the right stuff.
|
77
|
+
botscope.setvar("first", "shadowval")
|
78
|
+
assert_equal({"third" => "botval", "first" => "shadowval"},
|
79
|
+
botscope.to_hash(false),
|
80
|
+
"botscope has the right non-recursive hash")
|
81
|
+
assert_equal({"third" => "botval", "first" => "shadowval", "second" => "midval"},
|
82
|
+
botscope.to_hash(true),
|
83
|
+
"botscope values shadow parent scope values")
|
56
84
|
end
|
57
85
|
|
58
86
|
def test_lookupvar
|