puppet 6.19.0-x86-mingw32 → 6.22.1-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/CODEOWNERS +2 -16
- data/Gemfile +3 -1
- data/Gemfile.lock +50 -39
- data/ext/project_data.yaml +2 -2
- data/lib/puppet/application.rb +10 -6
- data/lib/puppet/application/agent.rb +1 -0
- data/lib/puppet/application/apply.rb +3 -2
- data/lib/puppet/application/device.rb +1 -0
- data/lib/puppet/application/filebucket.rb +2 -2
- data/lib/puppet/application/script.rb +1 -0
- data/lib/puppet/application/ssl.rb +11 -0
- data/lib/puppet/application_support.rb +7 -0
- data/lib/puppet/configurer.rb +28 -18
- data/lib/puppet/defaults.rb +46 -20
- data/lib/puppet/environments.rb +54 -55
- data/lib/puppet/face/config.rb +10 -0
- data/lib/puppet/face/epp.rb +12 -2
- data/lib/puppet/face/facts.rb +158 -0
- data/lib/puppet/ffi/posix.rb +10 -0
- data/lib/puppet/ffi/posix/constants.rb +14 -0
- data/lib/puppet/ffi/posix/functions.rb +24 -0
- data/lib/puppet/file_system/memory_file.rb +8 -1
- data/lib/puppet/file_system/windows.rb +2 -0
- data/lib/puppet/functions/epp.rb +1 -0
- data/lib/puppet/functions/inline_epp.rb +1 -0
- data/lib/puppet/functions/partition.rb +8 -0
- data/lib/puppet/indirector/fact_search.rb +60 -0
- data/lib/puppet/indirector/facts/facter.rb +24 -3
- data/lib/puppet/indirector/facts/json.rb +27 -0
- data/lib/puppet/indirector/facts/yaml.rb +3 -58
- data/lib/puppet/indirector/json.rb +5 -1
- data/lib/puppet/indirector/node/json.rb +8 -0
- data/lib/puppet/indirector/report/json.rb +34 -0
- data/lib/puppet/module_tool/applications/installer.rb +48 -2
- data/lib/puppet/module_tool/errors/shared.rb +17 -2
- data/lib/puppet/network/formats.rb +69 -1
- data/lib/puppet/network/http/factory.rb +4 -0
- data/lib/puppet/pal/pal_impl.rb +70 -17
- data/lib/puppet/parser/ast/leaf.rb +3 -2
- data/lib/puppet/parser/templatewrapper.rb +1 -1
- data/lib/puppet/pops/evaluator/deferred_resolver.rb +5 -3
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +22 -3
- data/lib/puppet/pops/model/ast_transformer.rb +1 -1
- data/lib/puppet/property/list.rb +1 -1
- data/lib/puppet/provider/group/groupadd.rb +13 -8
- data/lib/puppet/provider/package/apt.rb +34 -2
- data/lib/puppet/provider/package/aptitude.rb +6 -0
- data/lib/puppet/provider/package/dnfmodule.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +2 -0
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/user/aix.rb +2 -2
- data/lib/puppet/provider/user/useradd.rb +62 -8
- data/lib/puppet/reference/configuration.rb +6 -5
- data/lib/puppet/settings.rb +43 -15
- data/lib/puppet/settings/alias_setting.rb +37 -0
- data/lib/puppet/settings/base_setting.rb +26 -2
- data/lib/puppet/settings/environment_conf.rb +1 -0
- data/lib/puppet/type/package.rb +3 -3
- data/lib/puppet/util/autoload.rb +1 -8
- data/lib/puppet/util/fact_dif.rb +81 -0
- data/lib/puppet/util/monkey_patches.rb +7 -0
- data/lib/puppet/util/posix.rb +54 -5
- data/lib/puppet/util/rubygems.rb +5 -1
- data/lib/puppet/util/windows/adsi.rb +46 -0
- data/lib/puppet/util/windows/api_types.rb +1 -1
- data/lib/puppet/util/windows/principal.rb +9 -2
- data/lib/puppet/util/windows/service.rb +1 -1
- data/lib/puppet/util/windows/sid.rb +4 -2
- data/lib/puppet/version.rb +1 -1
- data/locales/puppet.pot +295 -219
- data/man/man5/puppet.conf.5 +15 -7
- data/man/man8/puppet-agent.8 +2 -2
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-catalog.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 +2 -2
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +90 -1
- data/man/man8/puppet-filebucket.8 +3 -3
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +4 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +4 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +2 -2
- data/man/man8/puppet-ssl.8 +5 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/integration/application/agent/cached_deferred_catalog.json +91 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services_vendor_preset +9 -0
- data/spec/fixtures/unit/provider/user/aix/aix_passwd_file.out +4 -0
- data/spec/integration/application/agent_spec.rb +160 -3
- data/spec/integration/application/apply_spec.rb +19 -0
- data/spec/integration/application/plugin_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +0 -7
- data/spec/integration/environments/setting_hooks_spec.rb +1 -1
- data/spec/integration/http/client_spec.rb +12 -0
- data/spec/integration/indirector/direct_file_server_spec.rb +1 -3
- data/spec/integration/resource/type_collection_spec.rb +2 -6
- data/spec/integration/transaction_spec.rb +4 -9
- data/spec/integration/util/windows/adsi_spec.rb +21 -1
- data/spec/integration/util/windows/principal_spec.rb +21 -0
- data/spec/integration/util/windows/registry_spec.rb +6 -10
- data/spec/lib/puppet_spec/settings.rb +6 -1
- data/spec/spec_helper.rb +12 -5
- data/spec/unit/agent_spec.rb +8 -6
- data/spec/unit/application/agent_spec.rb +0 -1
- data/spec/unit/application/config_spec.rb +224 -4
- data/spec/unit/application/facts_spec.rb +482 -3
- data/spec/unit/application/filebucket_spec.rb +0 -2
- data/spec/unit/application/ssl_spec.rb +23 -0
- data/spec/unit/application_spec.rb +51 -9
- data/spec/unit/confine/feature_spec.rb +1 -1
- data/spec/unit/confine_spec.rb +8 -2
- data/spec/unit/defaults_spec.rb +36 -1
- data/spec/unit/environments_spec.rb +221 -68
- data/spec/unit/face/config_spec.rb +27 -32
- data/spec/unit/face/facts_spec.rb +4 -0
- data/spec/unit/face/node_spec.rb +0 -11
- data/spec/unit/file_serving/configuration/parser_spec.rb +0 -1
- data/spec/unit/file_serving/metadata_spec.rb +3 -3
- data/spec/unit/file_serving/terminus_helper_spec.rb +11 -4
- data/spec/unit/file_system_spec.rb +9 -0
- data/spec/unit/forge/module_release_spec.rb +2 -7
- data/spec/unit/functions/inline_epp_spec.rb +26 -1
- data/spec/unit/http/service/compiler_spec.rb +49 -0
- data/spec/unit/http/service_spec.rb +1 -1
- data/spec/unit/indirector/face_spec.rb +0 -1
- data/spec/unit/indirector/facts/facter_spec.rb +95 -1
- data/spec/unit/indirector/facts/json_spec.rb +255 -0
- data/spec/unit/indirector/file_bucket_file/selector_spec.rb +26 -8
- data/spec/unit/indirector/indirection_spec.rb +8 -12
- data/spec/unit/indirector/key/file_spec.rb +0 -1
- data/spec/unit/indirector/node/json_spec.rb +33 -0
- data/spec/{integration/indirector/report/yaml.rb → unit/indirector/report/json_spec.rb} +13 -24
- data/spec/unit/indirector/report/yaml_spec.rb +72 -8
- data/spec/unit/indirector_spec.rb +2 -2
- data/spec/unit/module_tool/applications/installer_spec.rb +66 -0
- data/spec/unit/network/authconfig_spec.rb +0 -3
- data/spec/unit/network/formats_spec.rb +41 -0
- data/spec/unit/network/http/api/indirected_routes_spec.rb +0 -9
- data/spec/unit/network/http/factory_spec.rb +19 -0
- data/spec/unit/network/http/handler_spec.rb +0 -5
- data/spec/unit/parser/compiler_spec.rb +3 -19
- data/spec/unit/parser/resource_spec.rb +14 -8
- data/spec/unit/parser/templatewrapper_spec.rb +4 -3
- data/spec/unit/pops/evaluator/deferred_resolver_spec.rb +20 -0
- data/spec/unit/property_spec.rb +1 -0
- data/spec/unit/provider/group/groupadd_spec.rb +5 -2
- data/spec/unit/provider/nameservice_spec.rb +66 -65
- data/spec/unit/provider/package/apt_spec.rb +28 -23
- data/spec/unit/provider/package/aptitude_spec.rb +1 -1
- data/spec/unit/provider/package/base_spec.rb +6 -5
- data/spec/unit/provider/package/dnfmodule_spec.rb +10 -1
- data/spec/unit/provider/package/pacman_spec.rb +18 -12
- data/spec/unit/provider/package/pip_spec.rb +6 -11
- data/spec/unit/provider/package/pkgdmg_spec.rb +0 -4
- data/spec/unit/provider/service/systemd_spec.rb +11 -0
- data/spec/unit/provider/user/aix_spec.rb +5 -0
- data/spec/unit/provider/user/hpux_spec.rb +1 -1
- data/spec/unit/provider/user/pw_spec.rb +2 -0
- data/spec/unit/provider/user/useradd_spec.rb +71 -3
- data/spec/unit/provider_spec.rb +8 -10
- data/spec/unit/puppet_pal_catalog_spec.rb +45 -0
- data/spec/unit/resource/capability_finder_spec.rb +6 -1
- data/spec/unit/resource/catalog_spec.rb +1 -1
- data/spec/unit/resource/type_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +11 -10
- data/spec/unit/settings_spec.rb +543 -228
- data/spec/unit/ssl/base_spec.rb +0 -1
- data/spec/unit/ssl/host_spec.rb +0 -5
- data/spec/unit/ssl/ssl_provider_spec.rb +14 -8
- data/spec/unit/transaction/additional_resource_generator_spec.rb +3 -7
- data/spec/unit/transaction/event_manager_spec.rb +14 -11
- data/spec/unit/transaction_spec.rb +13 -4
- data/spec/unit/type/file/content_spec.rb +0 -1
- data/spec/unit/type/file/selinux_spec.rb +0 -2
- data/spec/unit/type/file_spec.rb +0 -6
- data/spec/unit/type/group_spec.rb +13 -6
- data/spec/unit/type/resources_spec.rb +7 -7
- data/spec/unit/type/service_spec.rb +1 -1
- data/spec/unit/type/tidy_spec.rb +0 -1
- data/spec/unit/type_spec.rb +2 -2
- data/spec/unit/util/at_fork_spec.rb +2 -2
- data/spec/unit/util/autoload_spec.rb +5 -1
- data/spec/unit/util/backups_spec.rb +1 -2
- data/spec/unit/util/execution_spec.rb +15 -11
- data/spec/unit/util/inifile_spec.rb +6 -14
- data/spec/unit/util/log_spec.rb +8 -7
- data/spec/unit/util/logging_spec.rb +3 -3
- data/spec/unit/util/posix_spec.rb +363 -15
- data/spec/unit/util/rubygems_spec.rb +2 -2
- data/spec/unit/util/selinux_spec.rb +76 -52
- data/spec/unit/util/storage_spec.rb +3 -1
- data/spec/unit/util/suidmanager_spec.rb +44 -41
- data/spec/unit/util/windows/sid_spec.rb +6 -0
- data/spec/unit/util_spec.rb +13 -6
- metadata +31 -16
- data/spec/integration/application/config_spec.rb +0 -74
- data/spec/lib/matchers/include.rb +0 -27
- data/spec/lib/matchers/include_spec.rb +0 -32
- data/spec/unit/face/catalog_spec.rb +0 -6
- data/spec/unit/face/module_spec.rb +0 -3
@@ -93,7 +93,7 @@ Puppet::Type.type(:package).provide :dnfmodule, :parent => :dnf do
|
|
93
93
|
# module has no default profile and no profile was requested, so just enable the stream
|
94
94
|
# DNF versions prior to 4.2.8 do not need this workaround
|
95
95
|
# see https://bugzilla.redhat.com/show_bug.cgi?id=1669527
|
96
|
-
if @resource[:flavor] == nil && e.message =~ /^missing groups or modules: #{Regexp.quote(@resource[:name])}$/
|
96
|
+
if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(@resource[:name])}$/
|
97
97
|
enable(args)
|
98
98
|
else
|
99
99
|
raise
|
@@ -17,6 +17,8 @@ Puppet::Type.type(:service).provide :debian, :parent => :init do
|
|
17
17
|
commands :invoke_rc => "/usr/sbin/invoke-rc.d"
|
18
18
|
commands :service => "/usr/sbin/service"
|
19
19
|
|
20
|
+
confine :false => Puppet::FileSystem.exist?('/proc/1/comm') && Puppet::FileSystem.read('/proc/1/comm').include?('systemd')
|
21
|
+
|
20
22
|
defaultfor :operatingsystem => :cumuluslinux, :operatingsystemmajrelease => ['1','2']
|
21
23
|
defaultfor :operatingsystem => :debian, :operatingsystemmajrelease => ['5','6','7']
|
22
24
|
defaultfor :operatingsystem => :devuan
|
@@ -30,7 +30,7 @@ Puppet::Type.type(:service).provide :systemd, :parent => :base do
|
|
30
30
|
def self.instances
|
31
31
|
i = []
|
32
32
|
output = systemctl('list-unit-files', '--type', 'service', '--full', '--all', '--no-pager')
|
33
|
-
output.scan(/^(\S+)\s+(disabled|enabled|masked|indirect|bad|static)\s*$/i).each do |m|
|
33
|
+
output.scan(/^(\S+)\s+(disabled|enabled|masked|indirect|bad|static)\s*([^-]\S+)?\s*$/i).each do |m|
|
34
34
|
Puppet.debug("#{m[0]} marked as bad by `systemctl`. It is recommended to be further checked.") if m[1] == "bad"
|
35
35
|
i << new(:name => m[0])
|
36
36
|
end
|
@@ -178,7 +178,7 @@ Puppet::Type.type(:user).provide :aix, :parent => Puppet::Provider::AixObject do
|
|
178
178
|
# does not have a password.
|
179
179
|
break if line =~ /^\S+:$/
|
180
180
|
|
181
|
-
match_obj = /password
|
181
|
+
match_obj = /password\s+=\s+(\S+)/.match(line)
|
182
182
|
end
|
183
183
|
return :absent unless match_obj
|
184
184
|
|
@@ -211,7 +211,7 @@ Puppet::Type.type(:user).provide :aix, :parent => Puppet::Provider::AixObject do
|
|
211
211
|
tempfile = Tempfile.new("puppet_#{user}_pw", :encoding => Encoding::ASCII)
|
212
212
|
tempfile << "#{user}:#{value}\n"
|
213
213
|
tempfile.close()
|
214
|
-
|
214
|
+
|
215
215
|
# Options '-e', '-c', use encrypted password and clear flags
|
216
216
|
# Must receive "user:enc_password" as input
|
217
217
|
# command, arguments = {:failonfail => true, :combine => true}
|
@@ -59,23 +59,37 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
|
|
59
59
|
get(:uid)
|
60
60
|
end
|
61
61
|
|
62
|
+
def gid
|
63
|
+
return localgid if @resource.forcelocal?
|
64
|
+
get(:gid)
|
65
|
+
end
|
66
|
+
|
62
67
|
def comment
|
63
68
|
return localcomment if @resource.forcelocal?
|
64
69
|
get(:comment)
|
65
70
|
end
|
66
71
|
|
72
|
+
def groups
|
73
|
+
return localgroups if @resource.forcelocal?
|
74
|
+
super
|
75
|
+
end
|
76
|
+
|
67
77
|
def finduser(key, value)
|
68
|
-
passwd_file =
|
78
|
+
passwd_file = '/etc/passwd'
|
69
79
|
passwd_keys = [:account, :password, :uid, :gid, :gecos, :directory, :shell]
|
70
|
-
|
71
|
-
@
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
80
|
+
|
81
|
+
unless @users
|
82
|
+
unless Puppet::FileSystem.exist?(passwd_file)
|
83
|
+
raise Puppet::Error.new("Forcelocal set for user resource '#{resource[:name]}', but #{passwd_file} does not exist")
|
84
|
+
end
|
85
|
+
|
86
|
+
@users = []
|
87
|
+
Puppet::FileSystem.each_line(passwd_file) do |line|
|
88
|
+
user = line.chomp.split(':')
|
89
|
+
@users << Hash[passwd_keys.zip(user)]
|
76
90
|
end
|
77
91
|
end
|
78
|
-
false
|
92
|
+
@users.find { |param| param[key] == value } || false
|
79
93
|
end
|
80
94
|
|
81
95
|
def local_username
|
@@ -88,16 +102,56 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
|
|
88
102
|
false
|
89
103
|
end
|
90
104
|
|
105
|
+
def localgid
|
106
|
+
user = finduser(:account, resource[:name])
|
107
|
+
if user
|
108
|
+
begin
|
109
|
+
return Integer(user[:gid])
|
110
|
+
rescue ArgumentError
|
111
|
+
Puppet.debug("Non-numeric GID found in /etc/passwd for user #{resource[:name]}")
|
112
|
+
return user[:gid]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
false
|
116
|
+
end
|
117
|
+
|
91
118
|
def localcomment
|
92
119
|
user = finduser(:account, resource[:name])
|
93
120
|
user[:gecos]
|
94
121
|
end
|
95
122
|
|
123
|
+
def localgroups
|
124
|
+
@groups_of ||= {}
|
125
|
+
group_file = '/etc/group'
|
126
|
+
user = resource[:name]
|
127
|
+
|
128
|
+
return @groups_of[user] if @groups_of[user]
|
129
|
+
|
130
|
+
@groups_of[user] = []
|
131
|
+
|
132
|
+
unless Puppet::FileSystem.exist?(group_file)
|
133
|
+
raise Puppet::Error.new("Forcelocal set for user resource '#{user}', but #{group_file} does not exist")
|
134
|
+
end
|
135
|
+
|
136
|
+
Puppet::FileSystem.each_line(group_file) do |line|
|
137
|
+
data = line.chomp.split(':')
|
138
|
+
if !data.empty? && data.last.split(',').include?(user)
|
139
|
+
@groups_of[user] << data.first
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
@groups_of[user]
|
144
|
+
end
|
145
|
+
|
96
146
|
def shell=(value)
|
97
147
|
check_valid_shell
|
98
148
|
set(:shell, value)
|
99
149
|
end
|
100
150
|
|
151
|
+
def groups=(value)
|
152
|
+
set(:groups, value)
|
153
|
+
end
|
154
|
+
|
101
155
|
verify :gid, "GID must be an integer" do |value|
|
102
156
|
value.is_a? Integer
|
103
157
|
end
|
@@ -55,11 +55,12 @@ config.header = <<EOT
|
|
55
55
|
* Each of these settings can be specified in `puppet.conf` or on the
|
56
56
|
command line.
|
57
57
|
* Puppet Enterprise (PE) and open source Puppet share the configuration settings
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
documented here. However, PE defaults differ from open source defaults for some
|
59
|
+
settings, such as `node_terminus`, `storeconfigs`, `always_retry_plugins`,
|
60
|
+
`disable18n`, `environment_timeout` (when Code Manager is enabled), and the
|
61
|
+
Puppet Server JRuby `max-active-instances` setting. To verify PE configuration
|
62
|
+
defaults, check the `puppet.conf` or `pe-puppet-server.conf` file after
|
63
|
+
installation.
|
63
64
|
* When using boolean settings on the command line, use `--setting` and
|
64
65
|
`--no-setting` instead of `--setting (true|false)`. (Using `--setting false`
|
65
66
|
results in "Error: Could not parse application options: needless argument".)
|
data/lib/puppet/settings.rb
CHANGED
@@ -32,6 +32,7 @@ class Puppet::Settings
|
|
32
32
|
require 'puppet/settings/server_list_setting'
|
33
33
|
require 'puppet/settings/http_extra_headers_setting'
|
34
34
|
require 'puppet/settings/certificate_revocation_setting'
|
35
|
+
require 'puppet/settings/alias_setting'
|
35
36
|
|
36
37
|
# local reference for convenience
|
37
38
|
PuppetOptionParser = Puppet::Util::CommandLine::PuppetOptionParser
|
@@ -729,7 +730,8 @@ class Puppet::Settings
|
|
729
730
|
:autosign => AutosignSetting,
|
730
731
|
:server_list => ServerListSetting,
|
731
732
|
:http_extra_headers => HttpExtraHeadersSetting,
|
732
|
-
:certificate_revocation => CertificateRevocationSetting
|
733
|
+
:certificate_revocation => CertificateRevocationSetting,
|
734
|
+
:alias => AliasSetting
|
733
735
|
}
|
734
736
|
|
735
737
|
# Create a new setting. The value is passed in because it's used to determine
|
@@ -916,6 +918,16 @@ class Puppet::Settings
|
|
916
918
|
end
|
917
919
|
end
|
918
920
|
|
921
|
+
# Allow later inspection to determine if the setting was set by user
|
922
|
+
# config, rather than a default setting.
|
923
|
+
def set_in_section?(param, section)
|
924
|
+
param = param.to_sym
|
925
|
+
vals = searchpath_values(SearchPathElement.new(section, :section))
|
926
|
+
if vals
|
927
|
+
vals.lookup(param)
|
928
|
+
end
|
929
|
+
end
|
930
|
+
|
919
931
|
# Patches the value for a param in a section.
|
920
932
|
# This method is required to support the use case of unifying --dns-alt-names and
|
921
933
|
# --dns_alt_names in the certificate face. Ideally this should be cleaned up.
|
@@ -1250,27 +1262,37 @@ Generated on #{Time.now}.
|
|
1250
1262
|
end
|
1251
1263
|
|
1252
1264
|
def add_environment_resources(catalog, sections)
|
1253
|
-
path = self[:environmentpath]
|
1254
|
-
envdir = path.split(File::PATH_SEPARATOR).first if path
|
1255
1265
|
configured_environment = self[:environment]
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1266
|
+
|
1267
|
+
if configured_environment == "production" && !production_environment_exists?
|
1268
|
+
environment_path = self[:environmentpath]
|
1269
|
+
first_environment_path = environment_path.split(File::PATH_SEPARATOR).first
|
1270
|
+
|
1271
|
+
if Puppet::FileSystem.exist?(first_environment_path)
|
1272
|
+
production_environment_path = File.join(first_environment_path, configured_environment)
|
1261
1273
|
parameters = { :ensure => 'directory' }
|
1262
|
-
|
1263
|
-
|
1264
|
-
if
|
1265
|
-
|
1266
|
-
parameters[:group] = Puppet[:group] if service_group_available?
|
1267
|
-
end
|
1274
|
+
parameters[:mode] = '0750'
|
1275
|
+
if Puppet.features.root?
|
1276
|
+
parameters[:owner] = Puppet[:user] if service_user_available?
|
1277
|
+
parameters[:group] = Puppet[:group] if service_group_available?
|
1268
1278
|
end
|
1269
|
-
catalog.add_resource(Puppet::Resource.new(:file,
|
1279
|
+
catalog.add_resource(Puppet::Resource.new(:file, production_environment_path, :parameters => parameters))
|
1270
1280
|
end
|
1271
1281
|
end
|
1272
1282
|
end
|
1273
1283
|
|
1284
|
+
def production_environment_exists?
|
1285
|
+
environment_path = self[:environmentpath]
|
1286
|
+
paths = environment_path.split(File::PATH_SEPARATOR)
|
1287
|
+
|
1288
|
+
paths.any? do |path|
|
1289
|
+
# If expected_path is a symlink, assume the source path is being managed
|
1290
|
+
# elsewhere, so accept it also as a valid production environment path
|
1291
|
+
expected_path = File.join(path, 'production')
|
1292
|
+
Puppet::FileSystem.directory?(expected_path) || Puppet::FileSystem.symlink?(expected_path)
|
1293
|
+
end
|
1294
|
+
end
|
1295
|
+
|
1274
1296
|
def add_user_resources(catalog, sections)
|
1275
1297
|
return unless Puppet.features.root?
|
1276
1298
|
return if Puppet::Util::Platform.windows?
|
@@ -1371,6 +1393,12 @@ Generated on #{Time.now}.
|
|
1371
1393
|
end
|
1372
1394
|
end
|
1373
1395
|
|
1396
|
+
setting = @defaults[name]
|
1397
|
+
if setting.respond_to?(:alias_name)
|
1398
|
+
val = lookup(setting.alias_name)
|
1399
|
+
return val if val
|
1400
|
+
end
|
1401
|
+
|
1374
1402
|
@defaults[name].default
|
1375
1403
|
end
|
1376
1404
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Puppet::Settings::AliasSetting
|
2
|
+
attr_reader :name, :alias_name
|
3
|
+
|
4
|
+
def initialize(args = {})
|
5
|
+
@name = args[:name]
|
6
|
+
@alias_name = args[:alias_for]
|
7
|
+
@alias_for = Puppet.settings.setting(alias_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def optparse_args
|
11
|
+
args = @alias_for.optparse_args
|
12
|
+
args[0].gsub!(alias_name.to_s, name.to_s)
|
13
|
+
args
|
14
|
+
end
|
15
|
+
|
16
|
+
def getopt_args
|
17
|
+
args = @alias_for.getopt_args
|
18
|
+
args[0].gsub!(alias_name.to_s, name.to_s)
|
19
|
+
args
|
20
|
+
end
|
21
|
+
|
22
|
+
def type
|
23
|
+
:alias
|
24
|
+
end
|
25
|
+
|
26
|
+
def method_missing(method, *args)
|
27
|
+
begin
|
28
|
+
alias_for.send(method, *args)
|
29
|
+
rescue => e
|
30
|
+
Puppet.log_exception(self.class, e.message)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
attr_reader :alias_for
|
37
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'set'
|
1
2
|
require 'puppet/settings/errors'
|
2
3
|
|
3
4
|
# The base setting type
|
@@ -5,27 +6,50 @@ class Puppet::Settings::BaseSetting
|
|
5
6
|
attr_accessor :name, :desc, :section, :default, :call_hook
|
6
7
|
attr_reader :short, :deprecated
|
7
8
|
|
9
|
+
# Hooks are called during different parts of the settings lifecycle:
|
10
|
+
#
|
11
|
+
# * :on_write_only - This is the default hook type. The hook will be called
|
12
|
+
# if its value is set in `main` or programmatically. If its value is set in
|
13
|
+
# a section that doesn't match the application's run mode, it will be
|
14
|
+
# ignored entirely. If the section does match the run mode, the value will
|
15
|
+
# be used, but the hook will not be called!
|
16
|
+
#
|
17
|
+
# * :on_define_and_write - The hook behaves the same as above, except it is
|
18
|
+
# also called immediately when the setting is defined in
|
19
|
+
# {Puppet::Settings.define_settings}. In that case, the hook receives the
|
20
|
+
# default value as specified.
|
21
|
+
#
|
22
|
+
# * :on_initialize_and_write - The hook will be called if the value is set in
|
23
|
+
# `main`, the section that matches the run mode, or programmatically.
|
24
|
+
#
|
25
|
+
HOOK_TYPES = Set.new([:on_define_and_write, :on_initialize_and_write, :on_write_only]).freeze
|
26
|
+
|
8
27
|
def self.available_call_hook_values
|
9
|
-
|
28
|
+
HOOK_TYPES.to_a
|
10
29
|
end
|
11
30
|
|
31
|
+
# Registers a hook to be called later based on the type of hook specified in `value`.
|
32
|
+
#
|
33
|
+
# @param value [Symbol] One of {HOOK_TYPES}
|
12
34
|
def call_hook=(value)
|
13
35
|
if value.nil?
|
14
36
|
#TRANSLATORS ':%{name}', ':call_hook', and ':on_write_only' should not be translated
|
15
37
|
Puppet.warning _("Setting :%{name} :call_hook is nil, defaulting to :on_write_only") % { name: name }
|
16
38
|
value = :on_write_only
|
17
39
|
end
|
18
|
-
unless
|
40
|
+
unless HOOK_TYPES.include?(value)
|
19
41
|
#TRANSLATORS 'call_hook' is a Puppet option name and should not be translated
|
20
42
|
raise ArgumentError, _("Invalid option %{value} for call_hook") % { value: value }
|
21
43
|
end
|
22
44
|
@call_hook = value
|
23
45
|
end
|
24
46
|
|
47
|
+
# @see {HOOK_TYPES}
|
25
48
|
def call_hook_on_define?
|
26
49
|
call_hook == :on_define_and_write
|
27
50
|
end
|
28
51
|
|
52
|
+
# @see {HOOK_TYPES}
|
29
53
|
def call_hook_on_initialize?
|
30
54
|
call_hook == :on_initialize_and_write
|
31
55
|
end
|
@@ -29,6 +29,7 @@ class Puppet::Settings::EnvironmentConf
|
|
29
29
|
section = config.sections[:main]
|
30
30
|
rescue Errno::ENOENT
|
31
31
|
# environment.conf is an optional file
|
32
|
+
Puppet.debug { "Path to #{path_to_env} does not exist, using default environment.conf" }
|
32
33
|
end
|
33
34
|
|
34
35
|
new(path_to_env, section, global_module_path)
|
data/lib/puppet/type/package.rb
CHANGED
@@ -426,10 +426,10 @@ module Puppet
|
|
426
426
|
end
|
427
427
|
|
428
428
|
newparam(:source) do
|
429
|
-
desc "Where to find the package file. This is
|
429
|
+
desc "Where to find the package file. This is mostly used by providers that don't
|
430
430
|
automatically download packages from a central repository. (For example:
|
431
|
-
the `yum`
|
432
|
-
`dpkg` providers require it.)
|
431
|
+
the `yum` provider ignores this attribute, `apt` provider uses it if present
|
432
|
+
and the `rpm` and `dpkg` providers require it.)
|
433
433
|
|
434
434
|
Different providers accept different values for `source`. Most providers
|
435
435
|
accept paths to local files stored on the target system. Some providers
|
data/lib/puppet/util/autoload.rb
CHANGED
@@ -166,14 +166,7 @@ class Puppet::Util::Autoload
|
|
166
166
|
# Normalize a path. This converts ALT_SEPARATOR to SEPARATOR on Windows
|
167
167
|
# and eliminates unnecessary parts of a path.
|
168
168
|
def cleanpath(path)
|
169
|
-
|
170
|
-
# paths correctly on windows (c:\ and c:/ are treated as distinct) but
|
171
|
-
# we don't want to convert relative paths to absolute
|
172
|
-
if Puppet::Util.absolute_path?(path)
|
173
|
-
File.expand_path(path)
|
174
|
-
else
|
175
|
-
Pathname.new(path).cleanpath.to_s
|
176
|
-
end
|
169
|
+
Pathname.new(path).cleanpath.to_s
|
177
170
|
end
|
178
171
|
end
|
179
172
|
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class FactDif
|
4
|
+
def initialize(old_output, new_output, exclude_list, save_structured)
|
5
|
+
@c_facter = JSON.parse(old_output)
|
6
|
+
@next_facter = JSON.parse(new_output)
|
7
|
+
@exclude_list = exclude_list
|
8
|
+
@save_structured = save_structured
|
9
|
+
@flat_diff = []
|
10
|
+
@diff = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def difs
|
14
|
+
search_hash(((@c_facter.to_a - @next_facter.to_a) | (@next_facter.to_a - @c_facter.to_a)).to_h)
|
15
|
+
|
16
|
+
@flat_diff.sort_by { |a| a[0] }.each do |pair|
|
17
|
+
fact_path = pair[0]
|
18
|
+
value = pair[1]
|
19
|
+
compare(fact_path, value, @c_facter)
|
20
|
+
compare(fact_path, value, @next_facter)
|
21
|
+
end
|
22
|
+
|
23
|
+
@diff
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def search_hash(sh, path = [])
|
29
|
+
if sh.is_a?(Hash)
|
30
|
+
sh.each do |k, v|
|
31
|
+
search_hash(v, path.push(k))
|
32
|
+
path.pop
|
33
|
+
end
|
34
|
+
elsif sh.is_a?(Array)
|
35
|
+
sh.each_with_index do |v, index|
|
36
|
+
search_hash(v, path.push(index))
|
37
|
+
path.pop
|
38
|
+
end
|
39
|
+
else
|
40
|
+
@flat_diff.push([path.dup, sh])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def compare(fact_path, given_value, compared_hash)
|
45
|
+
compared_value = compared_hash.dig(*fact_path)
|
46
|
+
if different?(compared_value, given_value) && !excluded?(fact_path.join('.'))
|
47
|
+
fact_path = fact_path.map{|f| f.to_s.include?('.') ? "\"#{f}\"" : f}.join('.') unless @save_structured
|
48
|
+
if compared_hash == @c_facter
|
49
|
+
bury(*fact_path, { :new_value => given_value, :old_value => compared_value }, @diff)
|
50
|
+
else
|
51
|
+
bury(*fact_path, { :new_value => compared_value, :old_value => given_value }, @diff)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def bury(*paths, value, hash)
|
57
|
+
if paths.count > 1
|
58
|
+
path = paths.shift
|
59
|
+
hash[path] = Hash.new unless hash.key?(path)
|
60
|
+
bury(*paths, value, hash[path])
|
61
|
+
else
|
62
|
+
hash[*paths] = value
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def different?(new, old)
|
67
|
+
if old.is_a?(String) && new.is_a?(String) && (old.include?(',') || new.include?(','))
|
68
|
+
old_values = old.split(',')
|
69
|
+
new_values = new.split(',')
|
70
|
+
|
71
|
+
diff = (old_values - new_values) | (new_values - old_values)
|
72
|
+
return diff.size.positive?
|
73
|
+
end
|
74
|
+
|
75
|
+
old != new
|
76
|
+
end
|
77
|
+
|
78
|
+
def excluded?(fact_name)
|
79
|
+
@exclude_list.any? {|excluded_fact| fact_name =~ /#{excluded_fact}/}
|
80
|
+
end
|
81
|
+
end
|