puppet 0.25.1 → 0.25.2

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 (198) hide show
  1. data/CHANGELOG +159 -135
  2. data/Rakefile +4 -1
  3. data/conf/gentoo/conf.d/puppetmaster +1 -1
  4. data/conf/osx/createpackage.sh +12 -0
  5. data/conf/osx/preflight +4 -0
  6. data/conf/redhat/puppet.spec +12 -2
  7. data/conf/redhat/server.init +1 -0
  8. data/conf/redhat/server.sysconfig +1 -1
  9. data/ext/ldap/puppet.schema +5 -9
  10. data/ext/puppetlast +2 -1
  11. data/ext/rack/README +2 -2
  12. data/ext/regexp_nodes/classes/databases +2 -0
  13. data/ext/regexp_nodes/classes/webservers +2 -0
  14. data/ext/regexp_nodes/parameters/environment/prod +1 -0
  15. data/ext/regexp_nodes/parameters/environment/qa +3 -0
  16. data/ext/regexp_nodes/regexp_nodes.rb +215 -0
  17. data/lib/puppet.rb +1 -1
  18. data/lib/puppet/agent.rb +2 -2
  19. data/lib/puppet/application/puppet.rb +1 -1
  20. data/lib/puppet/application/puppetd.rb +1 -1
  21. data/lib/puppet/application/puppetdoc.rb +4 -3
  22. data/lib/puppet/application/puppetrun.rb +5 -14
  23. data/lib/puppet/application/ralsh.rb +9 -25
  24. data/lib/puppet/configurer.rb +2 -1
  25. data/lib/puppet/configurer/fact_handler.rb +8 -6
  26. data/lib/puppet/daemon.rb +2 -2
  27. data/lib/puppet/defaults.rb +21 -2
  28. data/lib/puppet/external/pson/common.rb +1 -1
  29. data/lib/puppet/external/pson/pure.rb +3 -3
  30. data/lib/puppet/feature/base.rb +3 -0
  31. data/lib/puppet/feature/selinux.rb +3 -0
  32. data/lib/puppet/feature/zlib.rb +6 -0
  33. data/lib/puppet/file_serving/base.rb +16 -1
  34. data/lib/puppet/file_serving/metadata.rb +46 -9
  35. data/lib/puppet/file_serving/mount/file.rb +4 -1
  36. data/lib/puppet/indirector/catalog/active_record.rb +5 -0
  37. data/lib/puppet/indirector/envelope.rb +1 -3
  38. data/lib/puppet/indirector/indirection.rb +13 -16
  39. data/lib/puppet/indirector/node/ldap.rb +7 -4
  40. data/lib/puppet/indirector/ssl_file.rb +1 -1
  41. data/lib/puppet/network/authstore.rb +48 -118
  42. data/lib/puppet/network/client/resource.rb +2 -15
  43. data/lib/puppet/network/format.rb +2 -12
  44. data/lib/puppet/network/format_handler.rb +15 -1
  45. data/lib/puppet/network/formats.rb +19 -4
  46. data/lib/puppet/network/handler/fileserver.rb +1 -0
  47. data/lib/puppet/network/http/handler.rb +1 -0
  48. data/lib/puppet/network/http/rack/httphandler.rb +0 -18
  49. data/lib/puppet/network/http/rack/rest.rb +4 -4
  50. data/lib/puppet/network/http/rack/xmlrpc.rb +4 -4
  51. data/lib/puppet/network/http/webrick.rb +2 -1
  52. data/lib/puppet/network/server.rb +1 -1
  53. data/lib/puppet/node/environment.rb +20 -9
  54. data/lib/puppet/parameter.rb +17 -1
  55. data/lib/puppet/parser/ast/boolean_operator.rb +2 -2
  56. data/lib/puppet/parser/ast/leaf.rb +5 -1
  57. data/lib/puppet/parser/ast/resourceparam.rb +4 -0
  58. data/lib/puppet/parser/ast/selector.rb +4 -0
  59. data/lib/puppet/parser/functions/generate.rb +2 -2
  60. data/lib/puppet/parser/functions/shellquote.rb +1 -1
  61. data/lib/puppet/property.rb +3 -11
  62. data/lib/puppet/provider/cron/crontab.rb +2 -0
  63. data/lib/puppet/provider/host/parsed.rb +9 -9
  64. data/lib/puppet/provider/package/blastwave.rb +7 -6
  65. data/lib/puppet/provider/package/portage.rb +23 -27
  66. data/lib/puppet/provider/package/rug.rb +1 -1
  67. data/lib/puppet/provider/package/sun.rb +5 -3
  68. data/lib/puppet/provider/service/daemontools.rb +1 -1
  69. data/lib/puppet/provider/service/debian.rb +1 -1
  70. data/lib/puppet/provider/service/runit.rb +1 -1
  71. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -1
  72. data/lib/puppet/provider/sshkey/parsed.rb +3 -5
  73. data/lib/puppet/provider/zone/solaris.rb +1 -1
  74. data/lib/puppet/rails.rb +9 -2
  75. data/lib/puppet/rails/benchmark.rb +1 -1
  76. data/lib/puppet/rails/host.rb +2 -7
  77. data/lib/puppet/rails/resource.rb +20 -26
  78. data/lib/puppet/resource/catalog.rb +3 -3
  79. data/lib/puppet/resource/reference.rb +13 -25
  80. data/lib/puppet/ssl/certificate.rb +3 -2
  81. data/lib/puppet/ssl/host.rb +14 -33
  82. data/lib/puppet/sslcertificates.rb +1 -5
  83. data/lib/puppet/sslcertificates/ca.rb +8 -7
  84. data/lib/puppet/transaction.rb +15 -12
  85. data/lib/puppet/type.rb +12 -5
  86. data/lib/puppet/type/file.rb +26 -32
  87. data/lib/puppet/type/file/content.rb +5 -5
  88. data/lib/puppet/type/file/ensure.rb +6 -17
  89. data/lib/puppet/type/file/mode.rb +18 -1
  90. data/lib/puppet/type/file/source.rb +12 -12
  91. data/lib/puppet/type/host.rb +6 -9
  92. data/lib/puppet/type/k5login.rb +1 -1
  93. data/lib/puppet/type/maillist.rb +4 -7
  94. data/lib/puppet/type/port.rb +6 -5
  95. data/lib/puppet/type/resources.rb +12 -12
  96. data/lib/puppet/type/sshkey.rb +5 -5
  97. data/lib/puppet/type/tidy.rb +9 -2
  98. data/lib/puppet/type/yumrepo.rb +3 -1
  99. data/lib/puppet/util.rb +64 -56
  100. data/lib/puppet/util/backups.rb +2 -1
  101. data/lib/puppet/util/filetype.rb +46 -0
  102. data/lib/puppet/util/log.rb +10 -18
  103. data/lib/puppet/util/log_paths.rb +14 -0
  104. data/lib/puppet/util/methodhelper.rb +3 -4
  105. data/lib/puppet/util/monkey_patches.rb +8 -0
  106. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -3
  107. data/lib/puppet/util/rdoc/parser.rb +32 -16
  108. data/lib/puppet/util/reference.rb +6 -3
  109. data/lib/puppet/util/selinux.rb +21 -14
  110. data/lib/puppet/util/settings.rb +30 -25
  111. data/lib/puppet/util/settings/file_setting.rb +7 -4
  112. data/lib/puppet/util/subclass_loader.rb +1 -1
  113. data/lib/puppet/util/suidmanager.rb +11 -1
  114. data/lib/puppet/util/tagging.rb +22 -4
  115. data/man/man8/filebucket.8 +23 -18
  116. data/man/man8/pi.8 +42 -20
  117. data/man/man8/puppet.8 +47 -32
  118. data/man/man8/puppet.conf.8 +807 -764
  119. data/man/man8/puppetca.8 +24 -14
  120. data/man/man8/puppetd.8 +33 -16
  121. data/man/man8/puppetdoc.8 +71 -18
  122. data/man/man8/puppetmasterd.8 +18 -25
  123. data/man/man8/puppetqd.8 +60 -0
  124. data/man/man8/puppetrun.8 +27 -14
  125. data/man/man8/ralsh.8 +33 -40
  126. data/spec/integration/bin/puppetmasterd.rb +3 -2
  127. data/spec/integration/defaults.rb +11 -0
  128. data/spec/integration/file_serving/metadata.rb +1 -0
  129. data/spec/integration/indirector/file_content/file_server.rb +2 -1
  130. data/spec/integration/ssl/certificate_request.rb +2 -0
  131. data/spec/integration/type/file.rb +20 -1
  132. data/spec/shared_behaviours/file_serving.rb +1 -1
  133. data/spec/spec_helper.rb +1 -1
  134. data/spec/unit/application/puppet.rb +11 -30
  135. data/spec/unit/application/puppetd.rb +1 -0
  136. data/spec/unit/application/puppetdoc.rb +13 -4
  137. data/spec/unit/application/puppetmasterd.rb +1 -0
  138. data/spec/unit/application/puppetrun.rb +12 -2
  139. data/spec/unit/application/ralsh.rb +39 -22
  140. data/spec/unit/configurer.rb +6 -0
  141. data/spec/unit/configurer/fact_handler.rb +15 -1
  142. data/spec/unit/file_serving/metadata.rb +128 -16
  143. data/spec/unit/file_serving/mount/file.rb +8 -0
  144. data/spec/unit/indirector/catalog/active_record.rb +20 -1
  145. data/spec/unit/indirector/catalog/compiler.rb +2 -1
  146. data/spec/unit/indirector/indirection.rb +29 -18
  147. data/spec/unit/indirector/node/ldap.rb +20 -6
  148. data/spec/unit/network/authstore.rb +197 -0
  149. data/spec/unit/network/format_handler.rb +28 -8
  150. data/spec/unit/network/formats.rb +31 -0
  151. data/spec/unit/network/http/handler.rb +10 -0
  152. data/spec/unit/network/http/webrick.rb +2 -2
  153. data/spec/unit/network/rest_authconfig.rb +2 -2
  154. data/spec/unit/network/rights.rb +1 -1
  155. data/spec/unit/node/environment.rb +39 -23
  156. data/spec/unit/other/selinux.rb +2 -2
  157. data/spec/unit/parameter.rb +8 -0
  158. data/spec/unit/parser/ast/leaf.rb +9 -0
  159. data/spec/unit/parser/ast/selector.rb +8 -1
  160. data/spec/unit/parser/lexer.rb +1 -1
  161. data/spec/unit/parser/resource.rb +11 -0
  162. data/spec/unit/parser/resource/reference.rb +13 -1
  163. data/spec/unit/property.rb +6 -0
  164. data/spec/unit/provider/mount/parsed.rb +3 -1
  165. data/spec/unit/provider/service/debian.rb +1 -1
  166. data/spec/unit/provider/ssh_authorized_key/parsed.rb +9 -1
  167. data/spec/unit/provider/sshkey/parsed.rb +19 -0
  168. data/spec/unit/rails.rb +22 -9
  169. data/spec/unit/rails/resource.rb +20 -0
  170. data/spec/unit/ssl/host.rb +19 -57
  171. data/spec/unit/transaction.rb +39 -4
  172. data/spec/unit/type.rb +9 -0
  173. data/spec/unit/type/file/content.rb +29 -0
  174. data/spec/unit/type/maillist.rb +42 -0
  175. data/spec/unit/type/resources.rb +66 -1
  176. data/spec/unit/type/tidy.rb +14 -1
  177. data/spec/unit/util/autoload.rb +2 -0
  178. data/spec/unit/util/ldap/connection.rb +1 -1
  179. data/spec/unit/util/log.rb +14 -0
  180. data/spec/unit/util/monkey_patches.rb +103 -0
  181. data/spec/unit/util/queue.rb +10 -2
  182. data/spec/unit/util/selinux.rb +61 -2
  183. data/spec/unit/util/settings.rb +19 -0
  184. data/spec/unit/util/settings/file_setting.rb +25 -0
  185. data/spec/unit/util/tagging.rb +10 -0
  186. data/tasks/rake/changelog.rake +15 -0
  187. data/tasks/rake/ci.rake +22 -0
  188. data/tasks/rake/dailybuild.rake +9 -0
  189. data/tasks/rake/gem.rake +46 -0
  190. data/tasks/rake/git_workflow.rake +121 -0
  191. data/tasks/rake/metrics.rake +6 -0
  192. data/tasks/rake/sign.rake +14 -0
  193. data/tasks/rake/testbranch.rake +16 -0
  194. data/tasks/rake/tracdocs.rake +8 -0
  195. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -0
  196. metadata +1042 -1288
  197. data/ext/bin/sleeper +0 -67
  198. data/ext/module_puppet +0 -209
