puppet 3.2.2 → 3.2.3.rc1

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.

Files changed (50) hide show
  1. data/Gemfile +1 -1
  2. data/Rakefile +7 -2
  3. data/ext/build_defaults.yaml +1 -1
  4. data/ext/debian/changelog.erb +6 -0
  5. data/ext/debian/control +1 -1
  6. data/ext/project_data.yaml +1 -1
  7. data/ext/redhat/puppet.spec.erb +4 -1
  8. data/ext/windows/service/daemon.bat +1 -1
  9. data/lib/puppet/application/agent.rb +1 -1
  10. data/lib/puppet/application.rb +2 -2
  11. data/lib/puppet/defaults.rb +39 -26
  12. data/lib/puppet/parser/ast/block_expression.rb +4 -0
  13. data/lib/puppet/parser/ast/branch.rb +0 -15
  14. data/lib/puppet/parser/functions/collect.rb +8 -7
  15. data/lib/puppet/parser/functions/each.rb +6 -5
  16. data/lib/puppet/parser/functions/foreach.rb +6 -5
  17. data/lib/puppet/parser/functions/reduce.rb +20 -18
  18. data/lib/puppet/parser/functions/reject.rb +6 -5
  19. data/lib/puppet/parser/functions/select.rb +6 -5
  20. data/lib/puppet/parser/functions/slice.rb +4 -3
  21. data/lib/puppet/resource/catalog.rb +6 -4
  22. data/lib/puppet/resource/type.rb +1 -9
  23. data/lib/puppet/scheduler/timer.rb +1 -1
  24. data/lib/puppet/type/file/ensure.rb +10 -11
  25. data/lib/puppet/util/adsi.rb +15 -15
  26. data/lib/puppet/util/monkey_patches.rb +0 -9
  27. data/lib/puppet/util/windows/user.rb +7 -5
  28. data/lib/puppet/version.rb +1 -1
  29. data/spec/integration/application/apply_spec.rb +4 -0
  30. data/spec/unit/application/apply_spec.rb +1 -0
  31. data/spec/unit/application/facts_spec.rb +3 -1
  32. data/spec/unit/configurer_spec.rb +1 -0
  33. data/spec/unit/parser/ast/block_expression_spec.rb +67 -0
  34. data/spec/unit/parser/functions/fqdn_rand_spec.rb +22 -42
  35. data/spec/unit/parser/functions/sprintf_spec.rb +6 -1
  36. data/spec/unit/pops/parser/rgen_sanitycheck_spec.rb +9 -1
  37. data/spec/unit/provider/exec/posix_spec.rb +1 -0
  38. data/spec/unit/provider/group/windows_adsi_spec.rb +1 -1
  39. data/spec/unit/provider/package/pip_spec.rb +4 -0
  40. data/spec/unit/provider/service/redhat_spec.rb +2 -1
  41. data/spec/unit/provider/user/windows_adsi_spec.rb +1 -2
  42. data/spec/unit/resource/catalog_spec.rb +23 -3
  43. data/spec/unit/resource/type_spec.rb +3 -12
  44. data/spec/unit/type/exec_spec.rb +3 -2
  45. data/spec/unit/util/adsi_spec.rb +46 -11
  46. data/spec/unit/util/rdoc/parser_spec.rb +1 -1
  47. data/spec/unit/util/run_mode_spec.rb +38 -10
  48. data/spec/unit/util/zaml_spec.rb +1 -1
  49. data/spec/unit/util_spec.rb +4 -1
  50. metadata +16 -14
data/Gemfile CHANGED
@@ -24,7 +24,7 @@ gem "hiera", *location_for(ENV['HIERA_LOCATION'] || '~> 1.0')
24
24
  gem "rake", :require => false
25
25
  gem "rspec", "~> 2.11.0", :require => false
26
26
  gem "mocha", "~> 0.10.5", :require => false
27
- gem "rgen", "0.6.2", :require => false
27
+ gem "rgen", "0.6.5", :require => false
28
28
 
29
29
  gem "yarjuf", "~> 1.0"
30
30
 
data/Rakefile CHANGED
@@ -1,10 +1,11 @@
1
1
  # Rakefile for Puppet -*- ruby -*-
2
+ RAKE_ROOT = File.dirname(__FILE__)
2
3
 
3
4
  # We need access to the Puppet.version method
4
5
  $LOAD_PATH.unshift(File.expand_path("lib"))
5
6
  require 'puppet/version'
