puppet 4.0.0-x86-mingw32 → 4.1.0-x86-mingw32
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.
- checksums.yaml +4 -4
- data/ext/build_defaults.yaml +8 -35
- data/ext/debian/puppet.default +0 -5
- data/ext/debian/puppet.init +1 -15
- data/lib/hiera/puppet_function.rb +15 -4
- data/lib/puppet/application/agent.rb +5 -0
- data/lib/puppet/application/apply.rb +23 -2
- data/lib/puppet/application/device.rb +8 -3
- data/lib/puppet/application/master.rb +16 -5
- data/lib/puppet/configurer.rb +7 -5
- data/lib/puppet/defaults.rb +18 -0
- data/lib/puppet/environments.rb +1 -1
- data/lib/puppet/error.rb +27 -1
- data/lib/puppet/file_serving/metadata.rb +13 -8
- data/lib/puppet/file_serving/terminus_helper.rb +7 -8
- data/lib/puppet/file_system.rb +13 -0
- data/lib/puppet/file_system/file_impl.rb +4 -0
- data/lib/puppet/file_system/memory_impl.rb +4 -0
- data/lib/puppet/file_system/windows.rb +8 -0
- data/lib/puppet/functions.rb +33 -3
- data/lib/puppet/functions/defined.rb +130 -0
- data/lib/puppet/functions/regsubst.rb +1 -1
- data/lib/puppet/functions/split.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +1 -1
- data/lib/puppet/indirector/facts/facter.rb +11 -0
- data/lib/puppet/loaders.rb +1 -0
- data/lib/puppet/node.rb +17 -1
- data/lib/puppet/node/environment.rb +4 -0
- data/lib/puppet/parser/ast/pops_bridge.rb +4 -0
- data/lib/puppet/parser/compiler.rb +9 -0
- data/lib/puppet/parser/functions/defined.rb +25 -1
- data/lib/puppet/parser/functions/file.rb +3 -1
- data/lib/puppet/parser/scope.rb +11 -2
- data/lib/puppet/parser/templatewrapper.rb +2 -1
- data/lib/puppet/pops.rb +4 -0
- data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
- data/lib/puppet/pops/evaluator/closure.rb +28 -2
- data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
- data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +4 -0
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +4 -0
- data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +7 -2
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +48 -14
- data/lib/puppet/pops/evaluator/runtime3_support.rb +10 -5
- data/lib/puppet/pops/functions/dispatch.rb +6 -1
- data/lib/puppet/pops/functions/dispatcher.rb +7 -1
- data/lib/puppet/pops/issue_reporter.rb +42 -16
- data/lib/puppet/pops/issues.rb +116 -2
- data/lib/puppet/pops/loader/loader.rb +11 -0
- data/lib/puppet/pops/loader/loader_paths.rb +67 -6
- data/lib/puppet/pops/loader/module_loaders.rb +19 -8
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +78 -0
- data/lib/puppet/pops/loaders.rb +6 -4
- data/lib/puppet/pops/migration/migration_checker.rb +54 -0
- data/lib/puppet/pops/model/factory.rb +5 -1
- data/lib/puppet/pops/model/model_label_provider.rb +2 -0
- data/lib/puppet/pops/model/model_meta.rb +5 -1
- data/lib/puppet/pops/parser/egrammar.ra +9 -10
- data/lib/puppet/pops/parser/eparser.rb +1061 -1047
- data/lib/puppet/pops/parser/epp_support.rb +18 -9
- data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
- data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
- data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
- data/lib/puppet/pops/parser/lexer2.rb +29 -12
- data/lib/puppet/pops/parser/lexer_support.rb +52 -23
- data/lib/puppet/pops/parser/parser_support.rb +11 -14
- data/lib/puppet/pops/parser/slurp_support.rb +22 -6
- data/lib/puppet/pops/types/type_calculator.rb +156 -55
- data/lib/puppet/pops/types/type_factory.rb +66 -13
- data/lib/puppet/pops/types/type_parser.rb +22 -13
- data/lib/puppet/pops/types/types.rb +23 -4
- data/lib/puppet/pops/types/types_meta.rb +13 -2
- data/lib/puppet/pops/validation.rb +25 -2
- data/lib/puppet/pops/validation/checker4_0.rb +63 -31
- data/lib/puppet/provider/group/windows_adsi.rb +8 -4
- data/lib/puppet/provider/mount/parsed.rb +145 -2
- data/lib/puppet/provider/package/apt.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +11 -2
- data/lib/puppet/provider/package/pkgng.rb +134 -0
- data/lib/puppet/provider/package/portage.rb +1 -1
- data/lib/puppet/provider/package/ports.rb +0 -3
- data/lib/puppet/provider/package/windows/exe_package.rb +0 -1
- data/lib/puppet/provider/package/windows/msi_package.rb +0 -1
- data/lib/puppet/provider/package/zypper.rb +50 -15
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +32 -7
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +7 -0
- data/lib/puppet/provider/user/openbsd.rb +1 -0
- data/lib/puppet/provider/user/windows_adsi.rb +45 -2
- data/lib/puppet/reference/indirection.rb +1 -1
- data/lib/puppet/resource.rb +1 -1
- data/lib/puppet/resource/catalog.rb +0 -4
- data/lib/puppet/settings.rb +19 -0
- data/lib/puppet/type/file.rb +1 -0
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/mount.rb +9 -1
- data/lib/puppet/type/scheduled_task.rb +13 -0
- data/lib/puppet/type/tidy.rb +3 -1
- data/lib/puppet/type/user.rb +32 -0
- data/lib/puppet/type/yumrepo.rb +5 -5
- data/lib/puppet/util/log.rb +50 -8
- data/lib/puppet/util/log/destinations.rb +23 -2
- data/lib/puppet/util/logging.rb +37 -1
- data/lib/puppet/util/run_mode.rb +1 -14
- data/lib/puppet/util/windows/adsi.rb +130 -58
- data/lib/puppet/version.rb +1 -1
- data/man/man5/puppet.conf.5 +48 -6
- data/man/man8/extlookup2hiera.8 +1 -1
- data/man/man8/puppet-agent.8 +4 -1
- data/man/man8/puppet-apply.8 +4 -1
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +6 -3
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-file.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-inspect.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +4 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-resource_type.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +1 -1
- data/spec/fixtures/unit/data_providers/environments/production/lib/puppet/functions/environment/data.rb +3 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp +6 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +9 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp +9 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json +10 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +1 -10
- data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
- data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
- data/spec/fixtures/unit/provider/package/pkgng/pkg.info +8 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query +1 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +1 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.version +3 -0
- data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out +3 -0
- data/spec/integration/application/apply_spec.rb +49 -0
- data/spec/integration/faces/plugin_spec.rb +0 -4
- data/spec/integration/indirector/facts/facter_spec.rb +59 -0
- data/spec/integration/parser/compiler_spec.rb +850 -0
- data/spec/integration/parser/resource_expressions_spec.rb +3 -0
- data/spec/integration/parser/scope_spec.rb +26 -5
- data/spec/integration/transaction_spec.rb +1 -1
- data/spec/integration/type/file_spec.rb +318 -41
- data/spec/integration/util/windows/security_spec.rb +14 -5
- data/spec/lib/matchers/resource.rb +22 -1
- data/spec/lib/puppet_spec/matchers.rb +6 -4
- data/spec/unit/application/master_spec.rb +33 -7
- data/spec/unit/data_providers/function_data_provider_spec.rb +10 -1
- data/spec/unit/file_serving/metadata_spec.rb +1 -1
- data/spec/unit/file_serving/terminus_helper_spec.rb +2 -3
- data/spec/unit/file_system_spec.rb +38 -0
- data/spec/unit/functions/defined_spec.rb +289 -0
- data/spec/unit/functions/hiera_spec.rb +8 -6
- data/spec/unit/functions/regsubst_spec.rb +4 -0
- data/spec/unit/functions/split_spec.rb +8 -0
- data/spec/unit/functions4_spec.rb +97 -2
- data/spec/unit/indirector/facts/facter_spec.rb +7 -0
- data/spec/unit/node_spec.rb +6 -0
- data/spec/unit/parser/functions/file_spec.rb +7 -1
- data/spec/unit/parser/functions/template_spec.rb +1 -1
- data/spec/unit/parser/scope_spec.rb +2 -2
- data/spec/unit/parser/templatewrapper_spec.rb +1 -1
- data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +84 -18
- data/spec/unit/pops/evaluator/variables_spec.rb +1 -1
- data/spec/unit/pops/issues_spec.rb +16 -16
- data/spec/unit/pops/loaders/loaders_spec.rb +106 -48
- data/spec/unit/pops/migration_spec.rb +53 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +142 -1
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +205 -12
- data/spec/unit/pops/validation_spec.rb +66 -0
- data/spec/unit/pops/validator/validator_spec.rb +1 -1
- data/spec/unit/provider/group/windows_adsi_spec.rb +57 -9
- data/spec/unit/provider/mount/parsed_spec.rb +31 -5
- data/spec/unit/provider/package/apt_spec.rb +5 -0
- data/spec/unit/provider/package/pip_spec.rb +9 -0
- data/spec/unit/provider/package/pkgng_spec.rb +172 -0
- data/spec/unit/provider/package/windows/exe_package_spec.rb +0 -1
- data/spec/unit/provider/package/windows/msi_package_spec.rb +0 -1
- data/spec/unit/provider/package/zypper_spec.rb +50 -19
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
- data/spec/unit/provider/service/base_spec.rb +38 -27
- data/spec/unit/provider/service/debian_spec.rb +8 -0
- data/spec/unit/provider/service/freebsd_spec.rb +1 -0
- data/spec/unit/provider/service/gentoo_spec.rb +1 -0
- data/spec/unit/provider/service/init_spec.rb +18 -0
- data/spec/unit/provider/service/openbsd_spec.rb +1 -0
- data/spec/unit/provider/service/redhat_spec.rb +1 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +134 -5
- data/spec/unit/settings_spec.rb +11 -0
- data/spec/unit/util/log_spec.rb +113 -0
- data/spec/unit/util/windows/adsi_spec.rb +135 -41
- data/spec/unit/util/windows/sid_spec.rb +0 -10
- metadata +48 -2
@@ -4,6 +4,7 @@ require 'puppet/provider/mount'
|
|
4
4
|
fstab = nil
|
5
5
|
case Facter.value(:osfamily)
|
6
6
|
when "Solaris"; fstab = "/etc/vfstab"
|
7
|
+
when "AIX"; fstab = "/etc/filesystems"
|
7
8
|
else
|
8
9
|
fstab = "/etc/fstab"
|
9
10
|
end
|
@@ -25,7 +26,12 @@ Puppet::Type.type(:mount).provide(
|
|
25
26
|
@fields = [:device, :name, :fstype, :options, :dump, :pass]
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
+
if Facter.value(:osfamily) == "AIX"
|
30
|
+
# * is the comment character on AIX /etc/filesystems
|
31
|
+
text_line :comment, :match => /^\s*\*/
|
32
|
+
else
|
33
|
+
text_line :comment, :match => /^\s*#/
|
34
|
+
end
|
29
35
|
text_line :blank, :match => /^\s*$/
|
30
36
|
|
31
37
|
optional_fields = @fields - [:device, :name, :blockdevice]
|
@@ -36,7 +42,144 @@ Puppet::Type.type(:mount).provide(
|
|
36
42
|
field_pattern = '(\s*(?>\S+))'
|
37
43
|
text_line :incomplete, :match => /^(?!#{field_pattern}{#{mandatory_fields.length}})/
|
38
44
|
|
39
|
-
|
45
|
+
case Facter.value(:osfamily)
|
46
|
+
when "AIX"
|
47
|
+
# The only field that is actually ordered is :name. See `man filesystems` on AIX
|
48
|
+
@fields = [:name, :account, :boot, :check, :dev, :free, :mount, :nodename,
|
49
|
+
:options, :quota, :size, :type, :vfs, :vol, :log]
|
50
|
+
self.line_separator = "\n"
|
51
|
+
# Override lines and use scan instead of split, because we DON'T want to
|
52
|
+
# remove the separators
|
53
|
+
def self.lines(text)
|
54
|
+
lines = text.split("\n")
|
55
|
+
filesystem_stanza = false
|
56
|
+
filesystem_index = 0
|
57
|
+
ret = Array.new
|
58
|
+
lines.each_with_index do |line,i|
|
59
|
+
if line.match(%r{^\S+:})
|
60
|
+
# Begin new filesystem stanza and save the index
|
61
|
+
ret[filesystem_index] = filesystem_stanza.join("\n") if filesystem_stanza
|
62
|
+
filesystem_stanza = Array(line)
|
63
|
+
filesystem_index = i
|
64
|
+
# Eat the preceeding blank line
|
65
|
+
ret[i-1] = nil if i > 0 and ret[i-1] and ret[i-1].match(%r{^\s*$})
|
66
|
+
nil
|
67
|
+
elsif line.match(%r{^(\s*\*.*|\s*)$})
|
68
|
+
# Just a comment or blank line; add in place
|
69
|
+
ret[i] = line
|
70
|
+
else
|
71
|
+
# Non-comments or blank lines must be part of a stanza
|
72
|
+
filesystem_stanza << line
|
73
|
+
end
|
74
|
+
end
|
75
|
+
# Add the final stanza to the return
|
76
|
+
ret[filesystem_index] = filesystem_stanza.join("\n") if filesystem_stanza
|
77
|
+
ret = ret.compact.flatten
|
78
|
+
ret.reject { |line| line.match(/^\* HEADER/) }
|
79
|
+
end
|
80
|
+
def self.header
|
81
|
+
super.gsub(/^#/,'*')
|
82
|
+
end
|
83
|
+
|
84
|
+
record_line self.name,
|
85
|
+
:fields => @fields,
|
86
|
+
:separator => /\n/,
|
87
|
+
:block_eval => :instance do
|
88
|
+
|
89
|
+
def post_parse(result)
|
90
|
+
property_map = {
|
91
|
+
:dev => :device,
|
92
|
+
:nodename => :nodename,
|
93
|
+
:options => :options,
|
94
|
+
:vfs => :fstype,
|
95
|
+
}
|
96
|
+
# Result is modified in-place instead of being returned; icky!
|
97
|
+
memo = result.dup
|
98
|
+
result.clear
|
99
|
+
# Save the line for later, just in case it is unparsable
|
100
|
+
result[:line] = @fields.collect do |field|
|
101
|
+
memo[field] if memo[field] != :absent
|
102
|
+
end.compact.join("\n")
|
103
|
+
result[:record_type] = memo[:record_type]
|
104
|
+
special_options = Array.new
|
105
|
+
result[:name] = memo[:name].sub(%r{:\s*$},'').strip
|
106
|
+
memo.each do |_,k_v|
|
107
|
+
if k_v and k_v.is_a?(String) and k_v.match("=")
|
108
|
+
attr_name, attr_value = k_v.split("=",2).map(&:strip)
|
109
|
+
if attr_map_name = property_map[attr_name.to_sym]
|
110
|
+
# These are normal "options" options (see `man filesystems`)
|
111
|
+
result[attr_map_name] = attr_value
|
112
|
+
else
|
113
|
+
# These /etc/filesystem attributes have no mount resource simile,
|
114
|
+
# so are added to the "options" property for puppet's sake
|
115
|
+
special_options << "#{attr_name}=#{attr_value}"
|
116
|
+
end
|
117
|
+
if result[:nodename]
|
118
|
+
result[:device] = "#{result[:nodename]}:#{result[:device]}"
|
119
|
+
result.delete(:nodename)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
result[:options] = [result[:options],special_options.sort].flatten.compact.join(',')
|
124
|
+
if ! result[:device]
|
125
|
+
result[:device] = :absent
|
126
|
+
Puppet.err "Prefetch: Mount[#{result[:name]}]: Field 'device' is missing"
|
127
|
+
end
|
128
|
+
if ! result[:fstype]
|
129
|
+
result[:fstype] = :absent
|
130
|
+
Puppet.err "Prefetch: Mount[#{result[:name]}]: Field 'fstype' is missing"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
def to_line(result)
|
134
|
+
output = Array.new
|
135
|
+
output << "#{result[:name]}:"
|
136
|
+
if result[:device] and result[:device].match(%r{^/})
|
137
|
+
output << "\tdev\t\t= #{result[:device]}"
|
138
|
+
elsif result[:device] and result[:device] != :absent
|
139
|
+
if ! result[:device].match(%{^.+:/})
|
140
|
+
# Just skip this entry; it was malformed to begin with
|
141
|
+
Puppet.err "Mount[#{result[:name]}]: Field 'device' must be in the format of <absolute path> or <host>:<absolute path>"
|
142
|
+
return result[:line]
|
143
|
+
end
|
144
|
+
nodename, path = result[:device].split(":")
|
145
|
+
output << "\tdev\t\t= #{path}"
|
146
|
+
output << "\tnodename\t= #{nodename}"
|
147
|
+
else
|
148
|
+
# Just skip this entry; it was malformed to begin with
|
149
|
+
Puppet.err "Mount[#{result[:name]}]: Field 'device' is required"
|
150
|
+
return result[:line]
|
151
|
+
end
|
152
|
+
if result[:fstype] and result[:fstype] != :absent
|
153
|
+
output << "\tvfs\t\t= #{result[:fstype]}"
|
154
|
+
else
|
155
|
+
# Just skip this entry; it was malformed to begin with
|
156
|
+
Puppet.err "Mount[#{result[:name]}]: Field 'device' is required"
|
157
|
+
return result[:line]
|
158
|
+
end
|
159
|
+
if result[:options]
|
160
|
+
options = result[:options].split(',')
|
161
|
+
special_options = options.select do |x|
|
162
|
+
x.match('=') and
|
163
|
+
["account", "boot", "check", "free", "mount", "size", "type",
|
164
|
+
"vol", "log", "quota"].include? x.split('=').first
|
165
|
+
end
|
166
|
+
options = options - special_options
|
167
|
+
special_options.sort.each do |x|
|
168
|
+
k, v = x.split("=")
|
169
|
+
output << "\t#{k}\t\t= #{v}"
|
170
|
+
end
|
171
|
+
output << "\toptions\t\t= #{options.join(",")}" unless options.empty?
|
172
|
+
end
|
173
|
+
if result[:line] and result[:line].split("\n").sort == output.sort
|
174
|
+
return "\n#{result[:line]}"
|
175
|
+
else
|
176
|
+
return "\n#{output.join("\n")}"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
else
|
181
|
+
record_line self.name, :fields => @fields, :separator => /\s+/, :joiner => "\t", :optional => optional_fields
|
182
|
+
end
|
40
183
|
|
41
184
|
# Every entry in fstab is :unmounted until we can prove different
|
42
185
|
def self.prefetch_hook(target_records)
|
@@ -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 :
|
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
|
-
|
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.
|
39
|
-
#SLE 11.
|
40
|
-
#
|
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
|
-
|
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
|
61
|
-
|
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
|
-
|
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
|
-
|
84
|
-
end
|
119
|
+
@property_hash[:ensure]
|
85
120
|
end
|
86
121
|
|
87
122
|
def update
|