@@ -10,8 +10,9 @@ Puppet::Type.type(:package).provide :blastwave, :parent => :sun, :source => :sun
10
10
 
11
11
  commands :pkgget => pkgget
12
12
 
13
- # This is so stupid, but then, so is blastwave.
14
- ENV["PAGER"] = "/usr/bin/cat"
13
+ def pkgget_with_cat(*args)
14
+ withenv(:PAGER => "/usr/bin/cat") { pkgget(*args) }
15
+ end
15
16
 
16
17
  def self.extended(mod)
17
18
  unless command(:pkgget) != "pkg-get"
@@ -40,7 +41,7 @@ Puppet::Type.type(:package).provide :blastwave, :parent => :sun, :source => :sun
40
41
  command << hash[:justme]
41
42
  end
42
43
 
43
- output = pkgget command
44
+ output = pkgget_with_cat command
44
45
 
45
46
  list = output.split("\n").collect do |line|
46
47
  next if line =~ /^#/
@@ -88,7 +89,7 @@ Puppet::Type.type(:package).provide :blastwave, :parent => :sun, :source => :sun
88
89
  end
89
90
 
90
91
  def install
91
- pkgget "-f", :install, @resource[:name]
92
+ pkgget_with_cat "-f", :install, @resource[:name]
92
93
  end
