puppet 2.7.1 → 2.7.3
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.
- data/CHANGELOG +225 -1
- data/CONTRIBUTING.md +299 -0
- data/README.md +0 -1
- data/conf/redhat/puppet.spec +132 -25
- data/conf/solaris/pkginfo +1 -1
- data/conf/suse/puppet.spec +5 -2
- data/ext/envpuppet +56 -3
- data/ext/vim/README +2 -1
- data/ext/vim/ftplugin/puppet.vim +94 -0
- data/ext/vim/indent/puppet.vim +76 -0
- data/lib/puppet.rb +2 -3
- data/lib/puppet/application/agent.rb +7 -7
- data/lib/puppet/application/apply.rb +20 -8
- data/lib/puppet/application/ca.rb +5 -0
- data/lib/puppet/application/cert.rb +2 -1
- data/lib/puppet/application/certificate.rb +0 -5
- data/lib/puppet/application/device.rb +4 -4
- data/lib/puppet/application/doc.rb +23 -12
- data/lib/puppet/application/face_base.rb +2 -1
- data/lib/puppet/application/inspect.rb +5 -2
- data/lib/puppet/configurer.rb +60 -56
- data/lib/puppet/configurer/fact_handler.rb +6 -1
- data/lib/puppet/defaults.rb +20 -1
- data/lib/puppet/face/ca.rb +233 -0
- data/lib/puppet/face/certificate.rb +15 -11
- data/lib/puppet/face/certificate_request.rb +9 -11
- data/lib/puppet/face/certificate_revocation_list.rb +5 -7
- data/lib/puppet/face/node/clean.rb +154 -0
- data/lib/puppet/face/status.rb +1 -0
- data/lib/puppet/file_serving/configuration/parser.rb +6 -13
- data/lib/puppet/indirector/exec.rb +3 -3
- data/lib/puppet/indirector/face.rb +17 -7
- data/lib/puppet/indirector/report/processor.rb +29 -16
- data/lib/puppet/indirector/rest.rb +42 -7
- data/lib/puppet/indirector/yaml.rb +5 -0
- data/lib/puppet/interface.rb +7 -2
- data/lib/puppet/interface/action.rb +57 -23
- data/lib/puppet/interface/action_manager.rb +10 -5
- data/lib/puppet/interface/face_collection.rb +43 -52
- data/lib/puppet/interface/option.rb +19 -0
- data/lib/puppet/interface/option_builder.rb +13 -0
- data/lib/puppet/interface/option_manager.rb +2 -1
- data/lib/puppet/metatype/manager.rb +7 -20
- data/lib/puppet/module.rb +4 -1
- data/lib/puppet/network/authconfig.rb +3 -1
- data/lib/puppet/network/authstore.rb +14 -5
- data/lib/puppet/network/handler/fileserver.rb +3 -0
- data/lib/puppet/network/http/webrick.rb +1 -1
- data/lib/puppet/network/rest_authconfig.rb +6 -1
- data/lib/puppet/network/rest_authorization.rb +1 -1
- data/lib/puppet/parser/compiler.rb +8 -11
- data/lib/puppet/parser/functions.rb +1 -6
- data/lib/puppet/parser/functions/create_resources.rb +6 -5
- data/lib/puppet/parser/functions/regsubst.rb +26 -0
- data/lib/puppet/parser/functions/shellquote.rb +26 -0
- data/lib/puppet/parser/functions/sprintf.rb +26 -0
- data/lib/puppet/parser/grammar.ra +34 -60
- data/lib/puppet/parser/lexer.rb +5 -5
- data/lib/puppet/parser/parser.rb +913 -1196
- data/lib/puppet/parser/resource.rb +18 -1
- data/lib/puppet/parser/scope.rb +2 -2
- data/lib/puppet/provider/augeas/augeas.rb +42 -17
- data/lib/puppet/provider/mount/parsed.rb +19 -1
- data/lib/puppet/provider/naginator.rb +9 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +11 -8
- data/lib/puppet/provider/network_device.rb +1 -1
- data/lib/puppet/provider/package/aptitude.rb +1 -0
- data/lib/puppet/provider/package/pacman.rb +94 -0
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +0 -6
- data/lib/puppet/rails/host.rb +7 -0
- data/lib/puppet/reports/store.rb +15 -0
- data/lib/puppet/resource/catalog.rb +15 -6
- data/lib/puppet/ssl/certificate.rb +6 -0
- data/lib/puppet/ssl/inventory.rb +2 -0
- data/lib/puppet/transaction.rb +9 -17
- data/lib/puppet/transaction/report.rb +3 -3
- data/lib/puppet/type.rb +13 -24
- data/lib/puppet/type/file.rb +8 -2
- data/lib/puppet/type/file/source.rb +2 -2
- data/lib/puppet/type/service.rb +20 -24
- data/lib/puppet/type/ssh_authorized_key.rb +12 -0
- data/lib/puppet/type/user.rb +8 -0
- data/lib/puppet/util.rb +0 -1
- data/lib/puppet/util/network_device.rb +3 -3
- data/lib/puppet/util/settings.rb +1 -1
- data/lib/puppet/util/settings/file_setting.rb +1 -0
- data/lib/semver.rb +65 -0
- data/spec/integration/defaults_spec.rb +23 -1
- data/spec/integration/network/rest_authconfig_spec.rb +145 -0
- data/spec/integration/node/facts_spec.rb +1 -1
- data/spec/integration/parser/functions_spec.rb +1 -1
- data/spec/integration/parser/parser_spec.rb +31 -0
- data/spec/integration/provider/ssh_authorized_key_spec.rb +207 -0
- data/spec/integration/type_spec.rb +11 -0
- data/spec/lib/puppet/face/1.0.0/huzzah.rb +8 -0
- data/spec/lib/puppet/face/huzzah.rb +1 -0
- data/spec/lib/puppet/face/huzzah/obsolete.rb +6 -0
- data/spec/shared_behaviours/things_that_declare_options.rb +115 -3
- data/spec/unit/application/agent_spec.rb +2 -2
- data/spec/unit/application/apply_spec.rb +74 -56
- data/spec/unit/application/cert_spec.rb +10 -0
- data/spec/unit/application/device_spec.rb +2 -3
- data/spec/unit/application/face_base_spec.rb +1 -0
- data/spec/unit/application/facts_spec.rb +1 -0
- data/spec/unit/application/inspect_spec.rb +5 -0
- data/spec/unit/configurer/fact_handler_spec.rb +45 -37
- data/spec/unit/configurer_spec.rb +405 -327
- data/spec/unit/face/ca_spec.rb +355 -0
- data/spec/unit/face/certificate_spec.rb +16 -4
- data/spec/unit/face/node_spec.rb +261 -1
- data/spec/unit/file_serving/configuration/parser_spec.rb +8 -0
- data/spec/unit/indirector/certificate/rest_spec.rb +1 -0
- data/spec/unit/indirector/certificate_status/file_spec.rb +4 -0
- data/spec/unit/indirector/exec_spec.rb +4 -4
- data/spec/unit/indirector/face_spec.rb +3 -1
- data/spec/unit/indirector/facts/couch_spec.rb +2 -2
- data/spec/unit/indirector/facts/network_device_spec.rb +2 -6
- data/spec/unit/indirector/node/exec_spec.rb +1 -1
- data/spec/unit/indirector/report/processor_spec.rb +31 -8
- data/spec/unit/indirector/rest_spec.rb +53 -5
- data/spec/unit/indirector/yaml_spec.rb +18 -0
- data/spec/unit/interface/action_spec.rb +112 -8
- data/spec/unit/interface/face_collection_spec.rb +46 -36
- data/spec/unit/interface/option_spec.rb +44 -0
- data/spec/unit/interface_spec.rb +11 -6
- data/spec/unit/module_spec.rb +38 -9
- data/spec/unit/network/authconfig_spec.rb +23 -0
- data/spec/unit/network/authstore_spec.rb +36 -4
- data/spec/unit/network/handler/fileserver_spec.rb +32 -0
- data/spec/unit/network/rest_authconfig_spec.rb +1 -1
- data/spec/unit/node_spec.rb +1 -0
- data/spec/unit/parser/compiler_spec.rb +8 -46
- data/spec/unit/parser/lexer_spec.rb +27 -17
- data/spec/unit/parser/resource_spec.rb +61 -3
- data/spec/unit/parser/scope_spec.rb +5 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +106 -1
- data/spec/unit/provider/cisco_spec.rb +3 -4
- data/spec/unit/provider/interface/cisco_spec.rb +1 -2
- data/spec/unit/provider/mount/parsed_spec.rb +41 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +60 -0
- data/spec/unit/provider/network_device_spec.rb +1 -2
- data/spec/unit/provider/package/pacman_spec.rb +237 -0
- data/spec/unit/provider/package/pkgutil_spec.rb +2 -3
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +21 -32
- data/spec/unit/provider/vlan/cisco_spec.rb +1 -2
- data/spec/unit/rails/host_spec.rb +8 -0
- data/spec/unit/resource/catalog_spec.rb +55 -8
- data/spec/unit/semver_spec.rb +187 -0
- data/spec/unit/ssl/certificate_spec.rb +25 -0
- data/spec/unit/transaction/report_spec.rb +3 -3
- data/spec/unit/transaction_spec.rb +8 -2
- data/spec/unit/type/file_spec.rb +57 -0
- data/spec/unit/type/interface_spec.rb +1 -2
- data/spec/unit/type/schedule_spec.rb +73 -42
- data/spec/unit/type/ssh_authorized_key_spec.rb +180 -70
- data/spec/unit/type/user_spec.rb +8 -0
- data/spec/unit/type/vlan_spec.rb +1 -2
- data/spec/unit/type_spec.rb +66 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -2
- data/spec/unit/util/network_device/cisco/facts_spec.rb +2 -3
- data/spec/unit/util/network_device/cisco/interface_spec.rb +1 -2
- data/spec/unit/util/network_device/config_spec.rb +3 -4
- data/spec/unit/util/network_device/ipcalc_spec.rb +1 -2
- data/spec/unit/util/network_device/transport/base_spec.rb +1 -2
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -2
- data/spec/unit/util/network_device/transport/telnet_spec.rb +1 -2
- data/spec/unit/util/network_device_spec.rb +2 -2
- data/spec/unit/util/settings/file_setting_spec.rb +4 -0
- data/spec/unit/util/settings_spec.rb +11 -0
- data/test/lib/puppettest/railstesting.rb +0 -34
- metadata +19 -4
@@ -27,6 +27,12 @@ class Puppet::SSL::Certificate < Puppet::SSL::Base
|
|
27
27
|
[:s]
|
28
28
|
end
|
29
29
|
|
30
|
+
def alternate_names
|
31
|
+
alts = content.extensions.find{|ext| ext.oid == "subjectAltName"}
|
32
|
+
return [] unless alts
|
33
|
+
alts.value.split(/,\s+/).map{|al| al.sub(/^DNS:/,'')}
|
34
|
+
end
|
35
|
+
|
30
36
|
def expiration
|
31
37
|
return nil unless content
|
32
38
|
content.not_after
|
data/lib/puppet/ssl/inventory.rb
CHANGED
data/lib/puppet/transaction.rb
CHANGED
@@ -16,7 +16,7 @@ class Puppet::Transaction
|
|
16
16
|
attr_accessor :configurator
|
17
17
|
|
18
18
|
# The report, once generated.
|
19
|
-
|
19
|
+
attr_reader :report
|
20
20
|
|
21
21
|
# Routes and stores any events and subscriptions.
|
22
22
|
attr_reader :event_manager
|
@@ -92,25 +92,17 @@ class Puppet::Transaction
|
|
92
92
|
# collects all of the changes, executes them, and responds to any
|
93
93
|
# necessary events.
|
94
94
|
def evaluate
|
95
|
-
# Start logging.
|
96
|
-
Puppet::Util::Log.newdestination(@report)
|
97
|
-
|
98
95
|
prepare
|
99
96
|
|
100
97
|
Puppet.info "Applying configuration version '#{catalog.version}'" if catalog.version
|
101
98
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
resource.info "Evaluated in %0.2f seconds" % seconds if Puppet[:evaltrace] and @catalog.host_config?
|
109
|
-
end
|
99
|
+
relationship_graph.traverse do |resource|
|
100
|
+
if resource.is_a?(Puppet::Type::Component)
|
101
|
+
Puppet.warning "Somehow left a component in the relationship graph"
|
102
|
+
else
|
103
|
+
seconds = thinmark { eval_resource(resource) }
|
104
|
+
resource.info "Evaluated in %0.2f seconds" % seconds if Puppet[:evaltrace] and @catalog.host_config?
|
110
105
|
end
|
111
|
-
ensure
|
112
|
-
# And then close the transaction log.
|
113
|
-
Puppet::Util::Log.close(@report)
|
114
106
|
end
|
115
107
|
|
116
108
|
Puppet.debug "Finishing transaction #{object_id}"
|
@@ -221,10 +213,10 @@ class Puppet::Transaction
|
|
221
213
|
|
222
214
|
# this should only be called by a Puppet::Type::Component resource now
|
223
215
|
# and it should only receive an array
|
224
|
-
def initialize(catalog)
|
216
|
+
def initialize(catalog, report = nil)
|
225
217
|
@catalog = catalog
|
226
218
|
|
227
|
-
@report = Puppet::Transaction::Report.new("apply")
|
219
|
+
@report = report || Puppet::Transaction::Report.new("apply", catalog.version)
|
228
220
|
|
229
221
|
@event_manager = Puppet::Transaction::EventManager.new(self)
|
230
222
|
|
@@ -10,8 +10,8 @@ class Puppet::Transaction::Report
|
|
10
10
|
|
11
11
|
indirects :report, :terminus_class => :processor
|
12
12
|
|
13
|
-
attr_accessor :configuration_version
|
14
|
-
attr_reader :resource_statuses, :logs, :metrics, :
|
13
|
+
attr_accessor :configuration_version, :host
|
14
|
+
attr_reader :resource_statuses, :logs, :metrics, :time, :kind, :status
|
15
15
|
|
16
16
|
# This is necessary since Marshall doesn't know how to
|
17
17
|
# dump hash with default proc (see below @records)
|
@@ -73,7 +73,7 @@ class Puppet::Transaction::Report
|
|
73
73
|
@logs = []
|
74
74
|
@resource_statuses = {}
|
75
75
|
@external_times ||= {}
|
76
|
-
@host = Puppet[:
|
76
|
+
@host = Puppet[:node_name_value]
|
77
77
|
@time = Time.now
|
78
78
|
@kind = kind
|
79
79
|
@report_format = 2
|
data/lib/puppet/type.rb
CHANGED
@@ -1442,9 +1442,8 @@ class Type
|
|
1442
1442
|
def self.provide(name, options = {}, &block)
|
1443
1443
|
name = Puppet::Util.symbolize(name)
|
1444
1444
|
|
1445
|
-
if
|
1445
|
+
if unprovide(name)
|
1446
1446
|
Puppet.debug "Reloading #{name} #{self.name} provider"
|
1447
|
-
unprovide(name)
|
1448
1447
|
end
|
1449
1448
|
|
1450
1449
|
parent = if pname = options[:parent]
|
@@ -1467,16 +1466,14 @@ class Type
|
|
1467
1466
|
|
1468
1467
|
self.providify
|
1469
1468
|
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
:
|
1474
|
-
:
|
1475
|
-
:
|
1476
|
-
:
|
1477
|
-
:
|
1478
|
-
:extend => feature_module,
|
1479
|
-
|
1469
|
+
provider = genclass(
|
1470
|
+
name,
|
1471
|
+
:parent => parent,
|
1472
|
+
:hash => provider_hash,
|
1473
|
+
:prefix => "Provider",
|
1474
|
+
:block => block,
|
1475
|
+
:include => feature_module,
|
1476
|
+
:extend => feature_module,
|
1480
1477
|
:attributes => options
|
1481
1478
|
)
|
1482
1479
|
|
@@ -1536,18 +1533,11 @@ class Type
|
|
1536
1533
|
end
|
1537
1534
|
|
1538
1535
|
def self.unprovide(name)
|
1539
|
-
if
|
1540
|
-
|
1541
|
-
rmclass(
|
1542
|
-
name,
|
1543
|
-
:hash => provider_hash,
|
1544
|
-
|
1545
|
-
:prefix => "Provider"
|
1546
|
-
)
|
1547
|
-
if @defaultprovider and @defaultprovider.name == name
|
1548
|
-
@defaultprovider = nil
|
1549
|
-
end
|
1536
|
+
if @defaultprovider and @defaultprovider.name == name
|
1537
|
+
@defaultprovider = nil
|
1550
1538
|
end
|
1539
|
+
|
1540
|
+
rmclass(name, :hash => provider_hash, :prefix => "Provider")
|
1551
1541
|
end
|
1552
1542
|
|
1553
1543
|
# Return an array of all of the suitable providers.
|
@@ -1607,7 +1597,6 @@ class Type
|
|
1607
1597
|
|
1608
1598
|
# Collect the current prereqs
|
1609
1599
|
list.each { |dep|
|
1610
|
-
obj = nil
|
1611
1600
|
# Support them passing objects directly, to save some effort.
|
1612
1601
|
unless dep.is_a? Puppet::Type
|
1613
1602
|
# Skip autorequires that we aren't managing
|
data/lib/puppet/type/file.rb
CHANGED
@@ -257,11 +257,17 @@ Puppet::Type.newtype(:file) do
|
|
257
257
|
newvalues(:first, :all)
|
258
258
|
end
|
259
259
|
|
260
|
-
# Autorequire
|
260
|
+
# Autorequire the nearest ancestor directory found in the catalog.
|
261
261
|
autorequire(:file) do
|
262
262
|
basedir = ::File.dirname(self[:path])
|
263
263
|
if basedir != self[:path]
|
264
|
-
|
264
|
+
parents = []
|
265
|
+
until basedir == parents.last
|
266
|
+
parents << basedir
|
267
|
+
basedir = ::File.dirname(basedir)
|
268
|
+
end
|
269
|
+
# The filename of the first ancestor found, or nil
|
270
|
+
parents.find { |dir| catalog.resource(:file, dir) }
|
265
271
|
else
|
266
272
|
nil
|
267
273
|
end
|
@@ -42,7 +42,7 @@ module Puppet
|
|
42
42
|
on the local host, whereas `agent` will connect to the
|
43
43
|
puppet server that it received the manifest from.
|
44
44
|
|
45
|
-
See the [fileserver configuration documentation](http://
|
45
|
+
See the [fileserver configuration documentation](http://docs.puppetlabs.com/guides/file_serving.html) for information on how to configure
|
46
46
|
and use file services within Puppet.
|
47
47
|
|
48
48
|
If you specify multiple file sources for a file, then the first
|
@@ -154,7 +154,7 @@ module Puppet
|
|
154
154
|
fail detail, "Could not retrieve file metadata for #{source}: #{detail}"
|
155
155
|
end
|
156
156
|
end
|
157
|
-
fail "Could not retrieve information from source(s) #{value.join(", ")}" unless result
|
157
|
+
fail "Could not retrieve information from environment #{Puppet[:environment]} source(s) #{value.join(", ")}" unless result
|
158
158
|
result
|
159
159
|
end
|
160
160
|
|
data/lib/puppet/type/service.rb
CHANGED
@@ -8,17 +8,15 @@ module Puppet
|
|
8
8
|
|
9
9
|
newtype(:service) do
|
10
10
|
@doc = "Manage running services. Service support unfortunately varies
|
11
|
-
widely by platform --- some platforms have very little if any
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
behavior on restarts if you don't specify `hasstatus` or a `status`
|
21
|
-
command.
|
11
|
+
widely by platform --- some platforms have very little if any concept of a
|
12
|
+
running service, and some have a very codified and powerful concept.
|
13
|
+
Puppet's service support is usually capable of doing the right thing, but
|
14
|
+
the more information you can provide, the better behaviour you will get.
|
15
|
+
|
16
|
+
Puppet 2.7 and newer expect init scripts to have a working status command.
|
17
|
+
If this isn't the case for any of your services' init scripts, you will
|
18
|
+
need to set `hasstatus` to false and possibly specify a custom status
|
19
|
+
command in the `status` attribute.
|
22
20
|
|
23
21
|
Note that if a `service` receives an event from another resource,
|
24
22
|
the service will get restarted. The actual command to restart the
|
@@ -93,19 +91,17 @@ module Puppet
|
|
93
91
|
end
|
94
92
|
|
95
93
|
newparam(:hasstatus) do
|
96
|
-
desc "Declare
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
`status` attribute
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
(via notify and subscribe relationships) if you don't override
|
108
|
-
this default behavior."
|
94
|
+
desc "Declare whether the service's init script has a functional status
|
95
|
+
command; defaults to `true`. This attribute's default value changed in
|
96
|
+
Puppet 2.7.0.
|
97
|
+
|
98
|
+
If a service's init script does not support any kind of status command,
|
99
|
+
you should set `hasstatus` to false and either provide a specific
|
100
|
+
command using the `status` attribute or expect that Puppet will look for
|
101
|
+
the service name in the process table. Be aware that 'virtual' init
|
102
|
+
scripts (like 'network' under Red Hat systems) will respond poorly to
|
103
|
+
refresh events from other resources if you override the default behavior
|
104
|
+
without providing a status command."
|
109
105
|
|
110
106
|
newvalues(:true, :false)
|
111
107
|
|
@@ -14,6 +14,10 @@ module Puppet
|
|
14
14
|
system-wide primary key and therefore has to be unique."
|
15
15
|
|
16
16
|
isnamevar
|
17
|
+
|
18
|
+
validate do |value|
|
19
|
+
raise Puppet::Error, "Resourcename must not contain whitespace: #{value}" if value =~ /\s/
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
newproperty(:type) do
|
@@ -28,6 +32,10 @@ module Puppet
|
|
28
32
|
|
29
33
|
newproperty(:key) do
|
30
34
|
desc "The key itself; generally a long string of hex digits."
|
35
|
+
|
36
|
+
validate do |value|
|
37
|
+
raise Puppet::Error, "Key must not contain whitespace: #{value}" if value =~ /\s/
|
38
|
+
end
|
31
39
|
end
|
32
40
|
|
33
41
|
newproperty(:user) do
|
@@ -82,6 +90,10 @@ module Puppet
|
|
82
90
|
value.join(",")
|
83
91
|
end
|
84
92
|
end
|
93
|
+
|
94
|
+
validate do |value|
|
95
|
+
raise Puppet::Error, "Options must be provided as an array, not a comma separated list" if value != :absent and value.include?(',')
|
96
|
+
end
|
85
97
|
end
|
86
98
|
|
87
99
|
autorequire(:user) do
|
data/lib/puppet/type/user.rb
CHANGED
@@ -168,6 +168,14 @@ module Puppet
|
|
168
168
|
return "changed password"
|
169
169
|
end
|
170
170
|
end
|
171
|
+
|
172
|
+
def is_to_s( currentvalue )
|
173
|
+
return '[old password hash redacted]'
|
174
|
+
end
|
175
|
+
def should_to_s( newvalue )
|
176
|
+
return '[new password hash redacted]'
|
177
|
+
end
|
178
|
+
|
171
179
|
end
|
172
180
|
|
173
181
|
newproperty(:password_min_age, :required_features => :manages_password_age) do
|
data/lib/puppet/util.rb
CHANGED
data/lib/puppet/util/settings.rb
CHANGED
@@ -101,6 +101,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
|
|
101
101
|
|
102
102
|
resource[:ensure] = type
|
103
103
|
resource[:loglevel] = :debug
|
104
|
+
resource[:links] = :follow
|
104
105
|
resource[:backup] = false
|
105
106
|
|
106
107
|
resource.tag(self.section, self.name, "settings")
|
data/lib/semver.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
class SemVer
|
2
|
+
VERSION = /^v?(\d+)\.(\d+)\.(\d+)([A-Za-z][0-9A-Za-z-]*|)$/
|
3
|
+
SIMPLE_RANGE = /^v?(\d+|[xX])(?:\.(\d+|[xX])(?:\.(\d+|[xX]))?)?$/
|
4
|
+
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
def self.valid?(ver)
|
8
|
+
VERSION =~ ver
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find_matching(pattern, versions)
|
12
|
+
versions.select { |v| v.matched_by?("#{pattern}") }.sort.last
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :major, :minor, :tiny, :special
|
16
|
+
|
17
|
+
def initialize(ver)
|
18
|
+
unless SemVer.valid?(ver)
|
19
|
+
raise ArgumentError.new("Invalid version string '#{ver}'!")
|
20
|
+
end
|
21
|
+
|
22
|
+
@major, @minor, @tiny, @special = VERSION.match(ver).captures.map do |x|
|
23
|
+
# Because Kernel#Integer tries to interpret hex and octal strings, which
|
24
|
+
# we specifically do not want, and which cannot be overridden in 1.8.7.
|
25
|
+
Float(x).to_i rescue x
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def <=>(other)
|
30
|
+
other = SemVer.new("#{other}") unless other.is_a? SemVer
|
31
|
+
return self.major <=> other.major unless self.major == other.major
|
32
|
+
return self.minor <=> other.minor unless self.minor == other.minor
|
33
|
+
return self.tiny <=> other.tiny unless self.tiny == other.tiny
|
34
|
+
|
35
|
+
return 0 if self.special == other.special
|
36
|
+
return 1 if self.special == ''
|
37
|
+
return -1 if other.special == ''
|
38
|
+
|
39
|
+
return self.special <=> other.special
|
40
|
+
end
|
41
|
+
|
42
|
+
def matched_by?(pattern)
|
43
|
+
# For the time being, this is restricted to exact version matches and
|
44
|
+
# simple range patterns. In the future, we should implement some or all of
|
45
|
+
# the comparison operators here:
|
46
|
+
# https://github.com/isaacs/node-semver/blob/d474801/semver.js#L340
|
47
|
+
|
48
|
+
case pattern
|
49
|
+
when SIMPLE_RANGE
|
50
|
+
pattern = SIMPLE_RANGE.match(pattern).captures
|
51
|
+
pattern[1] = @minor unless pattern[1] && pattern[1] !~ /x/i
|
52
|
+
pattern[2] = @tiny unless pattern[2] && pattern[2] !~ /x/i
|
53
|
+
[@major, @minor, @tiny] == pattern.map { |x| x.to_i }
|
54
|
+
when VERSION
|
55
|
+
self == SemVer.new(pattern)
|
56
|
+
else
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def inspect
|
62
|
+
"v#{@major}.#{@minor}.#{@tiny}#{@special}"
|
63
|
+
end
|
64
|
+
alias :to_s :inspect
|
65
|
+
end
|
@@ -22,6 +22,28 @@ describe "Puppet defaults" do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
describe "when setting :node_name_value" do
|
26
|
+
it "should default to the value of :certname" do
|
27
|
+
Puppet.settings[:certname] = 'blargle'
|
28
|
+
Puppet.settings[:node_name_value].should == 'blargle'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when setting the :node_name_fact" do
|
33
|
+
it "should fail when also setting :node_name_value" do
|
34
|
+
lambda do
|
35
|
+
Puppet.settings[:node_name_value] = "some value"
|
36
|
+
Puppet.settings[:node_name_fact] = "some_fact"
|
37
|
+
end.should raise_error("Cannot specify both the node_name_value and node_name_fact settings")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should not fail when using the default for :node_name_value" do
|
41
|
+
lambda do
|
42
|
+
Puppet.settings[:node_name_fact] = "some_fact"
|
43
|
+
end.should_not raise_error
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
25
47
|
describe "when configuring the :crl" do
|
26
48
|
it "should warn if :cacrl is set to false" do
|
27
49
|
Puppet.expects(:warning)
|
@@ -253,6 +275,6 @@ describe "Puppet defaults" do
|
|
253
275
|
|
254
276
|
describe "reporturl" do
|
255
277
|
subject { Puppet.settings[:reporturl] }
|
256
|
-
it { should == "http://localhost:3000/reports" }
|
278
|
+
it { should == "http://localhost:3000/reports/upload" }
|
257
279
|
end
|
258
280
|
end
|