puppet 2.7.18 → 2.7.19

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 (137) hide show
  1. data/CHANGELOG +82 -0
  2. data/CONTRIBUTING.md +114 -171
  3. data/README.md +8 -0
  4. data/README_DEVELOPER.md +38 -3
  5. data/Rakefile +19 -3
  6. data/conf/osx/createpackage.sh +3 -1
  7. data/conf/redhat/logrotate +1 -1
  8. data/conf/redhat/puppet.spec +35 -8
  9. data/lib/puppet.rb +1 -1
  10. data/lib/puppet/application/agent.rb +2 -0
  11. data/lib/puppet/application/master.rb +2 -0
  12. data/lib/puppet/configurer.rb +2 -3
  13. data/lib/puppet/defaults.rb +6 -5
  14. data/lib/puppet/face/module/install.rb +2 -1
  15. data/lib/puppet/file_bucket/dipper.rb +1 -1
  16. data/lib/puppet/indirector/file_content.rb +2 -2
  17. data/lib/puppet/indirector/file_metadata.rb +2 -2
  18. data/lib/puppet/indirector/indirection.rb +3 -4
  19. data/lib/puppet/indirector/rest.rb +12 -6
  20. data/lib/puppet/interface/action_manager.rb +1 -2
  21. data/lib/puppet/module_tool/applications/unpacker.rb +22 -3
  22. data/lib/puppet/network/handler/fileserver.rb +2 -2
  23. data/lib/puppet/parser/ast/resource.rb +9 -2
  24. data/lib/puppet/parser/functions/fqdn_rand.rb +2 -1
  25. data/lib/puppet/parser/functions/md5.rb +2 -2
  26. data/lib/puppet/parser/functions/sha1.rb +2 -2
  27. data/lib/puppet/parser/functions/template.rb +0 -2
  28. data/lib/puppet/parser/type_loader.rb +1 -2
  29. data/lib/puppet/provider/augeas/augeas.rb +19 -1
  30. data/lib/puppet/provider/confine.rb +1 -1
  31. data/lib/puppet/provider/package/msi.rb +97 -51
  32. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -0
  33. data/lib/puppet/provider/service/gentoo.rb +0 -2
  34. data/lib/puppet/provider/service/openrc.rb +69 -0
  35. data/lib/puppet/provider/service/windows.rb +6 -4
  36. data/lib/puppet/provider/user/aix.rb +8 -4
  37. data/lib/puppet/provider/user/useradd.rb +6 -0
  38. data/lib/puppet/rails/benchmark.rb +2 -2
  39. data/lib/puppet/reports/store.rb +9 -9
  40. data/lib/puppet/resource/catalog.rb +2 -1
  41. data/lib/puppet/resource/type_collection.rb +2 -1
  42. data/lib/puppet/ssl/base.rb +1 -2
  43. data/lib/puppet/ssl/certificate_authority/interface.rb +1 -0
  44. data/lib/puppet/test/test_helper.rb +2 -1
  45. data/lib/puppet/type.rb +1 -1
  46. data/lib/puppet/type/augeas.rb +1 -1
  47. data/lib/puppet/type/file.rb +4 -2
  48. data/lib/puppet/type/scheduled_task.rb +8 -10
  49. data/lib/puppet/type/tidy.rb +1 -1
  50. data/lib/puppet/util.rb +63 -25
  51. data/lib/puppet/util/autoload.rb +6 -4
  52. data/lib/puppet/util/checksums.rb +3 -8
  53. data/lib/puppet/util/diff.rb +2 -1
  54. data/lib/puppet/util/filetype.rb +1 -3
  55. data/lib/puppet/util/run_mode.rb +2 -1
  56. data/lib/puppet/util/suidmanager.rb +1 -1
  57. data/lib/puppet/util/windows.rb +1 -0
  58. data/lib/puppet/util/windows/file.rb +27 -0
  59. data/lib/puppet/util/windows/user.rb +1 -2
  60. data/man/man8/puppet-agent.8 +4 -0
  61. data/man/man8/puppet-master.8 +4 -0
  62. data/man/man8/puppetmasterd.8 +4 -0
  63. data/spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug +13 -0
  64. data/spec/fixtures/unit/provider/augeas/augeas/etc/fstab +10 -0
  65. data/spec/fixtures/unit/provider/augeas/augeas/etc/hosts +6 -0
  66. data/spec/fixtures/unit/provider/augeas/augeas/etc/test +3 -0
  67. data/spec/fixtures/unit/provider/augeas/augeas/test.aug +13 -0
  68. data/spec/fixtures/unit/provider/service/openrc/rcservice_list +8 -0
  69. data/spec/fixtures/unit/provider/service/openrc/rcstatus +43 -0
  70. data/spec/integration/defaults_spec.rb +3 -3
  71. data/spec/integration/network/server/mongrel_spec.rb +8 -6
  72. data/spec/integration/parser/parser_spec.rb +1 -1
  73. data/spec/integration/type/file_spec.rb +49 -12
  74. data/spec/lib/puppet_spec/database.rb +5 -3
  75. data/spec/lib/puppet_spec/files.rb +2 -1
  76. data/spec/monkey_patches/alias_should_to_must.rb +15 -2
  77. data/spec/shared_behaviours/file_serving_model.rb +9 -6
  78. data/spec/shared_behaviours/path_parameters.rb +5 -5
  79. data/spec/shared_behaviours/things_that_declare_options.rb +5 -5
  80. data/spec/unit/application/facts_spec.rb +1 -1
  81. data/spec/unit/application_spec.rb +10 -8
  82. data/spec/unit/configurer_spec.rb +11 -2
  83. data/spec/unit/face/ca_spec.rb +15 -15
  84. data/spec/unit/face/help_spec.rb +5 -5
  85. data/spec/unit/face/module/install_spec.rb +13 -2
  86. data/spec/unit/face/node_spec.rb +7 -6
  87. data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -1
  88. data/spec/unit/indirector/envelope_spec.rb +0 -13
  89. data/spec/unit/indirector/facts/inventory_service_spec.rb +1 -1
  90. data/spec/unit/indirector/queue_spec.rb +3 -3
  91. data/spec/unit/indirector/rest_spec.rb +31 -20
  92. data/spec/unit/indirector_spec.rb +5 -5
  93. data/spec/unit/interface/action_builder_spec.rb +3 -2
  94. data/spec/unit/interface/action_manager_spec.rb +1 -1
  95. data/spec/unit/interface/action_spec.rb +4 -3
  96. data/spec/unit/interface/face_collection_spec.rb +1 -1
  97. data/spec/unit/interface/option_spec.rb +13 -9
  98. data/spec/unit/interface_spec.rb +5 -5
  99. data/spec/unit/module_tool/applications/unpacker_spec.rb +61 -0
  100. data/spec/unit/network/handler/fileserver_spec.rb +3 -3
  101. data/spec/unit/other/transbucket_spec.rb +6 -9
  102. data/spec/unit/parser/ast/resource_spec.rb +27 -0
  103. data/spec/unit/parser/functions/create_resources_spec.rb +12 -12
  104. data/spec/unit/parser/lexer_spec.rb +5 -5
  105. data/spec/unit/provider/augeas/augeas_spec.rb +78 -0
  106. data/spec/unit/provider/nameservice/directoryservice_spec.rb +6 -6
  107. data/spec/unit/provider/package/freebsd_spec.rb +2 -2
  108. data/spec/unit/provider/package/msi_spec.rb +181 -114
  109. data/spec/unit/provider/package/openbsd_spec.rb +1 -0
  110. data/spec/unit/provider/package/pkgdmg_spec.rb +3 -3
  111. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1 -1
  112. data/spec/unit/provider/service/openrc_spec.rb +209 -0
  113. data/spec/unit/provider/service/windows_spec.rb +57 -59
  114. data/spec/unit/provider/user/useradd_spec.rb +7 -0
  115. data/spec/unit/reports/store_spec.rb +13 -13
  116. data/spec/unit/resource/catalog_spec.rb +29 -24
  117. data/spec/unit/resource_spec.rb +13 -13
  118. data/spec/unit/simple_graph_spec.rb +12 -12
  119. data/spec/unit/ssl/certificate_authority/interface_spec.rb +3 -3
  120. data/spec/unit/ssl/certificate_authority_spec.rb +11 -10
  121. data/spec/unit/transaction_spec.rb +3 -3
  122. data/spec/unit/type/cron_spec.rb +171 -171
  123. data/spec/unit/type/exec_spec.rb +29 -27
  124. data/spec/unit/type/file_spec.rb +22 -13
  125. data/spec/unit/type/interface_spec.rb +1 -1
  126. data/spec/unit/type/scheduled_task_spec.rb +15 -14
  127. data/spec/unit/type/tidy_spec.rb +2 -2
  128. data/spec/unit/type/user_spec.rb +15 -15
  129. data/spec/unit/type/vlan_spec.rb +1 -1
  130. data/spec/unit/type_spec.rb +22 -25
  131. data/spec/unit/util/autoload_spec.rb +13 -7
  132. data/spec/unit/util/backups_spec.rb +36 -67
  133. data/spec/unit/util/storage_spec.rb +2 -9
  134. data/spec/unit/util/suidmanager_spec.rb +1 -1
  135. data/spec/unit/util_spec.rb +20 -28
  136. data/test/ral/manager/attributes.rb +1 -1
  137. metadata +1553 -1542
