puppet 2.6.4 → 2.6.5
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 +147 -0
- data/LICENSE +2 -2
- data/Rakefile +3 -4
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application.rb +22 -5
- data/lib/puppet/application/apply.rb +2 -18
- data/lib/puppet/application/doc.rb +1 -4
- data/lib/puppet/application/inspect.rb +178 -0
- data/lib/puppet/configurer.rb +9 -11
- data/lib/puppet/configurer/plugin_handler.rb +0 -2
- data/lib/puppet/defaults.rb +12 -3
- data/lib/puppet/external/pson/pure/generator.rb +1 -22
- data/lib/puppet/file_bucket/dipper.rb +9 -3
- data/lib/puppet/file_bucket/file.rb +14 -94
- data/lib/puppet/indirector.rb +4 -0
- data/lib/puppet/indirector/catalog/active_record.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +64 -75
- data/lib/puppet/indirector/indirection.rb +18 -8
- data/lib/puppet/indirector/resource/ral.rb +7 -2
- data/lib/puppet/indirector/rest.rb +19 -2
- data/lib/puppet/network/http/api/v1.rb +3 -0
- data/lib/puppet/network/http/handler.rb +16 -1
- data/lib/puppet/network/http/rack/rest.rb +1 -3
- data/lib/puppet/network/rest_authconfig.rb +4 -12
- data/lib/puppet/network/rights.rb +28 -14
- data/lib/puppet/parser/ast.rb +4 -0
- data/lib/puppet/parser/compiler.rb +18 -3
- data/lib/puppet/parser/functions/defined.rb +28 -6
- data/lib/puppet/parser/functions/fqdn_rand.rb +6 -3
- data/lib/puppet/parser/templatewrapper.rb +1 -0
- data/lib/puppet/property.rb +16 -1
- data/lib/puppet/property/keyvalue.rb +0 -2
- data/lib/puppet/property/list.rb +0 -2
- data/lib/puppet/provider/file/posix.rb +1 -3
- data/lib/puppet/provider/file/win32.rb +1 -3
- data/lib/puppet/provider/maillist/mailman.rb +3 -5
- data/lib/puppet/provider/mount.rb +2 -0
- data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
- data/lib/puppet/provider/package/freebsd.rb +2 -2
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/reference/configuration.rb +2 -2
- data/lib/puppet/reference/function.rb +4 -0
- data/lib/puppet/relationship.rb +4 -0
- data/lib/puppet/reports/store.rb +1 -19
- data/lib/puppet/resource.rb +11 -2
- data/lib/puppet/resource/status.rb +24 -3
- data/lib/puppet/resource/type.rb +24 -16
- data/lib/puppet/resource/type_collection.rb +4 -1
- data/lib/puppet/simple_graph.rb +4 -0
- data/lib/puppet/transaction.rb +1 -28
- data/lib/puppet/transaction/event.rb +9 -4
- data/lib/puppet/transaction/report.rb +42 -22
- data/lib/puppet/transaction/resource_harness.rb +99 -71
- data/lib/puppet/type.rb +22 -9
- data/lib/puppet/type/cron.rb +1 -5
- data/lib/puppet/type/exec.rb +4 -34
- data/lib/puppet/type/file.rb +19 -26
- data/lib/puppet/type/file/checksum.rb +1 -1
- data/lib/puppet/type/file/content.rb +2 -1
- data/lib/puppet/type/file/ctime.rb +18 -0
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +10 -44
- data/lib/puppet/type/file/mtime.rb +17 -0
- data/lib/puppet/type/file/owner.rb +1 -1
- data/lib/puppet/type/file/source.rb +0 -1
- data/lib/puppet/type/file/target.rb +1 -1
- data/lib/puppet/type/file/type.rb +5 -12
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/mount.rb +2 -2
- data/lib/puppet/type/package.rb +0 -2
- data/lib/puppet/type/service.rb +11 -5
- data/lib/puppet/type/user.rb +7 -9
- data/lib/puppet/type/yumrepo.rb +2 -2
- data/lib/puppet/type/zpool.rb +0 -4
- data/lib/puppet/util/checksums.rb +24 -1
- data/lib/puppet/util/command_line.rb +6 -2
- data/lib/puppet/util/command_line/puppet +5 -1
- data/lib/puppet/util/command_line/puppetca +2 -2
- data/lib/puppet/util/command_line/puppetd +11 -9
- data/lib/puppet/util/command_line/puppetdoc +2 -2
- data/lib/puppet/util/command_line/puppetmasterd +5 -0
- data/lib/puppet/util/log.rb +15 -8
- data/lib/puppet/util/log/destinations.rb +2 -0
- data/lib/puppet/util/log_paths.rb +1 -1
- data/lib/puppet/util/logging.rb +1 -1
- data/lib/puppet/util/metric.rb +1 -0
- data/lib/puppet/util/reference.rb +1 -10
- data/lib/puppet/util/settings.rb +1 -1
- data/lib/puppet/util/zaml.rb +30 -31
- data/spec/fixtures/unit/provider/mount/mount-output.aix.txt +7 -0
- data/spec/integration/application/apply_spec.rb +1 -2
- data/spec/integration/defaults_spec.rb +1 -0
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -4
- data/spec/integration/indirector/report/rest_spec.rb +13 -17
- data/spec/integration/network/formats_spec.rb +2 -5
- data/spec/integration/network/server/mongrel_spec.rb +1 -2
- data/spec/integration/provider/mailalias/aliases_spec.rb +0 -1
- data/spec/integration/provider/package_spec.rb +1 -3
- data/spec/integration/provider/service/init_spec.rb +3 -9
- data/spec/integration/reference/providers_spec.rb +2 -2
- data/spec/integration/resource/catalog_spec.rb +1 -2
- data/spec/integration/transaction/report_spec.rb +1 -1
- data/spec/monkey_patches/alias_should_to_must.rb +2 -0
- data/spec/shared_behaviours/file_server_terminus.rb +1 -1
- data/spec/shared_behaviours/file_serving.rb +1 -1
- data/spec/shared_behaviours/memory_terminus.rb +1 -1
- data/spec/spec_helper.rb +8 -6
- data/spec/unit/application/agent_spec.rb +1 -0
- data/spec/unit/application/apply_spec.rb +7 -7
- data/spec/unit/application/doc_spec.rb +2 -2
- data/spec/unit/application/filebucket_spec.rb +1 -0
- data/spec/unit/application/inspect_spec.rb +278 -0
- data/spec/unit/application/kick_spec.rb +1 -3
- data/spec/unit/application/master_spec.rb +1 -3
- data/spec/unit/application/queue_spec.rb +1 -0
- data/spec/unit/application_spec.rb +63 -5
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -1
- data/spec/unit/configurer_spec.rb +33 -49
- data/spec/unit/file_bucket/dipper_spec.rb +69 -77
- data/spec/unit/file_bucket/file_spec.rb +12 -127
- data/spec/unit/file_serving/fileset_spec.rb +1 -0
- data/spec/unit/file_serving/metadata_spec.rb +4 -4
- data/spec/unit/indirector/active_record_spec.rb +1 -0
- data/spec/unit/indirector/catalog/active_record_spec.rb +29 -13
- data/spec/unit/indirector/facts/active_record_spec.rb +2 -3
- data/spec/unit/indirector/facts/couch_spec.rb +1 -2
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +202 -218
- data/spec/unit/indirector/file_server_spec.rb +6 -7
- data/spec/unit/indirector/indirection_spec.rb +71 -2
- data/spec/unit/indirector/ldap_spec.rb +2 -6
- data/spec/unit/indirector/node/active_record_spec.rb +1 -3
- data/spec/unit/indirector/queue_spec.rb +1 -3
- data/spec/unit/indirector/rest_spec.rb +37 -1
- data/spec/unit/indirector/ssl_file_spec.rb +5 -5
- data/spec/unit/indirector_spec.rb +6 -1
- data/spec/unit/module_spec.rb +1 -3
- data/spec/unit/network/formats_spec.rb +2 -5
- data/spec/unit/network/http/api/v1_spec.rb +4 -0
- data/spec/unit/network/http/compression_spec.rb +1 -3
- data/spec/unit/network/http/handler_spec.rb +39 -0
- data/spec/unit/network/http/mongrel/rest_spec.rb +1 -2
- data/spec/unit/network/http/mongrel_spec.rb +3 -9
- data/spec/unit/network/http/rack/rest_spec.rb +1 -3
- data/spec/unit/network/http/rack/xmlrpc_spec.rb +2 -3
- data/spec/unit/network/http/rack_spec.rb +2 -3
- data/spec/unit/network/http/webrick_spec.rb +1 -0
- data/spec/unit/network/rest_authconfig_spec.rb +1 -1
- data/spec/unit/network/rights_spec.rb +43 -23
- data/spec/unit/network/xmlrpc/client_spec.rb +1 -0
- data/spec/unit/parameter_spec.rb +1 -2
- data/spec/unit/parser/collector_spec.rb +3 -6
- data/spec/unit/parser/compiler_spec.rb +90 -5
- data/spec/unit/parser/lexer_spec.rb +3 -2
- data/spec/unit/parser/templatewrapper_spec.rb +1 -0
- data/spec/unit/property/keyvalue_spec.rb +5 -5
- data/spec/unit/property/list_spec.rb +7 -7
- data/spec/unit/provider/mount/parsed_spec.rb +1 -2
- data/spec/unit/provider/mount_spec.rb +8 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +38 -0
- data/spec/unit/provider/package/freebsd_spec.rb +55 -0
- data/spec/unit/provider/service/init_spec.rb +2 -0
- data/spec/unit/rails/host_spec.rb +1 -3
- data/spec/unit/rails/param_value_spec.rb +2 -3
- data/spec/unit/rails/resource_spec.rb +2 -3
- data/spec/unit/rails_spec.rb +5 -15
- data/spec/unit/relationship_spec.rb +2 -6
- data/spec/unit/reports/http_spec.rb +1 -1
- data/spec/unit/reports/store_spec.rb +31 -0
- data/spec/unit/reports/tagmail_spec.rb +1 -1
- data/spec/unit/resource/catalog_spec.rb +2 -6
- data/spec/unit/resource/status_spec.rb +53 -3
- data/spec/unit/resource/type_collection_spec.rb +0 -8
- data/spec/unit/resource/type_spec.rb +50 -4
- data/spec/unit/resource_spec.rb +10 -6
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +1 -1
- data/spec/unit/transaction/event_spec.rb +21 -2
- data/spec/unit/transaction/report_spec.rb +91 -35
- data/spec/unit/transaction/resource_harness_spec.rb +289 -208
- data/spec/unit/transaction_spec.rb +1 -6
- data/spec/unit/type/augeas_spec.rb +1 -3
- data/spec/unit/type/file/content_spec.rb +63 -10
- data/spec/unit/type/file/ctime.rb +35 -0
- data/spec/unit/type/file/ensure_spec.rb +8 -7
- data/spec/unit/type/file/group_spec.rb +5 -5
- data/spec/unit/type/file/mtime.rb +35 -0
- data/spec/unit/type/file/owner_spec.rb +7 -7
- data/spec/unit/type/file/selinux_spec.rb +2 -2
- data/spec/unit/type/file/source_spec.rb +3 -3
- data/spec/unit/type/file/type.rb +20 -0
- data/spec/unit/type/file_spec.rb +131 -8
- data/spec/unit/type/mount_spec.rb +4 -4
- data/spec/unit/type/package_spec.rb +3 -3
- data/spec/unit/type/ssh_authorized_key_spec.rb +1 -1
- data/spec/unit/type/user_spec.rb +31 -3
- data/spec/unit/type/zpool_spec.rb +12 -12
- data/spec/unit/type_spec.rb +2 -2
- data/spec/unit/util/checksums_spec.rb +9 -1
- data/spec/unit/util/command_line_spec.rb +29 -0
- data/spec/unit/util/log/destinations_spec.rb +13 -0
- data/spec/unit/util/log_spec.rb +24 -12
- data/spec/unit/util/logging_spec.rb +1 -1
- data/spec/unit/util/metric_spec.rb +7 -7
- data/spec/unit/util/pson_spec.rb +15 -0
- data/spec/unit/util/queue/stomp_spec.rb +2 -6
- data/spec/unit/util/settings/file_setting_spec.rb +1 -3
- data/spec/unit/util/zaml_spec.rb +51 -0
- data/test/language/snippets.rb +3 -0
- data/test/lib/puppettest/fileparsing.rb +2 -0
- data/test/lib/puppettest/reporttesting.rb +1 -1
- data/test/lib/puppettest/support/utils.rb +1 -1
- data/test/network/server/mongrel_test.rb +0 -6
- data/test/other/report.rb +1 -1
- data/test/ral/providers/cron/crontab.rb +4 -1
- data/test/ral/type/file.rb +1 -1
- data/test/ral/type/filesources.rb +1 -4
- metadata +1119 -1113
- data/lib/puppet/transaction/change.rb +0 -87
- data/spec/Rakefile +0 -91
- data/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +0 -46
- data/spec/spec_specs/runnable_spec.rb +0 -95
- data/spec/unit/transaction/change_spec.rb +0 -193
@@ -442,7 +442,7 @@ class DirectoryService < Puppet::Provider::NameService
|
|
442
442
|
|
443
443
|
def remove_unwanted_members(current_members, new_members)
|
444
444
|
current_members.each do |member|
|
445
|
-
if not new_members.include?(member)
|
445
|
+
if not new_members.flatten.include?(member)
|
446
446
|
cmd = [:dseditgroup, "-o", "edit", "-n", ".", "-d", member, @resource[:name]]
|
447
447
|
begin
|
448
448
|
execute(cmd)
|
@@ -454,7 +454,7 @@ class DirectoryService < Puppet::Provider::NameService
|
|
454
454
|
end
|
455
455
|
|
456
456
|
def add_members(current_members, new_members)
|
457
|
-
new_members.each do |new_member|
|
457
|
+
new_members.flatten.each do |new_member|
|
458
458
|
if current_members.nil? or not current_members.include?(new_member)
|
459
459
|
cmd = [:dseditgroup, "-o", "edit", "-n", ".", "-a", new_member, @resource[:name]]
|
460
460
|
begin
|
@@ -20,11 +20,11 @@ Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do
|
|
20
20
|
|
21
21
|
if @resource[:source] =~ /\/$/
|
22
22
|
if @resource[:source] =~ /^(ftp|https?):/
|
23
|
-
withenv :PACKAGESITE => @resource[:source] do
|
23
|
+
Puppet::Util::Execution::withenv :PACKAGESITE => @resource[:source] do
|
24
24
|
pkgadd "-r", @resource[:name]
|
25
25
|
end
|
26
26
|
else
|
27
|
-
withenv :PKG_PATH => @resource[:source] do
|
27
|
+
Puppet::Util::Execution::withenv :PKG_PATH => @resource[:source] do
|
28
28
|
pkgadd @resource[:name]
|
29
29
|
end
|
30
30
|
end
|
@@ -40,7 +40,7 @@ Puppet::Type.type(:zone).provide(:solaris) do
|
|
40
40
|
# Then perform all of our configuration steps. It's annoying
|
41
41
|
# that we need this much internal info on the resource.
|
42
42
|
@resource.send(:properties).each do |property|
|
43
|
-
str += property.configtext + "\n" if property.is_a? ZoneConfigProperty and ! property.
|
43
|
+
str += property.configtext + "\n" if property.is_a? ZoneConfigProperty and ! property.safe_insync?(properties[property.name])
|
44
44
|
end
|
45
45
|
|
46
46
|
str += "commit\n"
|
@@ -94,11 +94,11 @@ The file follows INI-style formatting. Here is an example of a very simple
|
|
94
94
|
Note that boolean parameters must be explicitly specified as `true` or
|
95
95
|
`false` as seen above.
|
96
96
|
|
97
|
-
If you need to change file parameters (e.g., reset the mode or owner), do
|
97
|
+
If you need to change file or directory parameters (e.g., reset the mode or owner), do
|
98
98
|
so within curly braces on the same line:
|
99
99
|
|
100
100
|
[main]
|
101
|
-
|
101
|
+
vardir = /new/vardir {owner = root, mode = 644}
|
102
102
|
|
103
103
|
If you're starting out with a fresh configuration, you may wish to let
|
104
104
|
the executable generate a template configuration file for you by invoking
|
@@ -8,6 +8,10 @@ performing stand-alone work like importing. Rvalues return values and can
|
|
8
8
|
only be used in a statement requiring a value, such as an assignment or a case
|
9
9
|
statement.
|
10
10
|
|
11
|
+
Functions execute on the Puppet master. They do not execute on the Puppet agent.
|
12
|
+
Hence they only have access to the commands and data available on the Puppet master
|
13
|
+
host.
|
14
|
+
|
11
15
|
Here are the functions available in Puppet:
|
12
16
|
|
13
17
|
"
|
data/lib/puppet/relationship.rb
CHANGED
data/lib/puppet/reports/store.rb
CHANGED
@@ -8,24 +8,6 @@ Puppet::Reports.register_report(:store) do
|
|
8
8
|
to perform some maintenance on them if you use this report (it's the only
|
9
9
|
default report)."
|
10
10
|
|
11
|
-
def mkclientdir(client, dir)
|
12
|
-
config = Puppet::Util::Settings.new
|
13
|
-
|
14
|
-
config.setdefaults(
|
15
|
-
"reportclient-#{client}".to_sym,
|
16
|
-
"client-#{client}-dir" => { :default => dir,
|
17
|
-
:mode => 0750,
|
18
|
-
:desc => "Client dir for #{client}",
|
19
|
-
:owner => 'service',
|
20
|
-
:group => 'service'
|
21
|
-
},
|
22
|
-
|
23
|
-
:noop => [false, "Used by settings internally."]
|
24
|
-
)
|
25
|
-
|
26
|
-
config.use("reportclient-#{client}".to_sym)
|
27
|
-
end
|
28
|
-
|
29
11
|
def process
|
30
12
|
# We don't want any tracking back in the fs. Unlikely, but there
|
31
13
|
# you go.
|
@@ -33,7 +15,7 @@ Puppet::Reports.register_report(:store) do
|
|
33
15
|
|
34
16
|
dir = File.join(Puppet[:reportdir], client)
|
35
17
|
|
36
|
-
|
18
|
+
Dir.mkdir(dir, 0750) unless FileTest.exists?(dir)
|
37
19
|
|
38
20
|
# Now store the report.
|
39
21
|
now = Time.now.gmtime
|
data/lib/puppet/resource.rb
CHANGED
@@ -46,6 +46,10 @@ class Puppet::Resource
|
|
46
46
|
resource
|
47
47
|
end
|
48
48
|
|
49
|
+
def inspect
|
50
|
+
"#{@type}[#{@title}]#{to_hash.inspect}"
|
51
|
+
end
|
52
|
+
|
49
53
|
def to_pson_data_hash
|
50
54
|
data = ([:type, :title, :tags] + ATTRIBUTES).inject({}) do |hash, param|
|
51
55
|
next hash unless value = self.send(param)
|
@@ -201,8 +205,13 @@ class Puppet::Resource
|
|
201
205
|
tag(self.title) if valid_tag?(self.title)
|
202
206
|
|
203
207
|
@reference = Reference.new(@type,@title) # for serialization compatibility with 0.25.x
|
204
|
-
|
205
|
-
|
208
|
+
if strict? and ! resource_type
|
209
|
+
if @type == 'Class'
|
210
|
+
raise ArgumentError, "Could not find declared class #{title}"
|
211
|
+
else
|
212
|
+
raise ArgumentError, "Invalid resource type #{type}"
|
213
|
+
end
|
214
|
+
end
|
206
215
|
end
|
207
216
|
|
208
217
|
def ref
|
@@ -4,13 +4,15 @@ module Puppet
|
|
4
4
|
include Puppet::Util::Tagging
|
5
5
|
include Puppet::Util::Logging
|
6
6
|
|
7
|
-
|
8
|
-
attr_accessor *ATTRIBUTES
|
7
|
+
attr_accessor :resource, :node, :file, :line, :current_values, :status, :evaluation_time
|
9
8
|
|
10
9
|
STATES = [:skipped, :failed, :failed_to_restart, :restarted, :changed, :out_of_sync, :scheduled]
|
11
10
|
attr_accessor *STATES
|
12
11
|
|
13
12
|
attr_reader :source_description, :default_log_level, :time, :resource
|
13
|
+
attr_reader :change_count, :out_of_sync_count, :resource_type, :title
|
14
|
+
|
15
|
+
YAML_ATTRIBUTES = %w{@resource @file @line @evaluation_time @change_count @out_of_sync_count @tags @time @events @out_of_sync @changed @resource_type @title @skipped @failed}
|
14
16
|
|
15
17
|
# Provide a boolean method for each of the states.
|
16
18
|
STATES.each do |attr|
|
@@ -28,6 +30,13 @@ module Puppet
|
|
28
30
|
@events << event
|
29
31
|
if event.status == 'failure'
|
30
32
|
self.failed = true
|
33
|
+
elsif event.status == 'success'
|
34
|
+
@change_count += 1
|
35
|
+
@changed = true
|
36
|
+
end
|
37
|
+
if event.status != 'audit'
|
38
|
+
@out_of_sync_count += 1
|
39
|
+
@out_of_sync = true
|
31
40
|
end
|
32
41
|
end
|
33
42
|
|
@@ -38,14 +47,26 @@ module Puppet
|
|
38
47
|
def initialize(resource)
|
39
48
|
@source_description = resource.path
|
40
49
|
@resource = resource.to_s
|
50
|
+
@change_count = 0
|
51
|
+
@out_of_sync_count = 0
|
52
|
+
@changed = false
|
53
|
+
@out_of_sync = false
|
54
|
+
@skipped = false
|
55
|
+
@failed = false
|
41
56
|
|
42
|
-
[:file, :line
|
57
|
+
[:file, :line].each do |attr|
|
43
58
|
send(attr.to_s + "=", resource.send(attr))
|
44
59
|
end
|
45
60
|
|
46
61
|
tag(*resource.tags)
|
47
62
|
@time = Time.now
|
48
63
|
@events = []
|
64
|
+
@resource_type = resource.type.to_s.capitalize
|
65
|
+
@title = resource.title
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_yaml_properties
|
69
|
+
(YAML_ATTRIBUTES & instance_variables).sort
|
49
70
|
end
|
50
71
|
|
51
72
|
private
|
data/lib/puppet/resource/type.rb
CHANGED
@@ -143,18 +143,26 @@ class Puppet::Resource::Type
|
|
143
143
|
# classes and nodes. No parameters are be supplied--if this is a
|
144
144
|
# parameterized class, then all parameters take on their default
|
145
145
|
# values.
|
146
|
-
def ensure_in_catalog(scope)
|
146
|
+
def ensure_in_catalog(scope, parameters=nil)
|
147
147
|
type == :definition and raise ArgumentError, "Cannot create resources for defined resource types"
|
148
148
|
resource_type = type == :hostclass ? :class : :node
|
149
149
|
|
150
150
|
# Do nothing if the resource already exists; this makes sure we don't
|
151
151
|
# get multiple copies of the class resource, which helps provide the
|
152
152
|
# singleton nature of classes.
|
153
|
-
|
153
|
+
# we should not do this for classes with parameters
|
154
|
+
# if parameters are passed, we should still try to create the resource
|
155
|
+
# even if it exists so that we can fail
|
156
|
+
# this prevents us from being able to combine param classes with include
|
157
|
+
if resource = scope.catalog.resource(resource_type, name) and !parameters
|
154
158
|
return resource
|
155
159
|
end
|
156
|
-
|
157
160
|
resource = Puppet::Parser::Resource.new(resource_type, name, :scope => scope, :source => self)
|
161
|
+
if parameters
|
162
|
+
parameters.each do |k,v|
|
163
|
+
resource.set_parameter(k,v)
|
164
|
+
end
|
165
|
+
end
|
158
166
|
instantiate_resource(scope, resource)
|
159
167
|
scope.compiler.add_resource(scope, resource)
|
160
168
|
resource
|
@@ -222,6 +230,19 @@ class Puppet::Resource::Type
|
|
222
230
|
set[param] = true
|
223
231
|
end
|
224
232
|
|
233
|
+
if @type == :hostclass
|
234
|
+
scope.setvar("title", resource.title.to_s.downcase) unless set.include? :title
|
235
|
+
scope.setvar("name", resource.name.to_s.downcase ) unless set.include? :name
|
236
|
+
else
|
237
|
+
scope.setvar("title", resource.title ) unless set.include? :title
|
238
|
+
scope.setvar("name", resource.name ) unless set.include? :name
|
239
|
+
end
|
240
|
+
scope.setvar("module_name", module_name) if module_name and ! set.include? :module_name
|
241
|
+
|
242
|
+
if caller_name = scope.parent_module_name and ! set.include?(:caller_module_name)
|
243
|
+
scope.setvar("caller_module_name", caller_name)
|
244
|
+
end
|
245
|
+
scope.class_set(self.name,scope) if hostclass? or node?
|
225
246
|
# Verify that all required arguments are either present or
|
226
247
|
# have been provided with defaults.
|
227
248
|
arguments.each do |param, default|
|
@@ -238,19 +259,6 @@ class Puppet::Resource::Type
|
|
238
259
|
resource[param] = value
|
239
260
|
end
|
240
261
|
|
241
|
-
if @type == :hostclass
|
242
|
-
scope.setvar("title", resource.title.to_s.downcase) unless set.include? :title
|
243
|
-
scope.setvar("name", resource.name.to_s.downcase ) unless set.include? :name
|
244
|
-
else
|
245
|
-
scope.setvar("title", resource.title ) unless set.include? :title
|
246
|
-
scope.setvar("name", resource.name ) unless set.include? :name
|
247
|
-
end
|
248
|
-
scope.setvar("module_name", module_name) if module_name and ! set.include? :module_name
|
249
|
-
|
250
|
-
if caller_name = scope.parent_module_name and ! set.include?(:caller_module_name)
|
251
|
-
scope.setvar("caller_module_name", caller_name)
|
252
|
-
end
|
253
|
-
scope.class_set(self.name,scope) if hostclass? or node?
|
254
262
|
end
|
255
263
|
|
256
264
|
# Create a new subscope in which to evaluate our code.
|
@@ -19,6 +19,10 @@ class Puppet::Resource::TypeCollection
|
|
19
19
|
@watched_files = {}
|
20
20
|
end
|
21
21
|
|
22
|
+
def inspect
|
23
|
+
"TypeCollection" + { :hostclasses => @hostclasses.keys, :definitions => @definitions.keys, :nodes => @nodes.keys }.inspect
|
24
|
+
end
|
25
|
+
|
22
26
|
def <<(thing)
|
23
27
|
add(thing)
|
24
28
|
self
|
@@ -153,7 +157,6 @@ class Puppet::Resource::TypeCollection
|
|
153
157
|
end
|
154
158
|
|
155
159
|
def perform_initial_import
|
156
|
-
return if Puppet.settings[:ignoreimport]
|
157
160
|
parser = Puppet::Parser::Parser.new(environment)
|
158
161
|
if code = Puppet.settings.uninterpolated_value(:code, environment.to_s) and code != ""
|
159
162
|
parser.string = code
|
data/lib/puppet/simple_graph.rb
CHANGED
data/lib/puppet/transaction.rb
CHANGED
@@ -6,7 +6,6 @@ require 'puppet/util/tagging'
|
|
6
6
|
require 'puppet/application'
|
7
7
|
|
8
8
|
class Puppet::Transaction
|
9
|
-
require 'puppet/transaction/change'
|
10
9
|
require 'puppet/transaction/event'
|
11
10
|
require 'puppet/transaction/event_manager'
|
12
11
|
require 'puppet/transaction/resource_harness'
|
@@ -222,12 +221,6 @@ class Puppet::Transaction
|
|
222
221
|
end
|
223
222
|
end
|
224
223
|
|
225
|
-
# Generate a transaction report.
|
226
|
-
def generate_report
|
227
|
-
@report.calculate_metrics
|
228
|
-
@report
|
229
|
-
end
|
230
|
-
|
231
224
|
# Should we ignore tags?
|
232
225
|
def ignore_tags?
|
233
226
|
! (@catalog.host_config? or Puppet[:name] == "puppet")
|
@@ -238,7 +231,7 @@ class Puppet::Transaction
|
|
238
231
|
def initialize(catalog)
|
239
232
|
@catalog = catalog
|
240
233
|
|
241
|
-
@report = Report.new
|
234
|
+
@report = Report.new("apply", catalog.version)
|
242
235
|
|
243
236
|
@event_manager = Puppet::Transaction::EventManager.new(self)
|
244
237
|
|
@@ -285,26 +278,6 @@ class Puppet::Transaction
|
|
285
278
|
catalog.relationship_graph
|
286
279
|
end
|
287
280
|
|
288
|
-
# Send off the transaction report.
|
289
|
-
def send_report
|
290
|
-
begin
|
291
|
-
report = generate_report
|
292
|
-
rescue => detail
|
293
|
-
Puppet.err "Could not generate report: #{detail}"
|
294
|
-
return
|
295
|
-
end
|
296
|
-
|
297
|
-
puts report.summary if Puppet[:summarize]
|
298
|
-
|
299
|
-
if Puppet[:report]
|
300
|
-
begin
|
301
|
-
report.save
|
302
|
-
rescue => detail
|
303
|
-
Puppet.err "Reporting failed: #{detail}"
|
304
|
-
end
|
305
|
-
end
|
306
|
-
end
|
307
|
-
|
308
281
|
def add_resource_status(status)
|
309
282
|
report.add_resource_status status
|
310
283
|
end
|
@@ -7,7 +7,8 @@ class Puppet::Transaction::Event
|
|
7
7
|
include Puppet::Util::Tagging
|
8
8
|
include Puppet::Util::Logging
|
9
9
|
|
10
|
-
ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :
|
10
|
+
ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :audited]
|
11
|
+
YAML_ATTRIBUTES = %w{@audited @property @previous_value @desired_value @historical_value @message @name @status @time}
|
11
12
|
attr_accessor *ATTRIBUTES
|
12
13
|
attr_writer :tags
|
13
14
|
attr_accessor :time
|
@@ -15,9 +16,9 @@ class Puppet::Transaction::Event
|
|
15
16
|
|
16
17
|
EVENT_STATUSES = %w{noop success failure audit}
|
17
18
|
|
18
|
-
def initialize(
|
19
|
-
|
20
|
-
options.each { |attr, value| send(attr.to_s + "=", value)
|
19
|
+
def initialize(options = {})
|
20
|
+
@audited = false
|
21
|
+
options.each { |attr, value| send(attr.to_s + "=", value) }
|
21
22
|
|
22
23
|
@time = Time.now
|
23
24
|
end
|
@@ -46,6 +47,10 @@ class Puppet::Transaction::Event
|
|
46
47
|
message
|
47
48
|
end
|
48
49
|
|
50
|
+
def to_yaml_properties
|
51
|
+
(YAML_ATTRIBUTES & instance_variables).sort
|
52
|
+
end
|
53
|
+
|
49
54
|
private
|
50
55
|
|
51
56
|
# If it's a failure, use 'err', else use either the resource's log level (if available)
|
@@ -10,7 +10,8 @@ class Puppet::Transaction::Report
|
|
10
10
|
|
11
11
|
indirects :report, :terminus_class => :processor
|
12
12
|
|
13
|
-
|
13
|
+
attr_accessor :configuration_version
|
14
|
+
attr_reader :resource_statuses, :logs, :metrics, :host, :time, :kind, :status
|
14
15
|
|
15
16
|
# This is necessary since Marshall doesn't know how to
|
16
17
|
# dump hash with default proc (see below @records)
|
@@ -42,20 +43,37 @@ class Puppet::Transaction::Report
|
|
42
43
|
@resource_statuses[status.resource] = status
|
43
44
|
end
|
44
45
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
def compute_status(resource_metrics, change_metric)
|
47
|
+
if (resource_metrics["failed"] || 0) > 0
|
48
|
+
'failed'
|
49
|
+
elsif change_metric > 0
|
50
|
+
'changed'
|
51
|
+
else
|
52
|
+
'unchanged'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def finalize_report
|
57
|
+
resource_metrics = add_metric(:resources, calculate_resource_metrics)
|
58
|
+
add_metric(:time, calculate_time_metrics)
|
59
|
+
change_metric = calculate_change_metric
|
60
|
+
add_metric(:changes, {"total" => change_metric})
|
61
|
+
add_metric(:events, calculate_event_metrics)
|
62
|
+
@status = compute_status(resource_metrics, change_metric)
|
50
63
|
end
|
51
64
|
|
52
|
-
def initialize
|
65
|
+
def initialize(kind, configuration_version=nil)
|
53
66
|
@metrics = {}
|
54
67
|
@logs = []
|
55
68
|
@resource_statuses = {}
|
56
69
|
@external_times ||= {}
|
57
70
|
@host = Puppet[:certname]
|
58
71
|
@time = Time.now
|
72
|
+
@kind = kind
|
73
|
+
@report_format = 2
|
74
|
+
@puppet_version = Puppet.version
|
75
|
+
@configuration_version = configuration_version
|
76
|
+
@status = 'failed' # assume failed until the report is finalized
|
59
77
|
end
|
60
78
|
|
61
79
|
def name
|
@@ -91,46 +109,46 @@ class Puppet::Transaction::Report
|
|
91
109
|
# individual bits represent the presence of different metrics.
|
92
110
|
def exit_status
|
93
111
|
status = 0
|
94
|
-
status |= 2 if @metrics["changes"][
|
95
|
-
status |= 4 if @metrics["resources"][
|
112
|
+
status |= 2 if @metrics["changes"]["total"] > 0
|
113
|
+
status |= 4 if @metrics["resources"]["failed"] > 0
|
96
114
|
status
|
97
115
|
end
|
98
116
|
|
99
|
-
|
117
|
+
def to_yaml_properties
|
118
|
+
(instance_variables - ["@external_times"]).sort
|
119
|
+
end
|
100
120
|
|
101
|
-
|
102
|
-
metrics = Hash.new(0)
|
103
|
-
resource_statuses.each do |name, status|
|
104
|
-
metrics[:total] += status.change_count if status.change_count
|
105
|
-
end
|
121
|
+
private
|
106
122
|
|
107
|
-
|
123
|
+
def calculate_change_metric
|
124
|
+
resource_statuses.map { |name, status| status.change_count || 0 }.inject(0) { |a,b| a+b }
|
108
125
|
end
|
109
126
|
|
110
127
|
def calculate_event_metrics
|
111
128
|
metrics = Hash.new(0)
|
129
|
+
metrics["total"] = 0
|
112
130
|
resource_statuses.each do |name, status|
|
113
|
-
metrics[
|
131
|
+
metrics["total"] += status.events.length
|
114
132
|
status.events.each do |event|
|
115
133
|
metrics[event.status] += 1
|
116
134
|
end
|
117
135
|
end
|
118
136
|
|
119
|
-
|
137
|
+
metrics
|
120
138
|
end
|
121
139
|
|
122
140
|
def calculate_resource_metrics
|
123
141
|
metrics = Hash.new(0)
|
124
|
-
metrics[
|
142
|
+
metrics["total"] = resource_statuses.length
|
125
143
|
|
126
144
|
resource_statuses.each do |name, status|
|
127
145
|
|
128
146
|
Puppet::Resource::Status::STATES.each do |state|
|
129
|
-
metrics[state] += 1 if status.send(state)
|
147
|
+
metrics[state.to_s] += 1 if status.send(state)
|
130
148
|
end
|
131
149
|
end
|
132
150
|
|
133
|
-
|
151
|
+
metrics
|
134
152
|
end
|
135
153
|
|
136
154
|
def calculate_time_metrics
|
@@ -144,6 +162,8 @@ class Puppet::Transaction::Report
|
|
144
162
|
metrics[name.to_s.downcase] = value
|
145
163
|
end
|
146
164
|
|
147
|
-
|
165
|
+
metrics["total"] = metrics.values.inject(0) { |a,b| a+b }
|
166
|
+
|
167
|
+
metrics
|
148
168
|
end
|
149
169
|
end
|