puppet 4.0.0 → 4.1.0

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 (219) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +8 -35
  3. data/ext/debian/puppet.default +0 -5
  4. data/ext/debian/puppet.init +1 -15
  5. data/lib/hiera/puppet_function.rb +15 -4
  6. data/lib/puppet/application/agent.rb +5 -0
  7. data/lib/puppet/application/apply.rb +23 -2
  8. data/lib/puppet/application/device.rb +8 -3
  9. data/lib/puppet/application/master.rb +16 -5
  10. data/lib/puppet/configurer.rb +7 -5
  11. data/lib/puppet/defaults.rb +18 -0
  12. data/lib/puppet/environments.rb +1 -1
  13. data/lib/puppet/error.rb +27 -1
  14. data/lib/puppet/file_serving/metadata.rb +13 -8
  15. data/lib/puppet/file_serving/terminus_helper.rb +7 -8
  16. data/lib/puppet/file_system.rb +13 -0
  17. data/lib/puppet/file_system/file_impl.rb +4 -0
  18. data/lib/puppet/file_system/memory_impl.rb +4 -0
  19. data/lib/puppet/file_system/windows.rb +8 -0
  20. data/lib/puppet/functions.rb +33 -3
  21. data/lib/puppet/functions/defined.rb +130 -0
  22. data/lib/puppet/functions/regsubst.rb +1 -1
  23. data/lib/puppet/functions/split.rb +1 -1
  24. data/lib/puppet/indirector/catalog/compiler.rb +1 -1
  25. data/lib/puppet/indirector/facts/facter.rb +11 -0
  26. data/lib/puppet/loaders.rb +1 -0
  27. data/lib/puppet/node.rb +17 -1
  28. data/lib/puppet/node/environment.rb +4 -0
  29. data/lib/puppet/parser/ast/pops_bridge.rb +4 -0
  30. data/lib/puppet/parser/compiler.rb +9 -0
  31. data/lib/puppet/parser/functions/defined.rb +25 -1
  32. data/lib/puppet/parser/functions/file.rb +3 -1
  33. data/lib/puppet/parser/scope.rb +11 -2
  34. data/lib/puppet/parser/templatewrapper.rb +2 -1
  35. data/lib/puppet/pops.rb +4 -0
  36. data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
  37. data/lib/puppet/pops/evaluator/closure.rb +28 -2
  38. data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
  39. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +4 -0
  40. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +4 -0
  41. data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
  42. data/lib/puppet/pops/evaluator/epp_evaluator.rb +7 -2
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +48 -14
  44. data/lib/puppet/pops/evaluator/runtime3_support.rb +10 -5
  45. data/lib/puppet/pops/functions/dispatch.rb +6 -1
  46. data/lib/puppet/pops/functions/dispatcher.rb +7 -1
  47. data/lib/puppet/pops/issue_reporter.rb +42 -16
  48. data/lib/puppet/pops/issues.rb +116 -2
  49. data/lib/puppet/pops/loader/loader.rb +11 -0
  50. data/lib/puppet/pops/loader/loader_paths.rb +67 -6
  51. data/lib/puppet/pops/loader/module_loaders.rb +19 -8
  52. data/lib/puppet/pops/loader/puppet_function_instantiator.rb +78 -0
  53. data/lib/puppet/pops/loaders.rb +6 -4
  54. data/lib/puppet/pops/migration/migration_checker.rb +54 -0
  55. data/lib/puppet/pops/model/factory.rb +5 -1
  56. data/lib/puppet/pops/model/model_label_provider.rb +2 -0
  57. data/lib/puppet/pops/model/model_meta.rb +5 -1
  58. data/lib/puppet/pops/parser/egrammar.ra +9 -10
  59. data/lib/puppet/pops/parser/eparser.rb +1061 -1047
  60. data/lib/puppet/pops/parser/epp_support.rb +18 -9
  61. data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
  62. data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
  63. data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
  64. data/lib/puppet/pops/parser/lexer2.rb +29 -12
  65. data/lib/puppet/pops/parser/lexer_support.rb +52 -23
  66. data/lib/puppet/pops/parser/parser_support.rb +11 -14
  67. data/lib/puppet/pops/parser/slurp_support.rb +22 -6
  68. data/lib/puppet/pops/types/type_calculator.rb +156 -55
  69. data/lib/puppet/pops/types/type_factory.rb +66 -13
  70. data/lib/puppet/pops/types/type_parser.rb +22 -13
  71. data/lib/puppet/pops/types/types.rb +23 -4
  72. data/lib/puppet/pops/types/types_meta.rb +13 -2
  73. data/lib/puppet/pops/validation.rb +25 -2
  74. data/lib/puppet/pops/validation/checker4_0.rb +63 -31
  75. data/lib/puppet/provider/group/windows_adsi.rb +8 -4
  76. data/lib/puppet/provider/mount/parsed.rb +145 -2
  77. data/lib/puppet/provider/package/apt.rb +1 -1
  78. data/lib/puppet/provider/package/pip.rb +11 -2
  79. data/lib/puppet/provider/package/pkgng.rb +134 -0
  80. data/lib/puppet/provider/package/portage.rb +1 -1
  81. data/lib/puppet/provider/package/ports.rb +0 -3
  82. data/lib/puppet/provider/package/windows/exe_package.rb +0 -1
  83. data/lib/puppet/provider/package/windows/msi_package.rb +0 -1
  84. data/lib/puppet/provider/package/zypper.rb +50 -15
  85. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +32 -7
  86. data/lib/puppet/provider/service/debian.rb +1 -1
  87. data/lib/puppet/provider/service/init.rb +7 -0
  88. data/lib/puppet/provider/user/openbsd.rb +1 -0
  89. data/lib/puppet/provider/user/windows_adsi.rb +45 -2
  90. data/lib/puppet/reference/indirection.rb +1 -1
  91. data/lib/puppet/resource.rb +1 -1
  92. data/lib/puppet/resource/catalog.rb +0 -4
  93. data/lib/puppet/settings.rb +19 -0
  94. data/lib/puppet/type/file.rb +1 -0
  95. data/lib/puppet/type/file/ensure.rb +1 -1
  96. data/lib/puppet/type/mount.rb +9 -1
  97. data/lib/puppet/type/scheduled_task.rb +13 -0
  98. data/lib/puppet/type/tidy.rb +3 -1
  99. data/lib/puppet/type/user.rb +32 -0
  100. data/lib/puppet/type/yumrepo.rb +5 -5
  101. data/lib/puppet/util/log.rb +50 -8
  102. data/lib/puppet/util/log/destinations.rb +23 -2
  103. data/lib/puppet/util/logging.rb +37 -1
  104. data/lib/puppet/util/run_mode.rb +1 -14
  105. data/lib/puppet/util/windows/adsi.rb +130 -58
  106. data/lib/puppet/version.rb +1 -1
  107. data/man/man5/puppet.conf.5 +48 -6
  108. data/man/man8/extlookup2hiera.8 +1 -1
  109. data/man/man8/puppet-agent.8 +4 -1
  110. data/man/man8/puppet-apply.8 +4 -1
  111. data/man/man8/puppet-ca.8 +1 -1
  112. data/man/man8/puppet-catalog.8 +1 -1
  113. data/man/man8/puppet-cert.8 +1 -1
  114. data/man/man8/puppet-certificate.8 +1 -1
  115. data/man/man8/puppet-certificate_request.8 +1 -1
  116. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  117. data/man/man8/puppet-config.8 +1 -1
  118. data/man/man8/puppet-describe.8 +1 -1
  119. data/man/man8/puppet-device.8 +6 -3
  120. data/man/man8/puppet-doc.8 +1 -1
  121. data/man/man8/puppet-epp.8 +1 -1
  122. data/man/man8/puppet-facts.8 +1 -1
  123. data/man/man8/puppet-file.8 +1 -1
  124. data/man/man8/puppet-filebucket.8 +1 -1
  125. data/man/man8/puppet-help.8 +1 -1
  126. data/man/man8/puppet-inspect.8 +1 -1
  127. data/man/man8/puppet-key.8 +1 -1
  128. data/man/man8/puppet-man.8 +1 -1
  129. data/man/man8/puppet-master.8 +4 -1
  130. data/man/man8/puppet-module.8 +1 -1
  131. data/man/man8/puppet-node.8 +1 -1
  132. data/man/man8/puppet-parser.8 +1 -1
  133. data/man/man8/puppet-plugin.8 +1 -1
  134. data/man/man8/puppet-report.8 +1 -1
  135. data/man/man8/puppet-resource.8 +1 -1
  136. data/man/man8/puppet-resource_type.8 +1 -1
  137. data/man/man8/puppet-status.8 +1 -1
  138. data/man/man8/puppet.8 +1 -1
  139. data/spec/fixtures/unit/data_providers/environments/production/lib/puppet/functions/environment/data.rb +3 -1
  140. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp +6 -0
  141. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +9 -0
  142. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp +9 -0
  143. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp +3 -0
  144. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp +3 -0
  145. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp +3 -0
  146. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb +5 -0
  147. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp +3 -0
  148. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp +3 -0
  149. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json +10 -0
  150. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp +3 -0
  151. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp +3 -0
  152. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +1 -10
  153. data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
  154. data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
  155. data/spec/fixtures/unit/provider/package/pkgng/pkg.info +8 -0
  156. data/spec/fixtures/unit/provider/package/pkgng/pkg.query +1 -0
  157. data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +1 -0
  158. data/spec/fixtures/unit/provider/package/pkgng/pkg.version +3 -0
  159. data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out +3 -0
  160. data/spec/integration/application/apply_spec.rb +49 -0
  161. data/spec/integration/faces/plugin_spec.rb +0 -4
  162. data/spec/integration/indirector/facts/facter_spec.rb +59 -0
  163. data/spec/integration/parser/compiler_spec.rb +850 -0
  164. data/spec/integration/parser/resource_expressions_spec.rb +3 -0
  165. data/spec/integration/parser/scope_spec.rb +26 -5
  166. data/spec/integration/transaction_spec.rb +1 -1
  167. data/spec/integration/type/file_spec.rb +318 -41
  168. data/spec/integration/util/windows/security_spec.rb +14 -5
  169. data/spec/lib/matchers/resource.rb +22 -1
  170. data/spec/lib/puppet_spec/matchers.rb +6 -4
  171. data/spec/unit/application/master_spec.rb +33 -7
  172. data/spec/unit/data_providers/function_data_provider_spec.rb +10 -1
  173. data/spec/unit/file_serving/metadata_spec.rb +1 -1
  174. data/spec/unit/file_serving/terminus_helper_spec.rb +2 -3
  175. data/spec/unit/file_system_spec.rb +38 -0
  176. data/spec/unit/functions/defined_spec.rb +289 -0
  177. data/spec/unit/functions/hiera_spec.rb +8 -6
  178. data/spec/unit/functions/regsubst_spec.rb +4 -0
  179. data/spec/unit/functions/split_spec.rb +8 -0
  180. data/spec/unit/functions4_spec.rb +97 -2
  181. data/spec/unit/indirector/facts/facter_spec.rb +7 -0
  182. data/spec/unit/node_spec.rb +6 -0
  183. data/spec/unit/parser/functions/file_spec.rb +7 -1
  184. data/spec/unit/parser/functions/template_spec.rb +1 -1
  185. data/spec/unit/parser/scope_spec.rb +2 -2
  186. data/spec/unit/parser/templatewrapper_spec.rb +1 -1
  187. data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
  188. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +84 -18
  189. data/spec/unit/pops/evaluator/variables_spec.rb +1 -1
  190. data/spec/unit/pops/issues_spec.rb +16 -16
  191. data/spec/unit/pops/loaders/loaders_spec.rb +106 -48
  192. data/spec/unit/pops/migration_spec.rb +53 -0
  193. data/spec/unit/pops/parser/lexer2_spec.rb +142 -1
  194. data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
  195. data/spec/unit/pops/types/type_calculator_spec.rb +205 -12
  196. data/spec/unit/pops/validation_spec.rb +66 -0
  197. data/spec/unit/pops/validator/validator_spec.rb +1 -1
  198. data/spec/unit/provider/group/windows_adsi_spec.rb +57 -9
  199. data/spec/unit/provider/mount/parsed_spec.rb +31 -5
  200. data/spec/unit/provider/package/apt_spec.rb +5 -0
  201. data/spec/unit/provider/package/pip_spec.rb +9 -0
  202. data/spec/unit/provider/package/pkgng_spec.rb +172 -0
  203. data/spec/unit/provider/package/windows/exe_package_spec.rb +0 -1
  204. data/spec/unit/provider/package/windows/msi_package_spec.rb +0 -1
  205. data/spec/unit/provider/package/zypper_spec.rb +50 -19
  206. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
  207. data/spec/unit/provider/service/base_spec.rb +38 -27
  208. data/spec/unit/provider/service/debian_spec.rb +8 -0
  209. data/spec/unit/provider/service/freebsd_spec.rb +1 -0
  210. data/spec/unit/provider/service/gentoo_spec.rb +1 -0
  211. data/spec/unit/provider/service/init_spec.rb +18 -0
  212. data/spec/unit/provider/service/openbsd_spec.rb +1 -0
  213. data/spec/unit/provider/service/redhat_spec.rb +1 -0
  214. data/spec/unit/provider/user/windows_adsi_spec.rb +134 -5
  215. data/spec/unit/settings_spec.rb +11 -0
  216. data/spec/unit/util/log_spec.rb +113 -0
  217. data/spec/unit/util/windows/adsi_spec.rb +135 -41
  218. data/spec/unit/util/windows/sid_spec.rb +0 -10
  219. metadata +48 -2