data/Rakefile CHANGED
@@ -2,14 +2,30 @@
2
2
 
3
3
  $LOAD_PATH << File.join(File.dirname(__FILE__), 'tasks')
4
4
 
5
+ begin
6
+ require 'rubygems'
7
+ require 'rubygems/package_task'
8
+ rescue LoadError
9
+ # Users of older versions of Rake (0.8.7 for example) will not necessarily
10
+ # have rubygems installed, or the newer rubygems package_task for that
11
+ # matter.
12
+ require 'rake/packagetask'
13
+ require 'rake/gempackagetask'
14
+ end
15
+
5
16
  require 'rake'
6
- require 'rake/packagetask'
7
- require 'rake/gempackagetask'
8
17
  require 'rspec'
9
18
  require "rspec/core/rake_task"
10
19
 
20
+
11
21
  module Puppet
12
- PUPPETVERSION = File.read('lib/puppet.rb')[/PUPPETVERSION *= *'(.*)'/,1] or fail "Couldn't find PUPPETVERSION"
22
+ %x{which git &> /dev/null}
23
+ if $?.success? and File.exist?('.git')
24
+ # remove the git hash from git describe string
25
+ PUPPETVERSION=%x{git describe}.chomp.gsub('-','.').split('.')[0..3].join('.')
26
+ else
27
+ PUPPETVERSION=File.read('lib/puppet.rb')[/PUPPETVERSION *= *'(.*)'/,1] or fail "Couldn't find PUPPETVERSION"
28
+ end
13
29
  end
