puppet 4.4.2 → 4.5.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.
- data/CONTRIBUTING.md +5 -5
- data/Gemfile +2 -2
- data/LICENSE +2 -2
- data/README.md +5 -0
- data/ext/project_data.yaml +2 -0
- data/lib/hiera_puppet.rb +6 -14
- data/lib/puppet/application/agent.rb +2 -3
- data/lib/puppet/data_providers/hiera_config.rb +2 -4
- data/lib/puppet/data_providers/hiera_interpolate.rb +12 -154
- data/lib/puppet/data_providers/json_data_provider_factory.rb +0 -7
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -8
- data/lib/puppet/defaults.rb +70 -7
- data/lib/puppet/functions.rb +69 -0
- data/lib/puppet/functions/dig.rb +39 -0
- data/lib/puppet/functions/lest.rb +53 -0
- data/lib/puppet/functions/lookup.rb +40 -27
- data/lib/puppet/functions/new.rb +502 -0
- data/lib/puppet/functions/regsubst.rb +11 -10
- data/lib/puppet/functions/then.rb +74 -0
- data/lib/puppet/functions/type.rb +4 -4
- data/lib/puppet/functions/with.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +2 -0
- data/lib/puppet/indirector/resource_type/parser.rb +5 -0
- data/lib/puppet/indirector/rest.rb +5 -1
- data/lib/puppet/loaders.rb +2 -0
- data/lib/puppet/metatype/manager.rb +19 -2
- data/lib/puppet/module_tool/applications/application.rb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +6 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +19 -4
- data/lib/puppet/module_tool/skeleton/templates/generator/{tests → examples}/init.pp.erb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +0 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +6 -2
- data/lib/puppet/parser/ast/pops_bridge.rb +20 -3
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +24 -2
- data/lib/puppet/parser/e4_parser_adapter.rb +13 -12
- data/lib/puppet/parser/environment_compiler.rb +2 -2
- data/lib/puppet/parser/resource.rb +14 -5
- data/lib/puppet/parser/scope.rb +18 -15
- data/lib/puppet/plugins/data_providers/data_provider.rb +19 -8
- data/lib/puppet/pops.rb +6 -0
- data/lib/puppet/pops/adapters.rb +5 -1
- data/lib/puppet/pops/evaluator/access_operator.rb +52 -14
- data/lib/puppet/pops/evaluator/compare_operator.rb +34 -4
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +75 -22
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +7 -6
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +13 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +14 -4
- data/lib/puppet/pops/functions/dispatcher.rb +1 -1
- data/lib/puppet/pops/issues.rb +18 -2
- data/lib/puppet/pops/loader/base_loader.rb +48 -7
- data/lib/puppet/pops/loader/dependency_loader.rb +27 -2
- data/lib/puppet/pops/loader/loader.rb +12 -0
- data/lib/puppet/pops/loader/predefined_loader.rb +29 -0
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +57 -0
- data/lib/puppet/pops/loader/static_loader.rb +92 -5
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +25 -3
- data/lib/puppet/pops/loaders.rb +84 -14
- data/lib/puppet/pops/lookup/explainer.rb +38 -1
- data/lib/puppet/pops/lookup/interpolation.rb +115 -0
- data/lib/puppet/pops/lookup/sub_lookup.rb +86 -0
- data/lib/puppet/pops/model/ast_transformer.rb +8 -1
- data/lib/puppet/pops/model/factory.rb +31 -8
- data/lib/puppet/pops/model/model.rb +8 -0
- data/lib/puppet/pops/model/model_label_provider.rb +1 -0
- data/lib/puppet/pops/model/model_meta.rb +7 -1
- data/lib/puppet/pops/model/model_tree_dumper.rb +4 -0
- data/lib/puppet/pops/parser/egrammar.ra +24 -7
- data/lib/puppet/pops/parser/eparser.rb +863 -798
- data/lib/puppet/pops/parser/evaluating_parser.rb +4 -0
- data/lib/puppet/pops/parser/locator.rb +8 -4
- data/lib/puppet/pops/pcore.rb +30 -0
- data/lib/puppet/pops/types/class_loader.rb +2 -4
- data/lib/puppet/pops/types/implementation_registry.rb +146 -0
- data/lib/puppet/pops/types/iterable.rb +4 -4
- data/lib/puppet/pops/types/p_object_type.rb +846 -0
- data/lib/puppet/pops/types/p_runtime_type.rb +102 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +164 -0
- data/lib/puppet/pops/types/p_sem_ver_type.rb +113 -0
- data/lib/puppet/pops/types/puppet_object.rb +21 -0
- data/lib/puppet/pops/types/ruby_generator.rb +258 -0
- data/lib/puppet/pops/types/string_converter.rb +922 -0
- data/lib/puppet/pops/types/type_calculator.rb +29 -5
- data/lib/puppet/pops/types/type_conversion_error.rb +15 -0
- data/lib/puppet/pops/types/type_factory.rb +49 -16
- data/lib/puppet/pops/types/type_formatter.rb +335 -112
- data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -29
- data/lib/puppet/pops/types/type_parser.rb +205 -197
- data/lib/puppet/pops/types/types.rb +481 -103
- data/lib/puppet/pops/validation.rb +1 -1
- data/lib/puppet/pops/validation/checker4_0.rb +66 -4
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
- data/lib/puppet/pops/visitor.rb +3 -1
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +64 -20
- data/lib/puppet/provider/package/rpm.rb +112 -0
- data/lib/puppet/provider/package/yum.rb +7 -68
- data/lib/puppet/provider/service/daemontools.rb +3 -3
- data/lib/puppet/provider/service/init.rb +4 -2
- data/lib/puppet/provider/service/runit.rb +3 -3
- data/lib/puppet/provider/service/smf.rb +6 -3
- data/lib/puppet/provider/service/systemd.rb +59 -73
- data/lib/puppet/reference/providers.rb +1 -2
- data/lib/puppet/resource.rb +54 -37
- data/lib/puppet/resource/catalog.rb +31 -29
- data/lib/puppet/resource/type_collection.rb +23 -8
- data/lib/puppet/settings.rb +4 -2
- data/lib/puppet/settings/base_setting.rb +9 -3
- data/lib/puppet/settings/symbolic_enum_setting.rb +17 -0
- data/lib/puppet/test/test_helper.rb +0 -1
- data/lib/puppet/type.rb +9 -3
- data/lib/puppet/type/exec.rb +17 -17
- data/lib/puppet/type/file.rb +12 -0
- data/lib/puppet/type/file/content.rb +6 -6
- data/lib/puppet/type/file/ensure.rb +4 -4
- data/lib/puppet/type/file/source.rb +4 -4
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/mount.rb +18 -1
- data/lib/puppet/type/package.rb +3 -3
- data/lib/puppet/type/schedule.rb +4 -4
- data/lib/puppet/type/service.rb +15 -0
- data/lib/puppet/type/sshkey.rb +5 -3
- data/lib/puppet/type/tidy.rb +3 -3
- data/lib/puppet/type/zone.rb +5 -5
- data/lib/puppet/util/feature.rb +1 -1
- data/lib/puppet/util/monkey_patches.rb +8 -0
- data/lib/puppet/util/network_device/cisco/device.rb +16 -6
- data/lib/puppet/util/network_device/cisco/interface.rb +5 -6
- data/lib/puppet/util/plist.rb +3 -3
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +13 -0
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +2 -1
- data/spec/fixtures/unit/data_providers/environments/production/modules/abc/manifests/init.pp +2 -1
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/data/empty_key.json +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/data/empty_key.yaml +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_key_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/data/empty.yaml +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/lib/puppet/type/usee_type.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/manifests/init.pp +6 -0
- data/spec/fixtures/unit/provider/service/smf/svcs.out +4 -3
- data/spec/integration/module_tool/tar/mini_spec.rb +27 -27
- data/spec/integration/parser/catalog_spec.rb +14 -2
- data/spec/integration/parser/compiler_spec.rb +94 -3
- data/spec/integration/parser/resource_expressions_spec.rb +1 -1
- data/spec/integration/resource/type_collection_spec.rb +8 -0
- data/spec/lib/puppet_spec/compiler.rb +11 -4
- data/spec/shared_contexts/types_setup.rb +4 -0
- data/spec/unit/application/lookup_spec.rb +91 -9
- data/spec/unit/appmgmt_spec.rb +44 -35
- data/spec/unit/capability_spec.rb +33 -53
- data/spec/unit/data_providers/function_data_provider_spec.rb +19 -1
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +1 -1
- data/spec/unit/defaults_spec.rb +18 -0
- data/spec/unit/functions/assert_type_spec.rb +1 -1
- data/spec/unit/functions/dig_spec.rb +58 -0
- data/spec/unit/functions/lest_spec.rb +34 -0
- data/spec/unit/functions/lookup_spec.rb +108 -2
- data/spec/unit/functions/new_spec.rb +543 -0
- data/spec/unit/functions/regsubst_spec.rb +8 -0
- data/spec/unit/functions/then_spec.rb +40 -0
- data/spec/unit/functions4_spec.rb +78 -10
- data/spec/unit/hiera_puppet_spec.rb +49 -8
- data/spec/unit/indirector/resource_type/parser_spec.rb +5 -0
- data/spec/unit/indirector/rest_spec.rb +12 -0
- data/spec/unit/network/http/api/master/v3/environment_spec.rb +60 -0
- data/spec/unit/node/environment_spec.rb +10 -0
- data/spec/unit/parser/compiler_spec.rb +20 -1
- data/spec/unit/parser/functions/create_resources_spec.rb +2 -2
- data/spec/unit/parser/functions/shared.rb +1 -1
- data/spec/unit/parser/resource_spec.rb +8 -1
- data/spec/unit/parser/scope_spec.rb +45 -0
- data/spec/unit/pops/evaluator/access_ops_spec.rb +14 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +13 -5
- data/spec/unit/pops/loaders/static_loader_spec.rb +92 -1
- data/spec/unit/{data_providers/hiera_interpolation_spec.rb → pops/lookup/interpolation_spec.rb} +7 -5
- data/spec/unit/pops/parser/lexer2_spec.rb +2 -9
- data/spec/unit/pops/parser/parse_application_spec.rb +3 -8
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +19 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +3 -10
- data/spec/unit/pops/parser/parse_site_spec.rb +19 -10
- data/spec/unit/pops/parser/parser_rspec_helper.rb +0 -4
- data/spec/unit/pops/types/enumeration_spec.rb +13 -12
- data/spec/unit/pops/types/iterable_spec.rb +2 -2
- data/spec/unit/pops/types/p_object_type_spec.rb +1060 -0
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +285 -0
- data/spec/unit/pops/types/recursion_guard_spec.rb +19 -17
- data/spec/unit/pops/types/ruby_generator_spec.rb +261 -0
- data/spec/unit/pops/types/string_converter_spec.rb +904 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +430 -406
- data/spec/unit/pops/types/type_factory_spec.rb +119 -104
- data/spec/unit/pops/types/type_formatter_spec.rb +73 -6
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +2 -2
- data/spec/unit/pops/types/type_parser_spec.rb +54 -15
- data/spec/unit/pops/types/types_spec.rb +113 -8
- data/spec/unit/pops/validator/validator_spec.rb +84 -10
- data/spec/unit/provider/package/pip3_spec.rb +9 -270
- data/spec/unit/provider/package/pip_spec.rb +85 -30
- data/spec/unit/provider/package/rpm_spec.rb +160 -3
- data/spec/unit/provider/package/yum_spec.rb +23 -134
- data/spec/unit/provider/service/smf_spec.rb +14 -2
- data/spec/unit/provider/service/systemd_spec.rb +33 -41
- data/spec/unit/resource/capability_finder_spec.rb +10 -2
- data/spec/unit/settings/file_setting_spec.rb +6 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +80 -65
- data/spec/unit/type/mount_spec.rb +51 -10
- data/spec/unit/type/service_spec.rb +16 -0
- data/spec/unit/type_spec.rb +14 -0
- data/spec/unit/util/feature_spec.rb +1 -1
- data/spec/unit/util/monkey_patches_spec.rb +60 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- metadata +63 -11
- data/lib/puppet/pops/types/types_meta.rb +0 -0
- data/spec/integration/provider/package_spec.rb +0 -35
@@ -55,17 +55,16 @@ class Puppet::Resource::TypeCollection
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def add(instance)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
instance.resource_type_collection = self
|
65
|
-
instance
|
58
|
+
# return a merged instance, or the given
|
59
|
+
result = catch(:merged) {
|
60
|
+
send("add_#{instance.type}", instance)
|
61
|
+
instance.resource_type_collection = self
|
62
|
+
instance
|
63
|
+
}
|
66
64
|
end
|
67
65
|
|
68
66
|
def add_hostclass(instance)
|
67
|
+
handle_hostclass_merge(instance)
|
69
68
|
dupe_check(instance, @hostclasses) { |dupe| "Class '#{instance.name}' is already defined#{dupe.error_context}; cannot redefine" }
|
70
69
|
dupe_check(instance, @definitions) { |dupe| "Definition '#{instance.name}' is already defined#{dupe.error_context}; cannot be redefined as a class" }
|
71
70
|
dupe_check(instance, @applications) { |dupe| "Application '#{instance.name}' is already defined#{dupe.error_context}; cannot be redefined as a class" }
|
@@ -74,6 +73,22 @@ class Puppet::Resource::TypeCollection
|
|
74
73
|
instance
|
75
74
|
end
|
76
75
|
|
76
|
+
def handle_hostclass_merge(instance)
|
77
|
+
if instance.type == :hostclass && (other = @hostclasses[instance.name]) && other.type == :hostclass
|
78
|
+
unless instance.name == ''
|
79
|
+
case Puppet[:strict]
|
80
|
+
when :warning
|
81
|
+
Puppet.warning("Class '#{instance.name}' is already defined#{other.error_context}; cannot redefine at #{instance.file}:#{instance.line}")
|
82
|
+
when :error
|
83
|
+
# returning means a merge (with throw) is not performed, that will then trigger a duplication check with error.
|
84
|
+
return instance
|
85
|
+
end
|
86
|
+
end
|
87
|
+
other.merge(instance)
|
88
|
+
throw :merged, other
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
77
92
|
def hostclass(name)
|
78
93
|
@hostclasses[munge_name(name)]
|
79
94
|
end
|
data/lib/puppet/settings.rb
CHANGED
@@ -14,6 +14,7 @@ class Puppet::Settings
|
|
14
14
|
require 'puppet/settings/base_setting'
|
15
15
|
require 'puppet/settings/string_setting'
|
16
16
|
require 'puppet/settings/enum_setting'
|
17
|
+
require 'puppet/settings/symbolic_enum_setting'
|
17
18
|
require 'puppet/settings/array_setting'
|
18
19
|
require 'puppet/settings/file_setting'
|
19
20
|
require 'puppet/settings/directory_setting'
|
@@ -561,7 +562,7 @@ class Puppet::Settings
|
|
561
562
|
# will have associated hooks that it ends up being less work this
|
562
563
|
# way overall.
|
563
564
|
if setting.call_hook_on_initialize?
|
564
|
-
@hooks_to_call_on_application_initialization
|
565
|
+
@hooks_to_call_on_application_initialization |= [ setting ]
|
565
566
|
else
|
566
567
|
setting.handle(ChainedValues.new(
|
567
568
|
preferred_run_mode,
|
@@ -663,6 +664,7 @@ class Puppet::Settings
|
|
663
664
|
:ttl => TTLSetting,
|
664
665
|
:array => ArraySetting,
|
665
666
|
:enum => EnumSetting,
|
667
|
+
:symbolic_enum => SymbolicEnumSetting,
|
666
668
|
:priority => PrioritySetting,
|
667
669
|
:autosign => AutosignSetting,
|
668
670
|
}
|
@@ -906,7 +908,7 @@ class Puppet::Settings
|
|
906
908
|
if tryconfig.call_hook_on_define?
|
907
909
|
call << tryconfig
|
908
910
|
elsif tryconfig.call_hook_on_initialize?
|
909
|
-
@hooks_to_call_on_application_initialization
|
911
|
+
@hooks_to_call_on_application_initialization |= [ tryconfig ]
|
910
912
|
end
|
911
913
|
end
|
912
914
|
|
@@ -95,10 +95,16 @@ class Puppet::Settings::BaseSetting
|
|
95
95
|
|
96
96
|
def default(check_application_defaults_first = false)
|
97
97
|
if @default.is_a? Proc
|
98
|
-
|
98
|
+
# Give unit tests a chance to reevaluate the call by removing the instance variable
|
99
|
+
unless instance_variable_defined?(:@evaluated_default)
|
100
|
+
@evaluated_default = @default.call
|
101
|
+
end
|
102
|
+
default_value = @evaluated_default
|
103
|
+
else
|
104
|
+
default_value = @default
|
99
105
|
end
|
100
|
-
return
|
101
|
-
return @settings.value(name, :application_defaults, true) ||
|
106
|
+
return default_value unless check_application_defaults_first
|
107
|
+
return @settings.value(name, :application_defaults, true) || default_value
|
102
108
|
end
|
103
109
|
|
104
110
|
# Convert the object to a config statement.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Puppet::Settings::SymbolicEnumSetting < Puppet::Settings::BaseSetting
|
2
|
+
attr_accessor :values
|
3
|
+
|
4
|
+
def type
|
5
|
+
:symbolic_enum
|
6
|
+
end
|
7
|
+
|
8
|
+
def munge(value)
|
9
|
+
sym = value.to_sym
|
10
|
+
if values.include?(sym)
|
11
|
+
sym
|
12
|
+
else
|
13
|
+
raise Puppet::Settings::ValidationError,
|
14
|
+
"Invalid value '#{value}' for parameter #{@name}. Allowed values are '#{values.join("', '")}'"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -238,7 +238,6 @@ module Puppet::Test
|
|
238
238
|
#
|
239
239
|
# I would make these even shorter, but OpenSSL doesn't support anything
|
240
240
|
# below 512 bits. Sad, really, because a 0 bit key would be just fine.
|
241
|
-
Puppet[:req_bits] = 512
|
242
241
|
Puppet[:keylength] = 512
|
243
242
|
|
244
243
|
# Although we setup a testing context during initialization, some tests
|
data/lib/puppet/type.rb
CHANGED
@@ -1044,6 +1044,12 @@ class Type
|
|
1044
1044
|
insync
|
1045
1045
|
end
|
1046
1046
|
|
1047
|
+
# Says if the ensure property should be retrieved if the resource is ensurable
|
1048
|
+
# Defaults to true. Some resource type classes can override it
|
1049
|
+
def self.needs_ensure_retrieved
|
1050
|
+
true
|
1051
|
+
end
|
1052
|
+
|
1047
1053
|
# Retrieves the current value of all contained properties.
|
1048
1054
|
# Parameters and meta-parameters are not included in the result.
|
1049
1055
|
# @todo As oposed to all non contained properties? How is this different than any of the other
|
@@ -1058,7 +1064,7 @@ class Type
|
|
1058
1064
|
# Provide the name, so we know we'll always refer to a real thing
|
1059
1065
|
result[:name] = self[:name] unless self[:name] == title
|
1060
1066
|
|
1061
|
-
if ensure_prop = property(:ensure) or (self.class.validattr?(:ensure) and ensure_prop = newattr(:ensure))
|
1067
|
+
if ensure_prop = property(:ensure) or (self.class.needs_ensure_retrieved and self.class.validattr?(:ensure) and ensure_prop = newattr(:ensure))
|
1062
1068
|
result[:ensure] = ensure_state = ensure_prop.retrieve
|
1063
1069
|
else
|
1064
1070
|
ensure_state = nil
|
@@ -1531,12 +1537,12 @@ class Type
|
|
1531
1537
|
:event => self.class.events,
|
1532
1538
|
:callback => method
|
1533
1539
|
}
|
1534
|
-
self.debug
|
1540
|
+
self.debug { "subscribes to #{related_resource.ref}" }
|
1535
1541
|
else
|
1536
1542
|
# If there's no callback, there's no point in even adding
|
1537
1543
|
# a label.
|
1538
1544
|
subargs = nil
|
1539
|
-
self.debug
|
1545
|
+
self.debug { "subscribes to #{related_resource.ref}" }
|
1540
1546
|
end
|
1541
1547
|
|
1542
1548
|
Puppet::Relationship.new(source, target, subargs)
|
data/lib/puppet/type/exec.rb
CHANGED
@@ -340,15 +340,15 @@ module Puppet
|
|
340
340
|
other object; it is useful for triggering an action:
|
341
341
|
|
342
342
|
# Pull down the main aliases file
|
343
|
-
file {
|
344
|
-
source =>
|
343
|
+
file { '/etc/aliases':
|
344
|
+
source => 'puppet://server/module/aliases',
|
345
345
|
}
|
346
346
|
|
347
347
|
# Rebuild the database, but only when the file changes
|
348
348
|
exec { newaliases:
|
349
|
-
path => [
|
350
|
-
subscribe => File[
|
351
|
-
refreshonly => true
|
349
|
+
path => ['/usr/bin', '/usr/sbin'],
|
350
|
+
subscribe => File['/etc/aliases'],
|
351
|
+
refreshonly => true,
|
352
352
|
}
|
353
353
|
|
354
354
|
Note that only `subscribe` and `notify` can trigger actions, not `require`,
|
@@ -377,10 +377,10 @@ module Puppet
|
|
377
377
|
This parameter doesn't cause Puppet to create a file; it is only
|
378
378
|
useful if **the command itself** creates a file.
|
379
379
|
|
380
|
-
exec {
|
381
|
-
cwd =>
|
382
|
-
creates =>
|
383
|
-
path => [
|
380
|
+
exec { 'tar -xf /Volumes/nfs02/important.tar':
|
381
|
+
cwd => '/var/tmp',
|
382
|
+
creates => '/var/tmp/myfile',
|
383
|
+
path => ['/usr/bin', '/usr/sbin',],
|
384
384
|
}
|
385
385
|
|
386
386
|
In this example, `myfile` is assumed to be a file inside
|
@@ -404,9 +404,9 @@ module Puppet
|
|
404
404
|
If this parameter is set, then this `exec` will run unless
|
405
405
|
the command has an exit code of 0. For example:
|
406
406
|
|
407
|
-
exec {
|
408
|
-
path =>
|
409
|
-
unless =>
|
407
|
+
exec { '/bin/echo root >> /usr/lib/cron/cron.allow':
|
408
|
+
path => '/usr/bin:/usr/sbin:/bin',
|
409
|
+
unless => 'grep root /usr/lib/cron/cron.allow 2>/dev/null',
|
410
410
|
}
|
411
411
|
|
412
412
|
This would add `root` to the cron.allow file (on Solaris) unless
|
@@ -420,7 +420,7 @@ module Puppet
|
|
420
420
|
|
421
421
|
Also note that unless can take an array as its value, e.g.:
|
422
422
|
|
423
|
-
unless => [
|
423
|
+
unless => ['test -f /tmp/file1', 'test -f /tmp/file2'],
|
424
424
|
|
425
425
|
This will only run the exec if _all_ conditions in the array return false.
|
426
426
|
EOT
|
@@ -455,9 +455,9 @@ module Puppet
|
|
455
455
|
If this parameter is set, then this `exec` will only run if
|
456
456
|
the command has an exit code of 0. For example:
|
457
457
|
|
458
|
-
exec {
|
459
|
-
path =>
|
460
|
-
onlyif =>
|
458
|
+
exec { 'logrotate':
|
459
|
+
path => '/usr/bin:/usr/sbin:/bin',
|
460
|
+
onlyif => 'test `du /var/log/messages | cut -f1` -gt 100000',
|
461
461
|
}
|
462
462
|
|
463
463
|
This would run `logrotate` only if that test returned true.
|
@@ -471,7 +471,7 @@ module Puppet
|
|
471
471
|
|
472
472
|
Also note that onlyif can take an array as its value, e.g.:
|
473
473
|
|
474
|
-
onlyif => [
|
474
|
+
onlyif => ['test -f /tmp/file1', 'test -f /tmp/file2'],
|
475
475
|
|
476
476
|
This will only run the exec if _all_ conditions in the array return true.
|
477
477
|
EOT
|
data/lib/puppet/type/file.rb
CHANGED
@@ -854,6 +854,18 @@ Puppet::Type.newtype(:file) do
|
|
854
854
|
devfail 'a property should have been provided if write_temporary_file? returned true' if property.nil?
|
855
855
|
content_checksum = property.write(file)
|
856
856
|
file.flush
|
857
|
+
begin
|
858
|
+
file.fsync
|
859
|
+
rescue NotImplementedError
|
860
|
+
# fsync may not be implemented by Ruby on all platforms, but
|
861
|
+
# there is absolutely no recovery path if we detect that. So, we just
|
862
|
+
# ignore the return code.
|
863
|
+
#
|
864
|
+
# However, don't be fooled: that is accepting that we are running in
|
865
|
+
# an unsafe fashion. If you are porting to a new platform don't stub
|
866
|
+
# that out.
|
867
|
+
end
|
868
|
+
|
857
869
|
fail_if_checksum_is_wrong(file.path, content_checksum) if validate_checksum?
|
858
870
|
if self[:validate_cmd]
|
859
871
|
output = Puppet::Util::Execution.execute(self[:validate_cmd].gsub(self[:validate_replacement], file.path), :failonfail => true, :combine => true)
|
@@ -23,14 +23,14 @@ module Puppet
|
|
23
23
|
the manifest...
|
24
24
|
|
25
25
|
define resolve(nameserver1, nameserver2, domain, search) {
|
26
|
-
$str = "search $search
|
27
|
-
domain $domain
|
28
|
-
nameserver $nameserver1
|
29
|
-
nameserver $nameserver2
|
26
|
+
$str = "search ${search}
|
27
|
+
domain ${domain}
|
28
|
+
nameserver ${nameserver1}
|
29
|
+
nameserver ${nameserver2}
|
30
30
|
"
|
31
31
|
|
32
|
-
file {
|
33
|
-
content =>
|
32
|
+
file { '/etc/resolv.conf':
|
33
|
+
content => $str,
|
34
34
|
}
|
35
35
|
}
|
36
36
|
|
@@ -36,13 +36,13 @@ module Puppet
|
|
36
36
|
|
37
37
|
# Equivalent resources:
|
38
38
|
|
39
|
-
file {
|
40
|
-
ensure =>
|
39
|
+
file { '/etc/inetd.conf':
|
40
|
+
ensure => '/etc/inet/inetd.conf',
|
41
41
|
}
|
42
42
|
|
43
|
-
file {
|
43
|
+
file { '/etc/inetd.conf':
|
44
44
|
ensure => link,
|
45
|
-
target =>
|
45
|
+
target => '/etc/inet/inetd.conf',
|
46
46
|
}
|
47
47
|
|
48
48
|
However, we recommend using `link` and `target` explicitly, since this
|
@@ -52,11 +52,11 @@ module Puppet
|
|
52
52
|
use the first source that exists. This can be used to serve different
|
53
53
|
files to different system types:
|
54
54
|
|
55
|
-
file {
|
55
|
+
file { '/etc/nfs.conf':
|
56
56
|
source => [
|
57
|
-
"puppet:///modules/nfs/conf.$host",
|
58
|
-
"puppet:///modules/nfs/conf.$operatingsystem",
|
59
|
-
|
57
|
+
"puppet:///modules/nfs/conf.${host}",
|
58
|
+
"puppet:///modules/nfs/conf.${operatingsystem}",
|
59
|
+
'puppet:///modules/nfs/conf'
|
60
60
|
]
|
61
61
|
}
|
62
62
|
|
@@ -7,9 +7,9 @@ module Puppet
|
|
7
7
|
Symlink targets can be relative, as well as absolute:
|
8
8
|
|
9
9
|
# (Useful on Solaris)
|
10
|
-
file {
|
10
|
+
file { '/etc/inetd.conf':
|
11
11
|
ensure => link,
|
12
|
-
target =>
|
12
|
+
target => 'inet/inetd.conf',
|
13
13
|
}
|
14
14
|
|
15
15
|
Directories of symlinks can be served recursively by instead using the
|
data/lib/puppet/type/mount.rb
CHANGED
@@ -14,7 +14,11 @@ module Puppet
|
|
14
14
|
|
15
15
|
**Autorequires:** If Puppet is managing any parents of a mount resource ---
|
16
16
|
that is, other mount points higher up in the filesystem --- the child
|
17
|
-
mount will autorequire them.
|
17
|
+
mount will autorequire them. If Puppet is managing the file path of a
|
18
|
+
mount point, the mount resource will autorequire it.
|
19
|
+
|
20
|
+
**Autobefores:** If Puppet is managing any child file paths of a mount
|
21
|
+
point, the mount resource will autobefore them."
|
18
22
|
|
19
23
|
feature :refreshable, "The provider can remount the filesystem.",
|
20
24
|
:methods => [:remount]
|
@@ -293,5 +297,18 @@ module Puppet
|
|
293
297
|
dependencies[0..-2]
|
294
298
|
end
|
295
299
|
|
300
|
+
# Autorequire the mount point's file resource
|
301
|
+
autorequire(:file) { Pathname.new(self[:name]) }
|
302
|
+
|
303
|
+
# Autobefore the mount point's child file paths
|
304
|
+
autobefore(:file) do
|
305
|
+
dependencies = []
|
306
|
+
file_resources = catalog.resources.select { |resource| resource.type == :file }
|
307
|
+
children_file_resources = file_resources.select { |resource| File.expand_path(resource[:path]) =~ %r(#{self[:name]}/.) }
|
308
|
+
children_file_resources.each do |child|
|
309
|
+
dependencies.push Pathname.new(child[:path])
|
310
|
+
end
|
311
|
+
dependencies
|
312
|
+
end
|
296
313
|
end
|
297
314
|
end
|
data/lib/puppet/type/package.rb
CHANGED
@@ -238,8 +238,8 @@ module Puppet
|
|
238
238
|
}
|
239
239
|
|
240
240
|
package { 'openssl':
|
241
|
+
ensure => installed,
|
241
242
|
name => $ssl,
|
242
|
-
ensure => installed
|
243
243
|
}
|
244
244
|
|
245
245
|
. etc. .
|
@@ -250,9 +250,9 @@ module Puppet
|
|
250
250
|
}
|
251
251
|
|
252
252
|
package { 'openssh':
|
253
|
-
name => $ssh
|
254
253
|
ensure => installed,
|
255
|
-
|
254
|
+
name => $ssh,
|
255
|
+
require => Package['openssl'],
|
256
256
|
}
|
257
257
|
|
258
258
|
"
|
data/lib/puppet/type/schedule.rb
CHANGED
@@ -24,7 +24,7 @@ module Puppet
|
|
24
24
|
the hours of two and 4 AM, then you would use this schedule:
|
25
25
|
|
26
26
|
schedule { 'maint':
|
27
|
-
range =>
|
27
|
+
range => '2 - 4',
|
28
28
|
period => daily,
|
29
29
|
repeat => 1,
|
30
30
|
}
|
@@ -57,10 +57,10 @@ module Puppet
|
|
57
57
|
|
58
58
|
schedule { 'everyday':
|
59
59
|
period => daily,
|
60
|
-
range =>
|
60
|
+
range => '2 - 4',
|
61
61
|
}
|
62
62
|
|
63
|
-
exec {
|
63
|
+
exec { '/usr/bin/apt-get update':
|
64
64
|
schedule => 'everyday',
|
65
65
|
}
|
66
66
|
|
@@ -77,7 +77,7 @@ module Puppet
|
|
77
77
|
separator. For instance:
|
78
78
|
|
79
79
|
schedule { 'maintenance':
|
80
|
-
range =>
|
80
|
+
range => '1:30 - 4:30',
|
81
81
|
}
|
82
82
|
|
83
83
|
This is mostly useful for restricting certain resources to being
|
data/lib/puppet/type/service.rb
CHANGED
@@ -73,6 +73,17 @@ module Puppet
|
|
73
73
|
provider.enabled?
|
74
74
|
end
|
75
75
|
|
76
|
+
# This only makes sense on systemd systems. Static services cannot be enabled
|
77
|
+
# or disabled manually.
|
78
|
+
def insync?(current)
|
79
|
+
if provider.respond_to?(:cached_enabled?) && provider.cached_enabled? == 'static'
|
80
|
+
Puppet.debug("Unable to enable or disable static service #{@resource[:name]}")
|
81
|
+
return true
|
82
|
+
end
|
83
|
+
|
84
|
+
super(current)
|
85
|
+
end
|
86
|
+
|
76
87
|
validate do |value|
|
77
88
|
if value == :manual and !Puppet.features.microsoft_windows?
|
78
89
|
raise Puppet::Error.new("Setting enable to manual is only supported on Microsoft Windows.")
|
@@ -239,5 +250,9 @@ module Puppet
|
|
239
250
|
debug "Skipping restart; service is not running"
|
240
251
|
end
|
241
252
|
end
|
253
|
+
|
254
|
+
def self.needs_ensure_retrieved
|
255
|
+
false
|
256
|
+
end
|
242
257
|
end
|
243
258
|
end
|
data/lib/puppet/type/sshkey.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module Puppet
|
2
2
|
Type.newtype(:sshkey) do
|
3
|
-
@doc = "Installs and manages ssh host keys.
|
4
|
-
|
5
|
-
|
3
|
+
@doc = "Installs and manages ssh host keys. By default, this type will
|
4
|
+
install keys into `/etc/ssh/ssh_known_hosts`. To manage ssh keys in a
|
5
|
+
different `known_hosts` file, such as a user's personal `known_hosts`,
|
6
|
+
pass its path to the `target` parameter. See the `ssh_authorized_key`
|
7
|
+
type to manage authorized keys."
|
6
8
|
|
7
9
|
ensurable
|
8
10
|
|