@@ -14,7 +14,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do
14
14
  commands :aptcache => "/usr/bin/apt-cache"
15
15
  commands :preseed => "/usr/bin/debconf-set-selections"
16
16
 
17
- defaultfor :operatingsystem => [:debian, :ubuntu]
17
+ defaultfor :osfamily => :debian
18
18
 
19
19
  ENV['DEBIAN_FRONTEND'] = "noninteractive"
20
20
 
@@ -7,9 +7,13 @@ require 'xmlrpc/client'
7
7
  Puppet::Type.type(:package).provide :pip,
8
8
  :parent => ::Puppet::Provider::Package do
9
9
 
10
- desc "Python packages via `pip`."
10
+ desc "Python packages via `pip`.
11
11
 
12
- has_feature :installable, :uninstallable, :upgradeable, :versionable
12
+ This provider supports the `install_options` attribute, which allows command-line flags to be passed to pip.
13
+ These options should be specified as a string (e.g. '--flag'), a hash (e.g. {'--flag' => 'value'}),
14
+ or an array where each element is either a string or a hash."
15
+
16
+ has_feature :installable, :uninstallable, :upgradeable, :versionable, :install_options
13
17
 
14
18
  # Parse lines of output from `pip freeze`, which are structured as
15
19
  # _package_==_version_.