14
30
 
15
31
  Dir['tasks/**/*.rake'].each { |t| load t }
@@ -53,6 +53,7 @@ function install_puppet() {
53
53
  "${installer}" --destdir="${pkgroot}" --bindir="${BINDIR}" --sbindir="${SBINDIR}" --sitelibdir="${SITELIBDIR}"
54
54
  mkdir -p ${pkgroot}/var/lib/puppet
55
55
  chown -R root:admin "${pkgroot}"
56
+ chmod -R go-w "${pkgroot}"
56
57
  }
57
58
 
58
59
  function install_docs() {
@@ -107,7 +108,8 @@ function create_package() {
107
108
  rm -fr "$(pwd)/puppet-${puppet_version}.pkg"
108
109
  echo "Building package"
109
110
  echo "Note that packagemaker is reknowned for spurious errors. Don't panic."
110
- "${PACKAGEMAKER}" --root "${pkgroot}" \
111
+ "${PACKAGEMAKER}" --verbose --no-recommend --no-relocate \
112
+ --root "${pkgroot}" \
111
113
  --info "${pkgtemp}/${PROTO_PLIST}" \
112
114
  --scripts ${pkgtemp}/scripts \
113
115
  --out "$(pwd)/puppet-${puppet_version}.pkg"
@@ -4,7 +4,7 @@
4
4
  create 0644 puppet puppet
5
5
  sharedscripts
6
6
  postrotate
7
- [ -e /etc/init.d/puppetmaster ] && /etc/init.d/puppetmaster condrestart >/dev/null 2>&1 || true
7
+ pkill -USR2 -u puppet -f /usr/sbin/puppetmasterd || true
8
8
  [ -e /etc/init.d/puppet ] && /etc/init.d/puppet reload > /dev/null 2>&1 || true
9
9
  endscript
10
10
  }
@@ -1,20 +1,28 @@
1
1
  # Augeas and SELinux requirements may be disabled at build time by passing
2
2
  # --without augeas and/or --without selinux to rpmbuild or mock
3
3
 
4
- %{!?ruby_sitelibdir: %global ruby_sitelibdir %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')}
4
+ # Fedora 17 ships with Ruby 1.9, which uses vendorlibdir instead of
5
+ # sitelibdir. Adjust our target if installing on f17.
6
+ %if 0%{?fedora} >= 17
7
+ %global puppet_libdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendorlibdir"]')
8
+ %else
9
+ %global puppet_libdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]')
10
+ %endif
11
+
5
12
  %global confdir conf/redhat
6
13
 
7
14
  Name: puppet
8
- Version: 2.7.18
9
- #Release: 0.1rc1.2%{?dist}
15
+ Version: 2.7.19
16
+ #Release: 0.1rc3%{?dist}
10
17
  Release: 1%{?dist}
18
+ Vendor: %{?_host_vendor}
11
19
  Summary: A network tool for managing many disparate systems
12
20
  License: ASL 2.0
13
21
  URL: http://puppetlabs.com
14
22
  Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz
15
- #Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz
23
+ #Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc3.tar.gz
16
24
  Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz.asc
17
- #Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz.asc
25
+ #Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc3.tar.gz.asc
18
26
 
19
27
  Group: System Environment/Base
20
28
 
@@ -67,7 +75,7 @@ The server can also function as a certificate authority and file server.
67
75
 
68
76
  %prep
69
77
  %setup -q -n %{name}-%{version}
70
- #%setup -q -n %{name}-%{version}rc1
78
+ #%setup -q -n %{name}-%{version}rc3
71
79
  patch -s -p1 < conf/redhat/rundir-perms.patch
72
80
 
73
81
 
@@ -91,7 +99,7 @@ mv conf/puppet-queue.conf examples/etc/puppet/
91
99
 
92
100
  %install
93
101
  rm -rf %{buildroot}
94
- ruby install.rb --destdir=%{buildroot} --quick --no-rdoc
102
+ ruby install.rb --destdir=%{buildroot} --quick --no-rdoc --sitelibdir=%{puppet_libdir}
95
103
 
96
104
  install -d -m0755 %{buildroot}%{_sysconfdir}/puppet/manifests
97
105
  install -d -m0755 %{buildroot}%{_datadir}/%{name}/modules
@@ -136,6 +144,9 @@ echo "D /var/run/%{name} 0755 %{name} %{name} -" > \
136
144
  %{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf
137
145
  %endif
138
146
 
147
+ # Create puppet modules directory for puppet module tool
148
+ mkdir -p %{buildroot}%{_sysconfdir}/%{name}/modules
149
+
139
150
  %files
140
151
  %defattr(-, root, root, 0755)
141
152
  %doc CHANGELOG LICENSE README.md examples
@@ -146,9 +157,10 @@ echo "D /var/run/%{name} 0755 %{name} %{name} -" > \
146
157
  %{_bindir}/puppetdoc
147
158
  %{_sbindir}/puppetca
148
159
  %{_sbindir}/puppetd
149
- %{ruby_sitelibdir}/*
160
+ %{puppet_libdir}/*
150
161
  %{_initrddir}/puppet
151
162
  %dir %{_sysconfdir}/puppet
163
+ %dir %{_sysconfdir}/%{name}/modules
152
164
  %if 0%{?fedora} >= 15
153
165
  %config(noreplace) %{_sysconfdir}/tmpfiles.d/%{name}.conf
154
166
  %endif
@@ -289,6 +301,21 @@ fi
289
301
  rm -rf %{buildroot}
290
302
 
291
303
  %changelog
304
+ * Tue Aug 21 2012 Moses Mendoza <moses@puppetlabs.com> - 2.7.19-1
305
+ - Update for 2.7.19
306
+
307
+ * Tue Aug 14 2012 Moses Mendoza <moses@puppetlabs.com> - 2.7.19-0.1rc3
308
+ - Update for 2.7.19rc3
309
+
310
+ * Tue Aug 7 2012 Moses Mendoza <moses@puppetlabs.com> - 2.7.19-0.1rc2
311
+ - Update for 2.7.19rc2
312
+
313
+ * Wed Aug 1 2012 Moses Mendoza <moses@puppetlabs.com> - 2.7.19-0.1rc1
314
+ - Update for 2.7.19rc1
315
+
316
+ * Wed Jul 11 2012 William Hopper <whopper@puppetlabs.com> - 2.7.18-2
317
+ - (#15221) Create /etc/puppet/modules for puppet module tool
318
+
292
319
  * Mon Jul 9 2012 Moses Mendoza <moses@puppetlabs.com> - 2.7.18-1
293
320
  - Update for 2.7.18
294
321
 
data/lib/puppet.rb CHANGED
@@ -24,7 +24,7 @@ require 'puppet/util/run_mode'
24
24
  # it's also a place to find top-level commands like 'debug'
25
25
 
26
26
  module Puppet
27
- PUPPETVERSION = '2.7.18'
27
+ PUPPETVERSION = '2.7.19'
28
28
 
29
29
  def Puppet.version
30
30
  PUPPETVERSION
@@ -293,6 +293,8 @@ Puppet agent accepts the following signals:
293
293
  Shut down the puppet agent daemon.
294
294
  * SIGUSR1:
295
295
  Immediately retrieve and apply configurations from the puppet master.
296
+ * SIGUSR2:
297
+ Close file descriptors for log files and reopen them. Used with logrotate.
296
298
 
297
299
  AUTHOR
298
300
  ------
@@ -112,6 +112,8 @@ following signals:
112
112
  Restart the puppet master server.
113
113
  * SIGINT and SIGTERM:
114
114
  Shut down the puppet master server.
115
+ * SIGUSR2:
116
+ Close file descriptors for log files and reopen them. Used with logrotate.
115
117
 
116
118
  AUTHOR
117
119
  ------
@@ -180,9 +180,8 @@ class Puppet::Configurer
180
180
 
181
181
  def save_last_run_summary(report)
182
182
  mode = Puppet.settings.setting(:lastrunfile).mode
183
- Puppet::Util::FileLocking.writelock(Puppet[:lastrunfile]) do |file|
184
- file.chmod(mode)
185
- file.print YAML.dump(report.raw_summary)
183
+ Puppet::Util.replace_file(Puppet[:lastrunfile], mode) do |fh|
184
+ fh.print YAML.dump(report.raw_summary)
186
185
  end
187
186
  rescue => detail
188
187
  puts detail.backtrace if Puppet[:trace]
@@ -180,9 +180,10 @@ module Puppet
180
180
  end
181
181
  },
182
182
  :thin_storeconfigs => {:default => false, :desc =>
183
- "Boolean; wether storeconfigs store in the database only the facts and exported resources.
184
- If true, then storeconfigs performance will be higher and still allow exported/collected
185
- resources, but other usage external to Puppet might not work",
183
+ "Boolean; whether Puppet should store only facts and exported resources in the storeconfigs
184
+ database. This will improve the performance of exported resources with the older
185
+ `active_record` backend, but will disable external tools that search the storeconfigs database.
186
+ Thinning catalogs is generally unnecessary when using PuppetDB to store catalogs.",
186
187
  :hook => proc do |value|
187
188
  Puppet.settings[:storeconfigs] = true if value
188
189
  end
@@ -505,7 +506,7 @@ EOT
505
506
  rest indirections. This can be used as a fine-grained
506
507
  authorization system for `puppet master`."
507
508
  ],
508
- :ca => [true, "Wether the master should function as a certificate authority."],
509
+ :ca => [true, "Whether the master should function as a certificate authority."],
509
510
  :modulepath => {
510
511
  :default => "$confdir/modules#{File::PATH_SEPARATOR}/usr/share/puppet/modules",
511
512
  :desc => "The search path for modules, as a list of directories separated by the system path separator character. (The POSIX path separator is ':', and the Windows path separator is ';'.)",
@@ -713,7 +714,7 @@ EOT
713
714
  "Whether to send reports after every transaction."
714
715
  ],
715
716
  :lastrunfile => { :default => "$statedir/last_run_summary.yaml",
716
- :mode => 0640,
717
+ :mode => 0644,
717
718
  :desc => "Where puppet agent stores the last run report summary in yaml format."
718
719
  },
719
720
  :lastrunreport => { :default => "$statedir/last_run_report.yaml",
@@ -147,13 +147,14 @@ Puppet::Face.define(:module, '1.0.0') do
147
147
 
148
148
  when_invoked do |name, options|
149
149
  sep = File::PATH_SEPARATOR
150
+
150
151
  if options[:target_dir]
151
- options[:target_dir] = File.expand_path(options[:target_dir])
152
152
  options[:modulepath] = "#{options[:target_dir]}#{sep}#{options[:modulepath]}"
153
153
  end
154
154
 
155
155
  Puppet.settings[:modulepath] = options[:modulepath]
156
156
  options[:target_dir] = Puppet.settings[:modulepath].split(sep).first
157
+ options[:target_dir] = File.expand_path(options[:target_dir])
157
158
 
158
159
  Puppet.notice "Preparing to install into #{options[:target_dir]} ..."
159
160
  Puppet::ModuleTool::Applications::Installer.run(name, options)
@@ -1,3 +1,4 @@
1
+ require 'pathname'
1
2
  require 'puppet/file_bucket'
2
3
  require 'puppet/file_bucket/file'
3
4
  require 'puppet/indirector/request'
@@ -99,7 +100,6 @@ class Puppet::FileBucket::Dipper
99
100
 
100
101
  private
101
102
  def absolutize_path( path )
102
- require 'pathname'
103
103
  Pathname.new(path).realpath
104
104
  end
105
105
 
@@ -1,5 +1,5 @@
1
- require 'puppet/file_serving/content'
2
-
3
1
  # A stub class, so our constants work.
4
2
  class Puppet::Indirector::FileContent # :nodoc:
5
3
  end
4
+
5
+ require 'puppet/file_serving/content'
@@ -1,5 +1,5 @@
1
- require 'puppet/file_serving/metadata'
2
-
3
1
  # A stub class, so our constants work.
4
2
  class Puppet::Indirector::FileMetadata # :nodoc:
5
3
  end
4
+
5
+ require 'puppet/file_serving/metadata'
@@ -10,6 +10,9 @@ class Puppet::Indirector::Indirection
10
10
  include Puppet::Util::Docs
11
11
  extend Puppet::Util::Instrumentation::Instrumentable
12
12
 
13
+ attr_accessor :name, :model
14
+ attr_reader :termini
15
+
13
16
  probe :find, :label => Proc.new { |parent, key, *args| "find_#{parent.name}_#{parent.terminus_class}" }, :data => Proc.new { |parent, key, *args| { :key => key }}
14
17
  probe :save, :label => Proc.new { |parent, key, *args| "save_#{parent.name}_#{parent.terminus_class}" }, :data => Proc.new { |parent, key, *args| { :key => key }}
15
18
  probe :search, :label => Proc.new { |parent, key, *args| "search_#{parent.name}_#{parent.terminus_class}" }, :data => Proc.new { |parent, key, *args| { :key => key }}
@@ -36,10 +39,6 @@ class Puppet::Indirector::Indirection
36
39
  match.model
37
40
  end
38
41
 
39
- attr_accessor :name, :model
40
-
41
- attr_reader :termini
42
-
43
42
  # Create and return our cache terminus.
44
43
  def cache
45
44
  raise(Puppet::DevError, "Tried to cache when no cache class was set") unless cache_class
@@ -80,21 +80,27 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
80
80
  def http_request(method, request, *args)
81
81
  http_connection = network(request)
82
82
  peer_certs = []
83
+ verify_errors = []
83
84
 
84
- # We add the callback to collect the certificates for use in constructing
85
- # the error message if the verification failed. This is necessary since we
86
- # don't have direct access to the cert that we expected the connection to
87
- # use otherwise.
88
- #
89
85
  http_connection.verify_callback = proc do |preverify_ok, ssl_context|
86
+ # We use the callback to collect the certificates for use in constructing
87
+ # the error message if the verification failed. This is necessary since we
88
+ # don't have direct access to the cert that we expected the connection to
89
+ # use otherwise.
90
90
  peer_certs << Puppet::SSL::Certificate.from_s(ssl_context.current_cert.to_pem)
91
+ # And also keep the detailed verification error if such an error occurs
92
+ if ssl_context.error_string and not preverify_ok
93
+ verify_errors << "#{ssl_context.error_string} for #{ssl_context.current_cert.subject}"
94
+ end
91
95
  preverify_ok
92
96
  end
93
97
 
94
98
  http_connection.send(method, *args)
95
99
  rescue OpenSSL::SSL::SSLError => error
96
100
  if error.message.include? "certificate verify failed"
97
- raise Puppet::Error, "#{error.message}. This is often because the time is out of sync on the server or client"
101
+ msg = error.message
102
+ msg << ": [" + verify_errors.join('; ') + "]"
103
+ raise Puppet::Error, msg
98
104
  elsif error.message =~ /hostname (was )?not match/
99
105
  raise unless cert = peer_certs.find { |c| c.name !~ /^puppet ca/i }
100
106
 
@@ -1,11 +1,10 @@
1
1
  require 'puppet/interface/action'
2
+ require 'puppet/interface/action_builder'
2
3
 
3
4
  module Puppet::Interface::ActionManager
4
5
  # Declare that this app can take a specific action, and provide
5
6
  # the code to do so.
6
7
  def action(name, &block)
7
- require 'puppet/interface/action_builder'
8
-
9
8
  @actions ||= {}
10
9
  raise "Action #{name} already defined for #{self}" if action?(name)
11
10
 
@@ -21,16 +21,35 @@ module Puppet::ModuleTool
21
21
  @module_dir
22
22
  end
23
23
 
24
+ # Obtain a suitable temporary path for building and unpacking tarballs
25
+ #
26
+ # @return [Pathname] path to temporary build location
27
+ def build_dir
28
+ Puppet::Forge::Cache.base_path + "tmp-unpacker-#{Digest::SHA1.hexdigest(@filename.basename.to_s)}"
29
+ end
30
+
24
31
  private
25
32
  def extract_module_to_install_dir
26
33
  delete_existing_installation_or_abort!
27
34
 
28
- build_dir = Puppet::Forge::Cache.base_path + "tmp-unpacker-#{Digest::SHA1.hexdigest(@filename.basename.to_s)}"
29
35
  build_dir.mkpath
30
36
  begin
31
- unless system "tar xzf #{@filename} -C #{build_dir}"
32
- raise RuntimeError, "Could not extract contents of module archive."
37
+ begin
38
+ if Facter.value('operatingsystem') == "Solaris"
39
+ # Solaris tar is not as safe and works differently, so we prefer
40
+ # gnutar instead.
41
+ if Puppet::Util.which('gtar')
42
+ Puppet::Util.execute("gtar xzf #{@filename} -C #{build_dir}")
43
+ else
44
+ raise RuntimeError, "Cannot find the command 'gtar'. Make sure GNU tar is installed, and is in your PATH."
45
+ end
46
+ else
47
+ Puppet::Util.execute("tar xzf #{@filename} -C #{build_dir}")
48
+ end
49
+ rescue Puppet::ExecutionFailure => e
50
+ raise RuntimeError, "Could not extract contents of module archive: #{e.message}"
33
51
  end
52
+
34
53
  # grab the first directory
35
54
  extracted = build_dir.children.detect { |c| c.directory? }
36
55
  FileUtils.mv extracted, @module_dir
@@ -645,9 +645,9 @@ class Puppet::Network::Handler
645
645
  nil
646
646
  end
647
647
 
648
+ require 'puppet/file_serving'
649
+ require 'puppet/file_serving/fileset'
648
650
  def reclist(abspath, recurse, ignore)
649
- require 'puppet/file_serving'
650
- require 'puppet/file_serving/fileset'
651
651
  if recurse.is_a?(Fixnum)
652
652
  args = { :recurse => true, :recurselimit => recurse, :links => :follow }
653
653
  else
@@ -32,14 +32,21 @@ class Resource < AST::Branch
32
32
  resource_titles = instance.title.safeevaluate(scope)
33
33
 
34
34
  # it's easier to always use an array, even for only one name
35
- resource_titles = [resource_titles] unless resource_titles.is_a?(Array)
35
+ resource_titles = [resource_titles].flatten.collect do |title|
36
+ case title
37
+ when ::String, ::Numeric, ::Symbol, true, false
38
+ title.to_s
39
+ else
40
+ raise Puppet::ParseError, "Resource title must be a String, not #{title.class}"
41
+ end
42
+ end
36
43
 
37
44
  fully_qualified_type, resource_titles = scope.resolve_type_and_titles(type, resource_titles)
38
45
 
39
46
  # Second level of implicit iteration; build a resource for each
40
47
  # title. This handles things like:
41
48
  # file { ['/foo', '/bar']: owner => blah }
42
- resource_titles.flatten.collect { |resource_title|
49
+ resource_titles.collect { |resource_title|
43
50
  exceptwrap :type => Puppet::ParseError do
44
51
  resource = Puppet::Parser::Resource.new(
45
52
  fully_qualified_type, resource_title,
@@ -1,3 +1,5 @@
1
+ require 'digest/md5'
2
+
1
3
  Puppet::Parser::Functions::newfunction(:fqdn_rand, :type => :rvalue, :doc =>
2
4
  "Generates random numbers based on the node's fqdn. Generated random values
3
5
  will be a range from 0 up to and excluding n, where n is the first parameter.
@@ -5,7 +7,6 @@ Puppet::Parser::Functions::newfunction(:fqdn_rand, :type => :rvalue, :doc =>
5
7
 
6
8
  $random_number = fqdn_rand(30)
7
9
  $random_number_seed = fqdn_rand(30,30)") do |args|
8
- require 'digest/md5'
9
10
  max = args.shift
10
11
  srand(Digest::MD5.hexdigest([lookupvar('::fqdn'),args].join(':')).hex)
11
12
  rand(max).to_s
@@ -1,5 +1,5 @@
1
- Puppet::Parser::Functions::newfunction(:md5, :type => :rvalue, :doc => "Returns a MD5 hash value from a provided string.") do |args|
2
- require 'md5'
1
+ require 'digest/md5'
3
2
 
3
+ Puppet::Parser::Functions::newfunction(:md5, :type => :rvalue, :doc => "Returns a MD5 hash value from a provided string.") do |args|
4
4
  Digest::MD5.hexdigest(args[0])
5
5
  end