6
7
 
7
- $LOAD_PATH << File.join(File.dirname(__FILE__), 'tasks')
8
+ $LOAD_PATH << File.join(RAKE_ROOT, 'tasks')
8
9
 
9
10
  begin
10
11
  require 'rubygems'
@@ -22,7 +23,11 @@ end
22
23
  require 'rake'
23
24
 
24
25
  Dir['tasks/**/*.rake'].each { |t| load t }
25
- Dir['ext/packaging/tasks/**/*'].sort.each { |t| load t }
26
+
27
+ begin
28
+ load File.join(RAKE_ROOT, 'ext', 'packaging', 'packaging.rake')
29
+ rescue LoadError
30
+ end
26
31
 
27
32
  build_defs_file = 'ext/build_defaults.yaml'
28
33
  if File.exist?(build_defs_file)
@@ -2,7 +2,7 @@
2
2
  packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master'
3
3
  packaging_repo: 'packaging'
4
4
  default_cow: 'base-squeeze-i386.cow'
5
- cows: 'base-lucid-i386.cow base-oneiric-i386.cow base-precise-i386.cow base-quantal-i386.cow base-raring-i386.cow base-sid-i386.cow base-squeeze-i386.cow base-stable-i386.cow base-testing-i386.cow base-unstable-i386.cow base-wheezy-i386.cow'
5
+ cows: 'base-lucid-i386.cow base-precise-i386.cow base-quantal-i386.cow base-raring-i386.cow base-sid-i386.cow base-squeeze-i386.cow base-stable-i386.cow base-testing-i386.cow base-unstable-i386.cow base-wheezy-i386.cow'
6
6
  pbuild_conf: '/etc/pbuilderrc'
7
7
  packager: 'puppetlabs'
8
8
  gpg_name: 'info@puppetlabs.com'
@@ -4,6 +4,12 @@ puppet (<%= @debversion %>) hardy lucid natty oneiric unstable sid squeeze wheez
4
4
 
5
5
  -- Puppet Labs Release <info@puppetlabs.com> <%= Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")%>
6
6
 
7
+ puppet (3.2.3-0.1rc0puppetlabs1) lucid unstable sid squeeze wheezy precise quantal raring; urgency=low
8
+
9
+ * Update ruby-rgen dependency to 0.6.5
10
+
11
+ -- Matthaus Owens <matthaus@puppetlabs.com> Thu, 27 Jun 2013 14:45:14 +0000
12
+
7
13
  puppet (3.2.0-0.1rc0puppetlabs1) lucid oneiric precise unstable sid squeeze wheezy precise; urgency=low
8
14
 
9
15
  * Add ruby-rgen dependency for new parser in Puppet 3.2
data/ext/debian/control CHANGED
@@ -11,7 +11,7 @@ Homepage: http://projects.puppetlabs.com/projects/puppet
11
11
 
12
12
  Package: puppet-common
13
13
  Architecture: all
14
- Depends: ${misc:Depends}, ruby | ruby-interpreter, libxmlrpc-ruby, libopenssl-ruby, ruby-shadow | libshadow-ruby1.8, libaugeas-ruby | libaugeas-ruby1.9.1 | libaugeas-ruby1.8, adduser, lsb-base, sysv-rc (>= 2.86) | file-rc, hiera (>= 1.0.0), facter (>= 1.6.12), ruby-rgen
14
+ Depends: ${misc:Depends}, ruby | ruby-interpreter, libxmlrpc-ruby, libopenssl-ruby, ruby-shadow | libshadow-ruby1.8, libaugeas-ruby | libaugeas-ruby1.9.1 | libaugeas-ruby1.8, adduser, lsb-base, sysv-rc (>= 2.86) | file-rc, hiera (>= 1.0.0), facter (>= 1.6.12), ruby-rgen (>= 0.6.5)
15
15
  Recommends: lsb-release, debconf-utils
16
16
  Suggests: ruby-selinux | libselinux-ruby1.8, librrd-ruby1.9.1 | librrd-ruby1.8
17
17
  Breaks: puppet (<< 2.6.0~rc2-1), puppetmaster (<< 0.25.4-1)
@@ -17,7 +17,7 @@ gem_forge_project: 'puppet'
17
17
  gem_runtime_dependencies:
18
18
  facter: '~> 1.6'
19
19
  hiera: '~> 1.0'
20
- rgen: '~> 0.6'
20
+ rgen: '~> 0.6.5'
21
21
  gem_rdoc_options:
22
22
  - --title
23
23
  - "Puppet - Configuration Management"
@@ -56,7 +56,7 @@ Requires: facter >= 1.6.11
56
56
  # Ruby 1.8.7 available for el5 at: yum.puppetlabs.com/el/5/devel/$ARCH
57
57
  Requires: ruby >= 1.8.7
58
58
  Requires: hiera >= 1.0.0
59
- Requires: ruby-rgen
59
+ Requires: ruby-rgen >= 0.6.5
60
60
  Obsoletes: hiera-puppet < 1.0.0
61
61
  Provides: hiera-puppet >= 1.0.0
62
62
  %{!?_without_augeas:Requires: ruby-augeas}
@@ -391,6 +391,9 @@ rm -rf %{buildroot}
391
391
  * <%= Time.now.strftime("%a %b %d %Y") %> Puppet Labs Release <info@puppetlabs.com> - <%= @rpmversion %>-<%= @rpmrelease %>
392
392
  - Build for <%= @version %>
393
393
 
394
+ * Thu Jun 27 2013 Matthaus Owens <matthaus@puppetlabs.com> - 3.2.3-0.1rc0
395
+ - Bump requires on ruby-rgen to 0.6.5
396
+
394
397
  * Fri Apr 12 2013 Matthaus Owens <matthaus@puppetlabs.com> - 3.2.0-0.1rc0
395
398
  - Add requires on ruby-rgen for new parser in Puppet 3.2
396
399
 
@@ -3,4 +3,4 @@ SETLOCAL
3
3
 
4
4
  call "%~dp0..\bin\environment.bat" %0 %*
5
5
 
6
- rubyw -rubygems "%~dp0daemon.rb" %*
6
+ ruby -rubygems "%~dp0daemon.rb" %*
@@ -445,7 +445,7 @@ Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License
445
445
  def setup
446
446
  setup_test if options[:test]
447
447
 
448
- setup_logs(true)
448
+ setup_logs
449
449
 
450
450
  exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
451
451
 
@@ -376,8 +376,8 @@ class Application
376
376
  setup_logs
377
377
  end
378
378
 
379
- def setup_logs(is_daemon = false)
380
- if options[:debug] or options[:verbose] or is_daemon
379
+ def setup_logs
380
+ if options[:debug] or options[:verbose]
381
381
  Puppet::Util::Log.newdestination(:console)
382
382
  if options[:debug]
383
383
  Puppet::Util::Log.level = :debug
@@ -8,6 +8,9 @@ module Puppet
8
8
  # see the docs for Settings.define_settings
9
9
  ############################################################################################
10
10
 
11
+ AS_DURATION = %q{This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y).}
12
+ STORECONFIGS_ONLY = %q{This setting is only used by the ActiveRecord storeconfigs and inventory backends, which are deprecated.}
13
+
11
14
  define_settings(:main,
12
15
  :confdir => {
13
16
  :default => nil,
@@ -291,7 +294,7 @@ module Puppet
291
294
  :type => :duration,
292
295
  :desc => "The minimum time to wait between checking for updates in
293
296
  configuration files. This timeout determines how quickly Puppet checks whether
294
- a file (such as manifests or templates) has changed on disk. Can be specified as a duration.",
297
+ a file (such as manifests or templates) has changed on disk. #{AS_DURATION}",
295
298
  },
296
299
  :queue_type => {
297
300
  :default => "stomp",
@@ -578,7 +581,7 @@ EOT
578
581
  :default => "60d",
579
582
  :type => :duration,
580
583
  :desc => "The window of time leading up to a certificate's expiration that a notification
581
- will be logged. This applies to CA, master, and agent certificates. Can be specified as a duration."
584
+ will be logged. This applies to CA, master, and agent certificates. #{AS_DURATION}"
582
585
  }
583
586
  )
584
587
 
@@ -685,7 +688,7 @@ EOT
685
688
  :default => "5y",
686
689
  :type => :duration,
687
690
  :desc => "The default TTL for new certificates. If this setting is set, ca_days is ignored.
688
- Can be specified as a duration."
691
+ #{AS_DURATION}"
689
692
  },
690
693
  :req_bits => {
691
694
  :default => 4096,
@@ -904,7 +907,7 @@ EOT
904
907
  :default => "$runinterval",
905
908
  :type => :duration,
906
909
  :desc => "How often RRD should expect data.
907
- This should match how often the hosts report back to the server. Can be specified as a duration.",
910
+ This should match how often the hosts report back to the server. #{AS_DURATION}",
908
911
  }