@@ -71,6 +75,7 @@ Puppet::Type.type(:package).provide :pip,
71
75
  # gives the fully-qualified URL to the repository.
72
76
  def install
73
77
  args = %w{install -q}
78
+ args += install_options if @resource[:install_options]
74
79
  if @resource[:source]
75
80
  if String === @resource[:ensure]
76
81
  args << "#{@resource[:source]}@#{@resource[:ensure]}#egg=#{
@@ -115,4 +120,8 @@ Puppet::Type.type(:package).provide :pip,
115
120
  raise e, 'Could not locate the pip command.', e.backtrace
116
121
  end
117
122
  end
123
+
124
+ def install_options
125
+ join_options(@resource[:install_options])
126
+ end
118
127
  end
@@ -0,0 +1,134 @@
1
+ require 'puppet/provider/package'
2
+
3
+ Puppet::Type.type(:package).provide :pkgng, :parent => Puppet::Provider::Package do
4
+ desc "A PkgNG provider for FreeBSD and DragonFly."
5
+
6
+ commands :pkg => "/usr/local/sbin/pkg"
7
+
8
+ confine :operatingsystem => [:freebsd, :dragonfly]
9
+
10
+ defaultfor :operatingsystem => :freebsd
11
+
12
+ has_feature :versionable
13
+ has_feature :upgradeable
14
+
15
+ def self.get_query
16
+ pkg(['query', '-a', '%n %v %o'])
17
+ end
18
+
19
+ def self.get_version_list
20
+ pkg(['version', '-voRL='])
21
+ end
22
+
23
+ def self.get_latest_version(origin)
24
+ if latest_version = self.get_version_list.lines.find { |l| l =~ /^#{origin} / }
25
+ latest_version = latest_version.split(' ').last.split(')').first
26
+ return latest_version
27
+ end
28
+ nil
29
+ end
30
+
31
+ def self.instances
32
+ packages = []
33
+ begin
34
+ info = self.get_query
35
+
36
+ unless info
37
+ return packages
38
+ end
39
+
40
+ info.lines.each do |line|
41
+
42
+ name, version, origin = line.chomp.split(" ", 3)
43
+ latest_version = get_latest_version(origin) || version
44
+
45
+ pkg = {
46
+ :ensure => version,
47
+ :name => name,
48
+ :provider => self.name,
49
+ :origin => origin,
50
+ :version => version,
51
+ :latest => latest_version
52
+ }
53
+ packages << new(pkg)
54
+ end
55
+
56
+ return packages
57
+ rescue Puppet::ExecutionFailure
58
+ nil
59
+ end
60
+ end
61
+
62
+ def self.prefetch(resources)
63
+ packages = instances
64
+ resources.keys.each do |name|
65
+ if provider = packages.find{|p| p.name == name or p.origin == name }
66
+ resources[name].provider = provider
67
+ end
68
+ end
69
+ end
70
+
71
+ def repo_tag_from_urn(urn)
72
+ # extract repo tag from URN: urn:freebsd:repo:<tag>
73
+ match = /^urn:freebsd:repo:(.+)$/.match(urn)
74
+ raise ArgumentError urn.inspect unless match
75
+ match[1]
76
+ end
77
+
78
+ def install
79
+ source = resource[:source]
80
+ source = URI(source) unless source.nil?
81
+
82
+ # Ensure we handle the version
83
+ case resource[:ensure]
84
+ when true, false, Symbol
85
+ installname = resource[:name]
86
+ else
87
+ installname = resource[:name] + '-' + resource[:ensure]
88
+ end
89
+
90
+ if not source # install using default repo logic
91
+ args = ['install', '-qy', installname]
92
+ elsif source.scheme == 'urn' # install from repo named in URN
93
+ tag = repo_tag_from_urn(source.to_s)
94
+ args = ['install', '-qy', '-r', tag, installname]
95
+ else # add package located at URL
96
+ args = ['add', '-q', source.to_s]
97
+ end
98
+
99
+ pkg(args)
100
+ end
101
+
102
+ def uninstall
103
+ pkg(['remove', '-qy', resource[:name]])
104
+ end
105
+
106
+ def query
107
+ if @property_hash[:ensure] == nil
108
+ return nil
109
+ else
110
+ version = @property_hash[:version]
111
+ return { :version => version }
112
+ end
113
+ end
114
+
115
+ def version
116
+ @property_hash[:version]
117
+ end
118
+
119
+ # Upgrade to the latest version
120
+ def update
121
+ install
122
+ end
123
+
124
+ # Return the latest version of the package
125
+ def latest
126
+ debug "returning the latest #{@property_hash[:name].inspect} version #{@property_hash[:latest].inspect}"
127
+ @property_hash[:latest]
128
+ end
129
+
130
+ def origin
131
+ @property_hash[:origin]
132
+ end
133
+
134
+ end
@@ -132,7 +132,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
132
132
 
133
133
  private
134
134
  def self.eix_search_format
135
- "'<category> <name> [<installedversions:LASTVERSION>] [<bestversion:LASTVERSION>] <homepage> <description>'"
135
+ "'<category> <name> [<installedversions:LASTVERSION>] [<bestversion:LASTVERSION>] <homepage> <description>\n'"
136
136
  end
137
137
 
138
138
  def self.eix_result_format
@@ -6,9 +6,6 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre
6
6
  :portuninstall => "/usr/local/sbin/pkg_deinstall",
7
7
  :portinfo => "/usr/sbin/pkg_info"
8
8
 
9
- defaultfor :operatingsystem => :freebsd
10
-
11
- # I hate ports
12
9
  %w{INTERACTIVE UNAME}.each do |var|
13
10
  ENV.delete(var) if ENV.include?(var)
14
11
  end
@@ -20,7 +20,6 @@ class Puppet::Provider::Package::Windows
20
20
  # See http://community.spiceworks.com/how_to/show/2238
21
21
  !!(values['DisplayName'] and values['DisplayName'].length > 0 and
22
22
  values['UninstallString'] and values['UninstallString'].length > 0 and
23
- values['SystemComponent'] != 1 and # DWORD
24
23
  values['WindowsInstaller'] != 1 and # DWORD
25
24
  name !~ /^KB[0-9]{6}/ and
26
25
  values['ParentKeyName'] == nil and
@@ -32,7 +32,6 @@ class Puppet::Provider::Package::Windows
32
32
  def self.valid?(name, values)
33
33
  # See http://community.spiceworks.com/how_to/show/2238
34
34
  !!(values['DisplayName'] and values['DisplayName'].length > 0 and
35
- values['SystemComponent'] != 1 and # DWORD
36
35
  values['WindowsInstaller'] == 1 and # DWORD
37
36
  name =~ /\A\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}\Z/i)
38
37
  end
@@ -12,6 +12,37 @@ Puppet::Type.type(:package).provide :zypper, :parent => :rpm do
12
12
  defaultfor :operatingsystem => [:suse, :sles, :sled, :opensuse]
13
13
  confine :operatingsystem => [:suse, :sles, :sled, :opensuse]
14
14
 
15
+ # @api private
16
+ # Reset the latest version hash to nil
17
+ # needed for spec tests to clear cached value
18
+ def self.reset!
19
+ @latest_versions = nil
20
+ end
21
+
22
+ def self.latest_package_version(package)
23
+ if @latest_versions.nil?
24
+ @latest_versions = list_updates
25
+ end
26
+
27
+ @latest_versions[package]
28
+ end
29
+
30
+ def self.list_updates
31
+ output = zypper 'list-updates'
32
+
33
+ avail_updates = {}
34
+
35
+ # split up columns
36
+ output.lines.each do |line|
37
+ pkg_ver = line.split(/\s*\|\s*/)
38
+ # ignore zypper headers
39
+ next unless pkg_ver[0] == 'v'
40
+ avail_updates[pkg_ver[2]] = pkg_ver[4]
41
+ end
42
+
43
+ avail_updates
44
+ end
45
+
15
46
  #on zypper versions <1.0, the version option returns 1
16
47
  #some versions of zypper output on stderr
17
48
  def zypper_version
@@ -35,10 +66,9 @@ Puppet::Type.type(:package).provide :zypper, :parent => :rpm do
35
66
  end
36
67
 
37
68
  #This has been tested with following zypper versions
38
- #SLE 10.2: 0.6.104
39
- #SLE 11.0: 1.0.8
40
- #OpenSuse 10.2: 0.6.13
41
- #OpenSuse 11.2: 1.2.8
69
+ #SLE 10.4: 0.6.201
70
+ #SLE 11.3: 1.6.307
71
+ #SLE 12.0: 1.11.14
42
72
  #Assume that this will work on newer zypper versions
43
73
 
44
74
  #extract version numbers and convert to integers
@@ -52,13 +82,24 @@ Puppet::Type.type(:package).provide :zypper, :parent => :rpm do
52
82
  quiet = '--quiet'
53
83
  end
54
84
 
55
- options = [quiet, :install]
85
+ inst_opts = []
86
+ inst_opts = install_options if resource[:install_options]
87
+
88
+
89
+ options = []
90
+ options << quiet
91
+ options << '--no-gpg-check' unless inst_opts.delete('--no-gpg-check').nil?
92
+ options << :install
56
93
 
57
94
  #zypper 0.6.13 (OpenSuSE 10.2) does not support auto agree with licenses
58
95
  options << '--auto-agree-with-licenses' unless major < 1 and minor <= 6 and patch <= 13
59
96
  options << '--no-confirm'
60
- options << '--name' unless @resource.allow_virtual? || should
61
- options += install_options if resource[:install_options]
97
+ options += inst_opts unless inst_opts.empty?
98
+
99
+ # Zypper 0.6.201 doesn't recognize '--name'
100
+ # It is unclear where this functionality was introduced, but it
101
+ # is present as early as 1.0.13
102
+ options << '--name' unless major < 1 || @resource.allow_virtual? || should
62
103
  options << wanted
63
104
 
64
105
  zypper *options
@@ -72,16 +113,10 @@ Puppet::Type.type(:package).provide :zypper, :parent => :rpm do
72
113
 
73
114
  # What's the latest package version available?
74
115
  def latest
75
- #zypper can only get a list of *all* available packages?
76
- output = zypper "list-updates"
77
-
78
- if output =~ /#{Regexp.escape @resource[:name]}\s*\|.*?\|\s*([^\s\|]+)/
79
- return $1
80
- else
116
+ return self.class.latest_package_version(@resource[:name]) ||
81
117
  # zypper didn't find updates, pretend the current
82
118
  # version is the latest
83
- return @property_hash[:ensure]
84
- end
119
+ @property_hash[:ensure]
85
120
  end
86
121
 
87
122
  def update
@@ -10,6 +10,8 @@ Puppet::Type.type(:scheduled_task).provide(:win32_taskscheduler) do
10
10
  defaultfor :operatingsystem => :windows
11
11
  confine :operatingsystem => :windows
12
12
 
13
+ MINUTES_IN_DAY = 1440
14
+
13
15
  def self.instances
14
16
  Win32::TaskScheduler.new.tasks.collect do |job_file|
15
17
  job_title = File.basename(job_file, '.job')
@@ -76,7 +78,6 @@ Puppet::Type.type(:scheduled_task).provide(:win32_taskscheduler) do
76
78
  nil
77
79
  end
78
80
  next unless trigger and scheduler_trigger_types.include?(trigger['trigger_type'])
79
-
80
81
  puppet_trigger = {}
81
82
  case trigger['trigger_type']
82
83
  when Win32::TaskScheduler::TASK_TIME_TRIGGER_DAILY
@@ -101,6 +102,8 @@ Puppet::Type.type(:scheduled_task).provide(:win32_taskscheduler) do
101
102
  puppet_trigger['start_date'] = self.class.normalized_date("#{trigger['start_year']}-#{trigger['start_month']}-#{trigger['start_day']}")
102
103
  puppet_trigger['start_time'] = self.class.normalized_time("#{trigger['start_hour']}:#{trigger['start_minute']}")
103
104
  puppet_trigger['enabled'] = trigger['flags'] & Win32::TaskScheduler::TASK_TRIGGER_FLAG_DISABLED == 0
105
+ puppet_trigger['minutes_interval'] = trigger['minutes_interval'] ||= 0
106
+ puppet_trigger['minutes_duration'] = trigger['minutes_duration'] ||= 0
104
107
  puppet_trigger['index'] = i
105
108
 
106
109
  @triggers << puppet_trigger
@@ -209,7 +212,6 @@ Puppet::Type.type(:scheduled_task).provide(:win32_taskscheduler) do
209
212
  def create
210
213
  clear_task
211
214
  @task = Win32::TaskScheduler.new(resource[:name], dummy_time_trigger)
212
-
213
215
  self.command = resource[:command]
214
216
 
215
217
  [:arguments, :working_dir, :enabled, :trigger, :user].each do |prop|
@@ -258,10 +260,10 @@ Puppet::Type.type(:scheduled_task).provide(:win32_taskscheduler) do
258
260
  'flags' => 0,
259
261
  'random_minutes_interval' => 0,
260
262
  'end_day' => 0,
261
- "end_year" => 0,
262
- "minutes_interval" => 0,
263
- "end_month" => 0,
264
- "minutes_duration" => 0,
263
+ 'end_year' => 0,
264
+ 'minutes_interval' => 0,
265
+ 'end_month' => 0,
266
+ 'minutes_duration' => 0,
265
267
  'start_year' => now.year,
266
268
  'start_month' => now.month,
267
269
  'start_day' => now.day,
@@ -280,7 +282,7 @@ Puppet::Type.type(:scheduled_task).provide(:win32_taskscheduler) do
280
282
  trigger['flags'] &= ~Win32::TaskScheduler::TASK_TRIGGER_FLAG_DISABLED
281
283
  end
282
284
 
283
- extra_keys = puppet_trigger.keys.sort - ['index', 'enabled', 'schedule', 'start_date', 'start_time', 'every', 'months', 'on', 'which_occurrence', 'day_of_week']
285
+ extra_keys = puppet_trigger.keys.sort - ['index', 'enabled', 'schedule', 'start_date', 'start_time', 'every', 'months', 'on', 'which_occurrence', 'day_of_week', 'minutes_interval', 'minutes_duration']
284
286
  self.fail "Unknown trigger option(s): #{Puppet::Parameter.format_value_for_display(extra_keys)}" unless extra_keys.empty?
285
287
  self.fail "Must specify 'start_time' when defining a trigger" unless puppet_trigger['start_time']
286
288
 
@@ -333,6 +335,29 @@ Puppet::Type.type(:scheduled_task).provide(:win32_taskscheduler) do
333
335
  self.fail "Unknown schedule type: #{puppet_trigger["schedule"].inspect}"
334
336
  end
335
337
 
338
+ integer_interval = -1
339
+ if puppet_trigger['minutes_interval']
340
+ integer_interval = Integer(puppet_trigger['minutes_interval'])
341
+ self.fail 'minutes_interval must be an integer greater or equal to 0' if integer_interval < 0
342
+ trigger['minutes_interval'] = integer_interval
343
+ end
344
+
345
+ integer_duration = -1
346
+ if puppet_trigger['minutes_duration']
347
+ integer_duration = Integer(puppet_trigger['minutes_duration'])
348
+ self.fail 'minutes_duration must be an integer greater than minutes_interval and equal to or greater than 0' if integer_duration <= integer_interval && integer_duration != 0
349
+ trigger['minutes_duration'] = integer_duration
350
+ end
351
+
352
+ if integer_interval > 0 && integer_duration == -1
353
+ integer_duration = MINUTES_IN_DAY
354
+ trigger['minutes_duration'] = MINUTES_IN_DAY
355
+ end
356
+
357
+ if integer_interval >= integer_duration && integer_interval > 0
358
+ self.fail 'minutes_interval cannot be set without minutes_duration also being set to a number greater than 0'
359
+ end
360
+
336
361
  if start_date = puppet_trigger['start_date']
337
362
  start_date = Date.parse(start_date)
338
363
  self.fail "start_date must be on or after 1753-01-01" unless start_date >= Date.new(1753, 1, 1)
@@ -16,7 +16,7 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
16
16
  # is resolved.
17
17
  commands :invoke_rc => "/usr/sbin/invoke-rc.d"
18
18
 
19
- defaultfor :operatingsystem => :debian
19
+ defaultfor :operatingsystem => [:debian, :cumuluslinux]
20
20
 
21
21
  # Remove the symlinks
22
22
  def disable
@@ -152,6 +152,13 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
152
152
  (@resource[:hasrestart] == :true) && [initscript, :restart]
153
153
  end
154
154
 
155
+ def texecute(type, command, fof = true, squelch = false, combine = true)
156
+ if type == :start && Facter.value(:osfamily) == "Solaris"
157
+ command = ["/usr/bin/ctrun -l none", command].flatten.join(" ")
158
+ end
159
+ super(type, command, fof, squelch, combine)
160
+ end
161
+
155
162
  # If it was specified that the init script has a 'status' command, then
156
163
  # we just return that; otherwise, we return false, which causes it to
157
164
  # fallback to other mechanisms.
@@ -11,6 +11,7 @@ Puppet::Type.type(:user).provide :openbsd, :parent => :useradd do
11
11
  :password => "passwd"
12
12
 
13
13
  defaultfor :operatingsystem => :openbsd
14
+ confine :operatingsystem => :openbsd
14
15
 
15
16
  options :home, :flag => "-d", :method => :dir
16
17
  options :comment, :method => :gecos
@@ -8,18 +8,59 @@ Puppet::Type.type(:user).provide :windows_adsi do
8
8
 
9
9
  has_features :manages_homedir, :manages_passwords
10
10
 
11
+ def initialize(value={})
12
+ super(value)
13
+ @deleted = false
14
+ end
15
+
11
16
  def user
12
17
  @user ||= Puppet::Util::Windows::ADSI::User.new(@resource[:name])
13
18
  end
14
19
 
15
20
  def groups
16
- user.groups.join(',')
21
+ @groups ||= Puppet::Util::Windows::ADSI::Group.name_sid_hash(user.groups)
22
+ @groups.keys
17
23
  end
18
24
 
19
25
  def groups=(groups)
20
26
  user.set_groups(groups, @resource[:membership] == :minimum)
21
27
  end
22
28
 
29
+ def groups_insync?(current, should)
30
+ return false unless current
31
+
32
+ # By comparing account SIDs we don't have to worry about case
33
+ # sensitivity, or canonicalization of account names.
34
+
35
+ # Cannot use munge of the group property to canonicalize @should
36
+ # since the default array_matching comparison is not commutative
37
+
38
+ # dupes automatically weeded out when hashes built
39
+ current_users = Puppet::Util::Windows::ADSI::Group.name_sid_hash(current)
40
+ specified_users = Puppet::Util::Windows::ADSI::Group.name_sid_hash(should)
41
+
42
+ if @resource[:membership] == :inclusive
43
+ current_users == specified_users
44
+ else
45
+ (specified_users.keys.to_a & current_users.keys.to_a) == specified_users.keys.to_a
46
+ end
47
+ end
48
+
49
+ def groups_to_s(groups)
50
+ return '' if groups.nil? || !groups.kind_of?(Array)
51
+ groups = groups.map do |group_name|
52
+ sid = Puppet::Util::Windows::SID.name_to_sid_object(group_name)
53
+ if sid.account =~ /\\/
54
+ account, _ = Puppet::Util::Windows::ADSI::Group.parse_name(sid.account)
55
+ else
56
+ account = sid.account
57
+ end
58
+ resource.debug("#{sid.domain}\\#{account} (#{sid.to_s})")
59
+ "#{sid.domain}\\#{account}"
60
+ end
61
+ return groups.join(',')
62
+ end
63
+
23
64
  def create
24
65
  @user = Puppet::Util::Windows::ADSI::User.create(@resource[:name])
25
66
  @user.password = @resource[:password]
@@ -47,11 +88,13 @@ Puppet::Type.type(:user).provide :windows_adsi do
47
88
  if sid
48
89
  Puppet::Util::Windows::ADSI::UserProfile.delete(sid)
49
90
  end
91
+
92
+ @deleted = true
50
93
  end
51
94
 
52
95
  # Only flush if we created or modified a user, not deleted
53
96
  def flush
54
- @user.commit if @user
97
+ @user.commit if @user && !@deleted
55
98
  end
56
99
 
57
100
  def comment