93
94
 
94
95
  # Retrieve the version from the current package file.
@@ -107,11 +108,11 @@ Puppet::Type.type(:package).provide :blastwave, :parent => :sun, :source => :sun
107
108
 
108
109
  # Remove the old package, and install the new one
109
110
  def update
110
- pkgget "-f", :upgrade, @resource[:name]
111
+ pkgget_with_cat "-f", :upgrade, @resource[:name]
111
112
  end
112
113
 
113
114
  def uninstall
114
- pkgget "-f", :remove, @resource[:name]
115
+ pkgget_with_cat "-f", :remove, @resource[:name]
115
116
  end
116
117
  end
117
118
 
@@ -1,7 +1,6 @@
1
1
  require 'puppet/provider/package'
2
2
 
3
3
  Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Package do
4
- include Puppet::Util::Execution
5
4
  desc "Provides packaging support for Gentoo's portage system."
6
5
 
7
6
  has_feature :versionable
@@ -13,33 +12,32 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
13
12
  defaultfor :operatingsystem => :gentoo
14
13
 
15
14
  def self.instances
16
- result_format = /(\S+) (\S+) \[(?:([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\([^\)]+\))?(?:\[([^\]]+)\])?[ ]*)*\] \[(?:(?:\{M\})?(?:\([~*]+\))?([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\(([^\)]+)\))?(?:![mf])*(?:\[([^\]]+)\])?)?\] ([\S]*) (.*)/
17
- result_fields = [:category, :name, :ensure, :ensure_overlay, :version_available, :slot, :overlay, :vendor, :description]
15
+ result_format = /(\S+) (\S+) \[(\S+)\] \[(\S+)\] (\S+) (.*)/
16
+ result_fields = [:category, :name, :ensure, :version_available, :vendor, :description]
18
17
 