909
912
  )
910
913
 
@@ -1025,10 +1028,10 @@ EOT
1025
1028
  :runinterval => {
1026
1029
  :default => "30m",
1027
1030
  :type => :duration,
1028
- :desc => "How often puppet agent applies the client configuration; in seconds.
1031
+ :desc => "How often puppet agent applies the catalog.
1029
1032
  Note that a runinterval of 0 means \"run continuously\" rather than
1030
1033
  \"never run.\" If you want puppet agent to never run, you should start
1031
- it with the `--no-client` option. Can be specified as a duration.",
1034
+ it with the `--no-client` option. #{AS_DURATION}",
1032
1035
  },
1033
1036
  :listen => {
1034
1037
  :default => false,
@@ -1125,7 +1128,7 @@ EOT
1125
1128
  :default => "$runinterval",
1126
1129
  :type => :duration,
1127
1130
  :desc => "The maximum time to delay before runs. Defaults to being the same as the
1128
- run interval. Can be specified as a duration.",
1131
+ run interval. #{AS_DURATION}",
1129
1132
  },
1130
1133
  :splay => {
1131
1134
  :default => false,
@@ -1144,7 +1147,7 @@ EOT
1144
1147
  :type => :duration,
1145
1148
  :desc => "How long the client should wait for the configuration to be retrieved
1146
1149
  before considering it a failure. This can help reduce flapping if too
1147
- many clients contact the server at one time. Can be specified as a duration.",
1150
+ many clients contact the server at one time. #{AS_DURATION}",
1148
1151
  },
1149
1152
  :report_server => {
1150
1153
  :default => "$server",
@@ -1204,10 +1207,19 @@ EOT
1204
1207
  :waitforcert => {
1205
1208
  :default => "2m",
1206
1209
  :type => :duration,
1207
- :desc => "The time interval 'puppet agent' should connect to the server
1208
- and ask it to sign a certificate request. This is useful for the initial setup of a
1209
- puppet client. You can turn off waiting for certificates by specifying a time of 0.
1210
- Can be specified as a duration.",
1210
+ :desc => "How frequently puppet agent should ask for a signed certificate.
1211
+
1212
+ When starting for the first time, puppet agent will submit a certificate
1213
+ signing request (CSR) to the server named in the `ca_server` setting
1214
+ (usually the puppet master); this may be autosigned, or may need to be
1215
+ approved by a human, depending on the CA server's configuration.
1216
+
1217
+ Puppet agent cannot apply configurations until its approved certificate is
1218
+ available. Since the certificate may or may not be available immediately,
1219
+ puppet agent will repeatedly try to fetch it at this interval. You can
1220
+ turn off waiting for certificates by specifying a time of 0, in which case
1221
+ puppet agent will exit if it cannot get a cert.
1222
+ #{AS_DURATION}",
1211
1223
  }
1212
1224
  )
1213
1225
 
@@ -1296,21 +1308,20 @@ EOT
1296
1308
  :mode => 0660,
1297
1309
  :owner => "service",
1298
1310
  :group => "service",
1299
- :desc => "The database cache for client configurations. Used for
1300
- querying within the language."
1311
+ :desc => "The sqlite database file. #{STORECONFIGS_ONLY}"
1301
1312
  },
1302
1313
  :dbadapter => {
1303
1314
  :default => "sqlite3",
1304
- :desc => "The type of database to use.",
1315
+ :desc => "The type of database to use. #{STORECONFIGS_ONLY}",
1305
1316
  },
1306
1317
  :dbmigrate => {
1307
1318
  :default => false,
1308
1319
  :type => :boolean,
1309
- :desc => "Whether to automatically migrate the database.",
1320
+ :desc => "Whether to automatically migrate the database. #{STORECONFIGS_ONLY}",
1310
1321
  },
1311
1322
  :dbname => {
1312
1323
  :default => "puppet",
1313
- :desc => "The name of the database to use.",
1324
+ :desc => "The name of the database to use. #{STORECONFIGS_ONLY}",
1314
1325
  },