19
- version_format = "<version>{!last} {}"
20
- search_format = "<category> <name> [<installedversions:SPLITVERSIONS>] [<bestversion:SPLITVERSIONS>] <homepage> <description>"
18
+ version_format = "{last}<version>{}"
19
+ search_format = "<category> <name> [<installedversions:LASTVERSION>] [<bestversion:LASTVERSION>] <homepage> <description>\n"
21
20
 
22
21
  begin
23
22
  if !FileUtils.uptodate?("/var/cache/eix", %w(/usr/bin/eix /usr/portage/metadata/timestamp))
24
23
  update_eix
25
24
  end
25
+
26
26
  search_output = nil
27
- withenv :SPLITVERSIONS => version_format do
28
- search_output = eix "--nocolor", "--pure-packages", "--installed", "--format", search_format
27
+ Puppet::Util::Execution.withenv :LASTVERSION => version_format do
28
+ search_output = eix "--nocolor", "--pure-packages", "--stable", "--installed", "--format", search_format
29
29
  end
30
30
 
31
31
  packages = []
32
32
  search_output.each do |search_result|
33
- match = result_format.match( search_result )
33
+ match = result_format.match(search_result)
34
34
 
35
35
  if match
36
36
  package = {}
37
- result_fields.zip(match.captures) { |field, value|
37
+ result_fields.zip(match.captures) do |field, value|
38
38
  package[field] = value unless !value or value.empty?
39
- }
39
+ end
40
40
  package[:provider] = :portage
41
- package[:ensure] = package[:ensure].split.last
42
-
43
41
  packages << new(package)
44
42
  end
45
43
  end
@@ -74,36 +72,35 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
74
72
  end
75
73
 
76
74
  def query
77
- result_format = /(\S+) (\S+) \[(?:([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\([^\)]+\))?(?:\[([^\]]+)\])?[ ]*)*\] \[(?:(?:\{M\})?(?:\([~*]+\))?([0-9.a-zA-Z]+(?:_(?:alpha|beta|pre|rc|p)[0-9]*)*(?:-r[0-9]*)?)(?:\(([^\)]+)\))?(?:![mf])*(?:\[([^\]]+)\])?)?\] ([\S]*) (.*)/
78
- result_fields = [:category, :name, :ensure, :ensure_overlay, :version_available, :slot, :overlay, :vendor, :description]
75
+ result_format = /(\S+) (\S+) \[(\S*)\] \[(\S+)\] (\S+) (.*)/
76
+ result_fields = [:category, :name, :ensure, :version_available, :vendor, :description]
77
+
78
+ version_format = "{last}<version>{}"
79
+ search_format = "<category> <name> [<installedversions:LASTVERSION>] [<bestversion:LASTVERSION>] <homepage> <description>\n"
79
80
 
80
81
  search_field = package_name.count('/') > 0 ? "--category-name" : "--name"
81
82
  search_value = package_name
82
83
 
83
- version_format = "<version>{!last} {}"
84
- search_format = "<category> <name> [<installedversions:FORMAT_PVERSION>] [<bestversion:FORMAT_PVERSION>] <homepage> <description>"
85
-
86
84
  begin
87
85
  if !FileUtils.uptodate?("/var/cache/eix", %w(/usr/bin/eix /usr/portage/metadata/timestamp))
88
86
  update_eix
89
87
  end
88
+
90
89
  search_output = nil
91
- withenv :SPLITVERSIONS => version_format do
92
- search_output = eix "--nocolor", "--pure-packages", "--format", search_format, "--exact", search_field, search_value
90
+ Puppet::Util::Execution.withenv :LASTVERSION => version_format do
91
+ search_output = eix "--nocolor", "--pure-packages", "--stable", "--format", search_format, "--exact", search_field, search_value
93
92
  end
94
93
 
95
94
  packages = []
96
95
  search_output.each do |search_result|
97
- match = result_format.match( search_result )
96
+ match = result_format.match(search_result)
98
97
 
99
- if( match )
98
+ if match
100
99
  package = {}
101
- result_fields.zip( match.captures ) { |field, value| package[field] = value unless !value or value.empty? }
102
- if package[:ensure]
103
- package[:ensure] = package[:ensure].split.last
104
- else
105
- package[:ensure] = :absent
100
+ result_fields.zip(match.captures) do |field, value|
101
+ package[field] = value unless !value or value.empty?
106
102
  end
103
+ package[:ensure] = package[:ensure] ? package[:ensure] : :absent
107
104
  packages << package
108
105
  end
109
106
  end
@@ -126,4 +123,3 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
126
123
  return self.query[:version_available]
127
124
  end
128
125
  end
129
-
@@ -36,7 +36,7 @@ Puppet::Type.type(:package).provide :rug, :parent => :rpm do
36
36
  #rug can only get a list of *all* available packages?
37
37
  output = rug "list-updates"
38
38
 
39
- if output =~ /#{Regexp.escape @resource[:name]}\s*\|\s*([0-9\.\-]+)/
39
+ if output =~ /#{Regexp.escape @resource[:name]}\s*\|\s*([^\s\|]+)/
40
40
  return $1
41
41
  else
42
42
  # rug didn't find updates, pretend the current