1315
1326
  :dbserver => {
1316
1327
  :default => "localhost",
@@ -1320,27 +1331,27 @@ EOT
1320
1331
  :dbport => {
1321
1332
  :default => "",
1322
1333
  :desc => "The database password for caching. Only
1323
- used when networked databases are used.",
1334
+ used when networked databases are used. #{STORECONFIGS_ONLY}",
1324
1335
  },
1325
1336
  :dbuser => {
1326
1337
  :default => "puppet",
1327
1338
  :desc => "The database user for caching. Only
1328
- used when networked databases are used.",
1339
+ used when networked databases are used. #{STORECONFIGS_ONLY}",
1329
1340
  },
1330
1341
  :dbpassword => {
1331
1342
  :default => "puppet",
1332
1343
  :desc => "The database password for caching. Only
1333
- used when networked databases are used.",
1344
+ used when networked databases are used. #{STORECONFIGS_ONLY}",
1334
1345
  },
1335
1346
  :dbconnections => {
1336
1347
  :default => '',
1337
1348
  :desc => "The number of database connections for networked
1338
- databases. Will be ignored unless the value is a positive integer.",
1349
+ databases. Will be ignored unless the value is a positive integer. #{STORECONFIGS_ONLY}",
1339
1350
  },
1340
1351
  :dbsocket => {
1341
1352
  :default => "",
1342
1353
  :desc => "The database socket location. Only used when networked
1343
- databases are used. Will be ignored if the value is an empty string.",
1354
+ databases are used. Will be ignored if the value is an empty string. #{STORECONFIGS_ONLY}",
1344
1355
  },
1345
1356
  :railslog => {
1346
1357
  :default => "$logdir/rails.log",
@@ -1348,14 +1359,14 @@ EOT
1348
1359
  :mode => 0600,
1349
1360
  :owner => "service",
1350
1361
  :group => "service",
1351
- :desc => "Where Rails-specific logs are sent"
1362
+ :desc => "Where Rails-specific logs are sent. #{STORECONFIGS_ONLY}"
1352
1363
  },
1353
1364
 
1354
1365
  :rails_loglevel => {
1355
1366
  :default => "info",
1356
1367
  :desc => "The log level for Rails connections. The value must be
1357
1368
  a valid log level within Rails. Production environments normally use `info`
1358
- and other environments normally use `debug`.",
1369
+ and other environments normally use `debug`. #{STORECONFIGS_ONLY}",
1359
1370
  }
1360
1371
  )
1361
1372
 
@@ -1364,7 +1375,8 @@ EOT
1364
1375
 
1365
1376
  :couchdb_url => {
1366
1377
  :default => "http://127.0.0.1:5984/puppet",
1367
- :desc => "The url where the puppet couchdb database will be created",
1378
+ :desc => "The url where the puppet couchdb database will be created.
1379
+ Only used when `facts_terminus` is set to `couch`.",
1368
1380
  }
1369
1381
  )
1370
1382
 
@@ -1574,7 +1586,8 @@ EOT
1574
1586
  :document_all => {
1575
1587
  :default => false,
1576
1588
  :type => :boolean,
1577
- :desc => "Document all resources",
1589
+ :desc => "Whether to document all resources when using `puppet doc` to
1590
+ generate manifest documentation.",
1578
1591
  }
1579
1592
  )
1580
1593
  end
@@ -34,6 +34,10 @@ class Puppet::Parser::AST
34
34
  self
35
35
  end
36
36
 
37
+ def sequence_with(other)
38
+ Puppet::Parser::AST::BlockExpression.new(:children => self.children + other.children)
39
+ end
40
+
37
41
  def to_s
38
42
  "[" + @children.collect { |c| c.to_s }.join(', ') + "]"
39
43
  end
@@ -7,31 +7,16 @@ class Puppet::Parser::AST
7
7
  include Enumerable
8
8
  attr_accessor :pin, :children
9
9
 
10
- # Yield each contained AST node in turn. Used mostly by 'evaluate'.
11
- # This definition means that I don't have to override 'evaluate'
12
- # every time, but each child of Branch will likely need to override
13
- # this method.
14
10
  def each
15
11
  @children.each { |child|
16
12
  yield child
17
13
  }
18
14
  end
19
15
 
20
- # Initialize our object. Largely relies on the method from the base
21
- # class, but also does some verification.
22
16
  def initialize(arghash)
23
17
  super(arghash)
24
18
 
25
- # Create the hash, if it was not set at initialization time.
26
19
  @children ||= []
27
-
28
- # Verify that we only got valid AST nodes.
29
- @children.each { |child|
30
- unless child.is_a?(AST)
31
- raise Puppet::DevError,
32
- "child #{child} is a #{child.class} instead of ast"
33
- end
34
- }
35
20
  end