@@ -94,7 +94,7 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d
94
94
  execpipe(cmd) { |process|
95
95
  # we're using the long listing, so each line is a separate
96
96
  # piece of information
97
- process.each { |line|
97
+ process.readlines.each { |line|
98
98
  case line
99
99
  when /^$/ # ignore
100
100
  when /\s*([A-Z]+):\s+(.+)/
@@ -111,8 +111,10 @@ Puppet::Type.type(:package).provide :sun, :parent => Puppet::Provider::Package d
111
111
  }
112
112
  }
113
113
  return hash
114
- rescue Puppet::ExecutionFailure
115
- return nil
114
+ rescue Puppet::ExecutionFailure => detail
115
+ return {:ensure => :absent} if detail.message =~ /information for "#{Regexp.escape(@resource[:name])}" was not found/
116
+ puts detail.backtrace if Puppet[:trace]
117
+ raise Puppet::Error, "Unable to get information about package #{@resource[:name]} because of: #{detail}"
116
118
  end
117
119
  end
118
120
 
@@ -45,7 +45,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do
45
45
  attr_writer :defpath
46
46
 
47
47
  # Determine the daemon path.
48
- def defpath
48
+ def defpath(dummy_argument=:work_arround_for_ruby_GC_bug)
49
49
  unless defined?(@defpath) and @defpath
50
50
  ["/var/lib/service", "/etc"].each do |path|
51
51
  if FileTest.exist?(path)
@@ -29,7 +29,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
29
29
  def enabled?
30
30
  # TODO: Replace system() call when Puppet::Util.execute gives us a way
31
31
  # to determine exit status. http://projects.reductivelabs.com/issues/2538
32
- system("/usr/sbin/invoke-rc.d", "--query", @resource[:name], "start")
32
+ system("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start")
33
33
 
34
34
  # 104 is the exit status when you query start an enabled service.
35
35
  # 106 is the exit status when the policy layer supplies a fallback action
@@ -38,7 +38,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
38
38
  class << self
39
39
  # this is necessary to autodetect a valid resource
40
40
  # default path, since there is no standard for such directory.
41
- def defpath
41
+ def defpath(dummy_argument=:work_arround_for_ruby_GC_bug)
42
42
  unless defined?(@defpath) and @defpath
43
43
  ["/etc/sv", "/var/lib/service"].each do |path|
44
44
  if FileTest.exist?(path)
@@ -14,8 +14,9 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
14
14
  :fields => %w{options type key name},
15
15
  :optional => %w{options},
16
16
  :rts => /^\s+/,
17
- :match => /^(?:(.+) )?(ssh-dss|ssh-rsa) ([^ ]+)(?: (.+))?$/,
17
+ :match => /^(?:(.+) )?(ssh-dss|ssh-rsa) ([^ ]+) ?(.*)$/,
18
18
  :post_parse => proc { |h|
19
+ h[:name] = "" if h[:name] == :absent
19
20
  h[:options] ||= [:absent]
20
21
  h[:options] = Puppet::Type::Ssh_authorized_key::ProviderParsed.parse_options(h[:options]) if h[:options].is_a? String
21
22
  },
@@ -19,11 +19,9 @@ Puppet::Type.type(:sshkey).provide(:parsed,
19
19
 
20
20
  record_line :parsed, :fields => %w{name type key},
21
21
  :post_parse => proc { |hash|
22
- if hash[:name] =~ /,/
23
- names = hash[:name].split(",")
24
- hash[:name] = names.shift
25
- hash[:alias] = names
26
- end
22
+ names = hash[:name].split(",", -1)
23
+ hash[:name] = names.shift
24
+ hash[:alias] = names
27
25
  },
28
26
  :pre_gen => proc { |hash|
29
27
  if hash[:alias]
@@ -64,7 +64,7 @@ Puppet::Type.type(:zone).provide(:solaris) do
64
64
  @property_hash.clear
65
65
  end
66
66
 
67
- def install
67
+ def install(dummy_argument=:work_arround_for_ruby_GC_bug)
68
68
  if @resource[:install_args]
69
69
  zoneadm :install, @resource[:install_args].split(" ")
70
70
  else
@@ -22,10 +22,16 @@ module Puppet::Rails
22
22
  ActiveRecord::Base.logger.level = Logger::DEBUG
23
23
  end
24
24
 
25
+ if (::ActiveRecord::VERSION::MAJOR == 2 and ::ActiveRecord::VERSION::MINOR <= 1)
26
+ ActiveRecord::Base.allow_concurrency = true
27
+ end
28
+
25
29
  ActiveRecord::Base.verify_active_connections!
26
30
 
27
31
  begin
28
- ActiveRecord::Base.establish_connection(database_arguments())
32
+ args = database_arguments
33
+ Puppet.info "Connecting to #{args[:adapter]} database: #{args[:database]}"
34
+ ActiveRecord::Base.establish_connection(args)
29
35
  rescue => detail
30
36
  if Puppet[:trace]
31
37
  puts detail.backtrace
@@ -42,12 +48,13 @@ module Puppet::Rails
42
48
 
43
49
  case adapter
44
50
  when "sqlite3"
45
- args[:dbfile] = Puppet[:dblocation]
51
+ args[:database] = Puppet[:dblocation]
46
52
  when "mysql", "postgresql"
47
53
  args[:host] = Puppet[:dbserver] unless Puppet[:dbserver].empty?
48
54
  args[:username] = Puppet[:dbuser] unless Puppet[:dbuser].empty?
49
55
  args[:password] = Puppet[:dbpassword] unless Puppet[:dbpassword].empty?
50
56
  args[:database] = Puppet[:dbname]
57
+ args[:reconnect]= true
51
58
 
52
59
  socket = Puppet[:dbsocket]
53
60
  args[:socket] = socket unless socket.empty?
@@ -64,6 +64,6 @@ module Puppet::Rails::Benchmark
64
64
  data = {}
65
65
  end
66
66
  data[branch] = $benchmarks
67
- File.open(file, "w") { |f| f.print YAML.dump(data) }
67
+ Puppet::Util.secure_open(file, "w") { |f| f.print YAML.dump(data) }
68
68
  end
69
69
  end
@@ -172,11 +172,6 @@ class Puppet::Rails::Host < ActiveRecord::Base
172
172
  end
173
173
 
174
174
  def find_resources_parameters_tags(resources)
175
- # initialize all resource parameters
176
- resources.each do |key,resource|
177
- resource.params_hash = []
178
- end
179
-
180
175
  find_resources_parameters(resources)
181
176
  find_resources_tags(resources)
182
177
  end
@@ -294,7 +289,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
294
289
 
295
290
  # assign each loaded parameters/tags to the resource it belongs to
296
291
  params.each do |param|
297
- resources[param['resource_id']].add_param_to_hash(param) if resources.include?(param['resource_id'])
292
+ resources[param['resource_id']].add_param_to_list(param) if resources.include?(param['resource_id'])
298
293
  end
299
294
  end
300
295
 
@@ -302,7 +297,7 @@ class Puppet::Rails::Host < ActiveRecord::Base
302
297
  tags = Puppet::Rails::ResourceTag.find_all_tags_from_host(self)
303
298
 
304
299
  tags.each do |tag|
305
- resources[tag['resource_id']].add_tag_to_hash(tag) if resources.include?(tag['resource_id'])
300
+ resources[tag['resource_id']].add_tag_to_list(tag) if resources.include?(tag['resource_id'])
306
301
  end
307
302
  end
308
303
 
@@ -63,22 +63,28 @@ class Puppet::Rails::Resource < ActiveRecord::Base
63
63
  unserialize_value(self[:title])
64
64
  end
65
65
 
66
- def add_param_to_hash(param)
67
- @params_hash ||= []
68
- @params_hash << param
66
+ def params_list
67
+ @params_list ||= []
69
68
  end
70
69
 
71
- def add_tag_to_hash(tag)
72
- @tags_hash ||= []
73
- @tags_hash << tag
70
+ def params_list=(params)
71
+ @params_list = params
74
72
  end
75
73
 
76
- def params_hash=(hash)
77
- @params_hash = hash
74
+ def add_param_to_list(param)
75
+ params_list << param
78
76
  end
79
77
 
80
- def tags_hash=(hash)
81
- @tags_hash = hash
78
+ def tags_list
79
+ @tags_list ||= []
80
+ end
81
+
82
+ def tags_list=(tags)
83
+ @tags_list = tags
84
+ end
85
+
86
+ def add_tag_to_list(tag)
87
+ tags_list << tag
82
88
  end
83
89
 
84
90
  def [](param)
@@ -116,7 +122,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
116
122
  db_params = {}
117
123
 
118
124
  deletions = []
119
- @params_hash.each do |value|
125
+ params_list.each do |value|
120
126
  # First remove any parameters our catalog resource doesn't have at all.
121
127
  deletions << value['id'] and next unless catalog_params.include?(value['name'])
122
128
 
@@ -142,7 +148,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
142
148
 
143
149
  # Lastly, add any new parameters.
144
150
  catalog_params.each do |name, value|
145
- next if db_params.include?(name)
151
+ next if db_params.include?(name) && ! db_params[name].find{ |val| deletions.include?( val["id"] ) }
146
152
  values = value.is_a?(Array) ? value : [value]
147
153
 
148
154
  values.each do |v|
@@ -156,7 +162,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
156
162
  in_db = []
157
163
  deletions = []
158
164
  resource_tags = resource.tags
159
- @tags_hash.each do |tag|
165
+ tags_list.each do |tag|
160
166
  deletions << tag['id'] and next unless resource_tags.include?(tag['name'])
161
167
  in_db << tag['name']
162
168
  end
@@ -187,19 +193,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base
187
193
  end
188
194
  end
189
195
 
190
- def parameters
191
- result = get_params_hash
192
- result.each do |param, value|
193
- if value.is_a?(Array)
194
- result[param] = value.collect { |v| v['value'] }
195
- else
196
- result[param] = value.value
197
- end
198
- end
199
- result
200
- end
201
-
202
- def ref
196
+ def ref(dummy_argument=:work_arround_for_ruby_GC_bug)
203
197
  "%s[%s]" % [self[:restype].split("::").collect { |s| s.capitalize }.join("::"), self.title.to_s]
204
198
  end
205
199
 
@@ -78,7 +78,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
78
78
  @resource_table[ref] = resource
79
79
 
80
80
  # If the name and title differ, set up an alias
81
- #self.alias(resource, resource.name) if resource.respond_to?(:name) and resource.respond_to?(:title) and resource.name != resource.title
81
+
82
82
  if resource.respond_to?(:name) and resource.respond_to?(:title) and resource.name != resource.title
83
83
  self.alias(resource, resource.name) if resource.isomorphic?
84
84
  end
@@ -430,12 +430,12 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
430
430
  # the class.
431
431
  edge = Puppet::Relationship.from_pson(edge) if edge.is_a?(Hash)
432
432
  unless source = result.resource(edge.source)
433
- raise ArgumentError, "Could not convert from pson: Could not find relationship source '%s'" % source
433
+ raise ArgumentError, "Could not convert from pson: Could not find relationship source #{edge.source.inspect}"
434
434
  end
435
435
  edge.source = source
436
436
 
437
437
  unless target = result.resource(edge.target)
438
- raise ArgumentError, "Could not convert from pson: Could not find relationship target '%s'" % target
438
+ raise ArgumentError, "Could not convert from pson: Could not find relationship target #{edge.target.inspect}"
439
439
  end
440
440
  edge.target = target
441
441
 
@@ -20,24 +20,12 @@ class Puppet::Resource::Reference
20
20
  end
21
21
 
22
22
  def initialize(argtype, argtitle = nil)
23
- if argtitle.nil?
24
- if argtype.is_a?(Puppet::Type)
25
- self.title = argtype.title
26
- self.type = argtype.class.name
27
- else
28
- self.title = argtype
29
- if self.title == argtype
30
- raise ArgumentError, "No title provided and title '%s' is not a valid resource reference" % argtype.inspect
31
- end
32
- end
33
- else
34
- # This will set @type if it looks like a resource reference.
35
- self.title = argtitle
36
-
37
- # Don't override whatever was done by setting the title.
38
- self.type ||= argtype
39
- end
40
-
23
+ self.type,self.title =
24
+ if (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1, $2 ]
25
+ elsif argtitle then [ argtype, argtitle ]
26
+ elsif argtype.is_a?(Puppet::Type) then [ argtype.class.name, argtype.title ]
27
+ else raise ArgumentError, "No title provided and #{argtype.inspect} is not a valid resource reference"
28
+ end
41
29
  @builtin_type = nil
42
30
  end
43
31
 
@@ -47,15 +35,11 @@ class Puppet::Resource::Reference
47
35
  return nil
48
36
  end
49
37
 
50
- # If the title has square brackets, treat it like a reference and
51
- # set things appropriately; else, just set it.
52
38
  def title=(value)
53
- if value =~ /^([^\[\]]+)\[(.+)\]$/
54
- self.type = $1
55
- @title = $2
56
- else
57
- @title = value
39
+ if @type and klass = Puppet::Type.type(@type.to_s.downcase)
40
+ value = klass.canonicalize_ref(value)
58
41
  end
42
+ @title = value
59
43
  end
60
44
 
61
45
  # Canonize the type so we know it's always consistent.
@@ -66,6 +50,10 @@ class Puppet::Resource::Reference
66
50
  # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
67
51
  x = @type = value.to_s.split("::").collect { |s| s.capitalize }.join("::")
68
52
  end
53
+
54
+ if @title
55
+ self.title = @title
56
+ end
69
57
  end
70
58
 
71
59
  # Convert to the reference format that TransObject uses. Yay backward