36
21
  end
37
22
  end
@@ -11,20 +11,21 @@ Puppet::Parser::Functions::newfunction(
11
11
  This function takes two mandatory arguments: the first should be an Array or a Hash, and the second
12
12
  a parameterized block as produced by the puppet syntax:
13
13
 
14
- $a.collect |$x| { ... }
14
+ $a.collect |$x| { ... }
15
15
 
16
- When the first argument is an Array, the block is called with each entry in turn. When the first argument
16
+ When the first argument `$a` is an Array, the block is called with each entry in turn. When the first argument
17
17
  is a hash the entry is an array with `[key, value]`.
18
18
 
19
19
  *Examples*
20
20
 
21
- # Turns hash into array of values
22
- $a.collect |$x|{ $x[1] }
21
+ # Turns hash into array of values
22
+ $a.collect |$x|{ $x[1] }
23
23
 
24
- # Turns hash into array of keys
25
- $a.collect |$x| { $x[0] }
24
+ # Turns hash into array of keys
25
+ $a.collect |$x| { $x[0] }
26
26
 
27
- Since 3.2
27
+ - Since 3.2
28
+ - requires `parser = future`.
28
29
  ENDHEREDOC
29
30
 
30
31
  receiver = args[0]
@@ -9,23 +9,24 @@ Puppet::Parser::Functions::newfunction(
9
9
  This function takes two mandatory arguments: the first should be an Array or a Hash, and the second
10
10
  a parameterized block as produced by the puppet syntax:
11
11
 
12
- $a.each {|$x| ... }
12
+ $a.each {|$x| ... }
13
13
 
14
14
  When the first argument is an Array, the parameterized block should define one or two block parameters.
15
15
  For each application of the block, the next element from the array is selected, and it is passed to
16
16
  the block if the block has one parameter. If the block has two parameters, the first is the elements
17
17
  index, and the second the value. The index starts from 0.
18
18
 
19
- $a.each {|$index, $value| ... }
19
+ $a.each {|$index, $value| ... }
20
20
 
21
21
  When the first argument is a Hash, the parameterized block should define one or two parameters.
22
22
  When one parameter is defined, the iteration is performed with each entry as an array of `[key, value]`,
23
23
  and when two parameters are defined the iteration is performed with key and value.
24
24
 
25
- $a.each {|$entry| ..."key ${$entry[0]}, value ${$entry[1]}" }
26
- $a.each {|$key, $value| ..."key ${key}, value ${value}" }
25
+ $a.each {|$entry| ..."key ${$entry[0]}, value ${$entry[1]}" }
26
+ $a.each {|$key, $value| ..."key ${key}, value ${value}" }
27
27
 
28
- Since 3.2
28
+ - Since 3.2
29
+ - requires `parser = future`.
29
30
  ENDHEREDOC
30
31
  require 'puppet/parser/ast/lambda'
31
32
 
@@ -9,23 +9,24 @@ Puppet::Parser::Functions::newfunction(
9
9
  This function takes two mandatory arguments: the first should be an Array or a Hash, and the second
10
10
  a parameterized block as produced by the puppet syntax:
11
11
 
12
- $a.foreach {|$x| ... }
12
+ $a.foreach {|$x| ... }
13
13
 
14
14
  When the first argument is an Array, the parameterized block should define one or two block parameters.
15
15
  For each application of the block, the next element from the array is selected, and it is passed to
16
16
  the block if the block has one parameter. If the block has two parameters, the first is the elements
17
17
  index, and the second the value. The index starts from 0.
18
18
 
19
- $a.foreach {|$index, $value| ... }
19
+ $a.foreach {|$index, $value| ... }
20
20
 
21
21
  When the first argument is a Hash, the parameterized block should define one or two parameters.
22
22
  When one parameter is defined, the iteration is performed with each entry as an array of `[key, value]`,
23
23
  and when two parameters are defined the iteration is performed with key and value.
24
24
 
25
- $a.foreach {|$entry| ..."key ${$entry[0]}, value ${$entry[1]}" }
26
- $a.foreach {|$key, $value| ..."key ${key}, value ${value}" }
25
+ $a.foreach {|$entry| ..."key ${$entry[0]}, value ${$entry[1]}" }
26
+ $a.foreach {|$key, $value| ..."key ${key}, value ${value}" }
27
27
 
28
- Since 3.2
28
+ - Since 3.2
29
+ - requires `parser = future`.
29
30
  ENDHEREDOC
30
31
  require 'puppet/parser/ast/lambda'
31
32
 
@@ -9,7 +9,7 @@ Puppet::Parser::Functions::newfunction(
9
9
  This function takes two mandatory arguments: the first should be an Array or a Hash, and the last
10
10
  a parameterized block as produced by the puppet syntax:
11
11
 
12
- $a.reduce |$memo, $x| { ... }
12
+ $a.reduce |$memo, $x| { ... }
13
13
 
14
14
  When the first argument is an Array, the block is called with each entry in turn. When the first argument
15
15
  is a hash each entry is converted to an array with `[key, value]` before being fed to the block. An optional
@@ -24,30 +24,32 @@ Puppet::Parser::Functions::newfunction(
24
24
 
25
25
  *Examples*
26
26
 
27
- # Reduce an array
28
- $a = [1,2,3]
29
- $a.reduce |$memo, $entry| { $memo + $entry }
30
- #=> 6
27
+ # Reduce an array
28
+ $a = [1,2,3]
29
+ $a.reduce |$memo, $entry| { $memo + $entry }
30
+ #=> 6
31
31
 
32
- # Reduce hash values
33
- $a = {a => 1, b => 2, c => 3}
34
- $a.reduce |$memo, $entry| { [sum, $memo[1]+$entry[1]] }
35
- #=> [sum, 6]
32
+ # Reduce hash values
33
+ $a = {a => 1, b => 2, c => 3}
34
+ $a.reduce |$memo, $entry| { [sum, $memo[1]+$entry[1]] }
35
+ #=> [sum, 6]
36
36
 
37
37
  It is possible to provide a starting 'memo' as an argument.
38
38
 
39
39
  *Examples*
40
- # Reduce an array
41
- $a = [1,2,3]
42
- $a.reduce(4) |$memo, $entry| { $memo + $entry }
43
- #=> 10
44
40
 
45
- # Reduce hash values
46
- $a = {a => 1, b => 2, c => 3}
47
- $a.reduce([na, 4]) |$memo, $entry| { [sum, $memo[1]+$entry[1]] }
48
- #=> [sum, 10]
41
+ # Reduce an array
42
+ $a = [1,2,3]
43
+ $a.reduce(4) |$memo, $entry| { $memo + $entry }
44
+ #=> 10
49
45
 
50
- Since 3.2
46
+ # Reduce hash values
47
+ $a = {a => 1, b => 2, c => 3}
48
+ $a.reduce([na, 4]) |$memo, $entry| { [sum, $memo[1]+$entry[1]] }
49
+ #=> [sum, 10]
50
+
51
+ - Since 3.2
52
+ - requires `parser = future`.
51
53
  ENDHEREDOC
52
54
 
53
55
  require 'puppet/parser/ast/lambda'
@@ -11,7 +11,7 @@ Puppet::Parser::Functions::newfunction(
11
11
  This function takes two mandatory arguments: the first should be an Array or a Hash, and the second
12
12
  a parameterized block as produced by the puppet syntax:
13
13
 
14
- $a.reject |$x| { ... }
14
+ $a.reject |$x| { ... }
15
15
 
16
16
  When the first argument is an Array, the block is called with each entry in turn. When the first argument
17
17
  is a hash the entry is an array with `[key, value]`.
@@ -20,11 +20,12 @@ Puppet::Parser::Functions::newfunction(
20
20
 
21
21
  *Examples*
22
22
 
23
- # selects all that does not end with berry
24
- $a = ["rasberry", "blueberry", "orange"]
25
- $a.reject |$x| { $x =~ /berry$/ }
23
+ # selects all that does not end with berry
24
+ $a = ["rasberry", "blueberry", "orange"]
25
+ $a.reject |$x| { $x =~ /berry$/ }
26
26
 
27
- Since 3.2
27
+ - Since 3.2
28
+ - requires `parser = future`.
28
29
  ENDHEREDOC
29
30
 
30
31
  receiver = args[0]
@@ -11,7 +11,7 @@ Puppet::Parser::Functions::newfunction(
11
11
  This function takes two mandatory arguments: the first should be an Array or a Hash, and the second
12
12
  a parameterized block as produced by the puppet syntax:
13
13
 
14
- $a.select |$x| { ... }
14
+ $a.select |$x| { ... }
15
15
 
16
16
  When the first argument is an Array, the block is called with each entry in turn. When the first argument
17
17
  is a hash the entry is an array with `[key, value]`.
@@ -20,11 +20,12 @@ Puppet::Parser::Functions::newfunction(
20
20
 
21
21
  *Examples*
22
22
 
23
- # selects all that end with berry
24
- $a = ["raspberry", "blueberry", "orange"]
25
- $a.select |$x| { $x =~ /berry$/ }
23
+ # selects all that end with berry
24
+ $a = ["raspberry", "blueberry", "orange"]
25
+ $a.select |$x| { $x =~ /berry$/ }
26
26
 
27
- Since 3.2
27
+ - Since 3.2
28
+ - requires `parser = future`.
28
29
  ENDHEREDOC
29
30
 
30
31
  receiver = args[0]
@@ -7,11 +7,11 @@ Puppet::Parser::Functions::newfunction(
7
7
  argument and returns the first argument, or if no block is given returns a new array with a concatenation of
8
8
  the slices.
9
9
 
10
- This function takes two mandatory arguments: the first should be an Array or a Hash, and the second
10
+ This function takes two mandatory arguments: the first, `$a`, should be an Array or a Hash, and the second, `$n`,
11
11
  the number of elements to include in each slice. The optional third argument should be a
12
12
  a parameterized block as produced by the puppet syntax:
13
13
 
14
- |$x| { ... }
14
+ $a.slice($n) |$x| { ... }
15
15
 
16
16
  The parameterized block should have either one parameter (receiving an array with the slice), or the same number
17
17
  of parameters as specified by the slice size (each parameter receiving its part of the slice).
@@ -31,7 +31,8 @@ Puppet::Parser::Functions::newfunction(
31
31
 
32
32
  slice($[1,2,3,4,5,6], 2) # produces [[1,2], [3,4], [5,6]]
33
33
 
34
- Since 3.2
34
+ - Since 3.2
35
+ - requires `parser = future`.
35
36
  ENDHEREDOC
36
37
  require 'puppet/parser/ast/lambda'
37
38
  require 'puppet/parser/scope'
@@ -12,7 +12,9 @@ require 'puppet/util/tagging'
12
12
  # of the information in the catalog, including the resources
13
13
  # and the relationships between them.
14
14
  class Puppet::Resource::Catalog < Puppet::SimpleGraph
15
- class DuplicateResourceError < Puppet::Error; end
15
+ class DuplicateResourceError < Puppet::Error
16
+ include Puppet::ExternalFileError
17
+ end
16
18
 
17
19
  extend Puppet::Indirector
18
20
  indirects :catalog, :terminus_setting => :catalog_terminus
@@ -531,11 +533,11 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
531
533
  # If we've gotten this far, it's a real conflict
532
534
  msg = "Duplicate declaration: #{resource.ref} is already declared"
533
535
 
534
- msg << " in file #{existing_resource.file} at line #{existing_resource.line}" if existing_resource.file and existing_resource.line
536
+ msg << " in file #{existing_resource.file}:#{existing_resource.line}" if existing_resource.file and existing_resource.line
535
537
 
536
- msg << "; cannot redeclare" if resource.line or resource.file
538
+ msg << "; cannot redeclare"
537
539
 
538
- raise DuplicateResourceError.new(msg)
540
+ raise DuplicateResourceError.new(msg, resource.file, resource.line)
539
541
  end
540
542
 
541
543
  # An abstracted method for converting one catalog into another type of catalog.
@@ -191,15 +191,7 @@ class Puppet::Resource::Type
191
191
  return
192
192
  end
193
193
 
194
- self.code = Puppet::Parser::AST::BlockExpression.new(:children => [self.code, other.code])
195
- # array_class = Puppet::Parser::AST::ASTArray
196
- # self.code = array_class.new(:children => [self.code]) unless self.code.is_a?(array_class)
197
- #
198
- # if other.code.is_a?(array_class)
199
- # code.children += other.code.children
200
- # else
201
- # code.children << other.code
202
- # end
194
+ self.code = self.code.sequence_with(other.code)
203
195
  end
204
196
 
205
197
  # Make an instance of the resource type, and place it in the catalog
@@ -2,7 +2,7 @@ module Puppet::Scheduler
2
2
  class Timer
3
3
  def wait_for(seconds)
4
4
  if seconds > 0
5
- select([], [], [], seconds)
5
+ sleep(seconds)
6
6
  end
7
7
  end
8
8