puppet 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +20 -20
- data/Guardfile.example +76 -0
- data/LICENSE +189 -4
- data/README.md +3 -3
- data/Rakefile +5 -2
- data/ext/solaris/smf/svc-puppetd +8 -1
- data/ext/solaris/smf/svc-puppetmasterd +8 -1
- data/lib/puppet/application/apply.rb +100 -59
- data/lib/puppet/application/cert.rb +4 -114
- data/lib/puppet/application/device.rb +48 -32
- data/lib/puppet/application/script.rb +1 -1
- data/lib/puppet/application/ssl.rb +135 -51
- data/lib/puppet/application.rb +5 -0
- data/lib/puppet/configurer.rb +2 -3
- data/lib/puppet/defaults.rb +33 -49
- data/lib/puppet/etc.rb +20 -0
- data/lib/puppet/face/config.rb +3 -3
- data/lib/puppet/face/key.rb +1 -1
- data/lib/puppet/face/node/clean.rb +0 -1
- data/lib/puppet/feature/base.rb +1 -1
- data/lib/puppet/file_bucket/dipper.rb +1 -1
- data/lib/puppet/file_serving/fileset.rb +1 -1
- data/lib/puppet/functions/abs.rb +1 -1
- data/lib/puppet/functions/new.rb +1 -1
- data/lib/puppet/module/task.rb +29 -38
- data/lib/puppet/pal/catalog_compiler.rb +96 -0
- data/lib/puppet/pal/compiler.rb +221 -0
- data/lib/puppet/pal/function_signature.rb +52 -0
- data/lib/puppet/pal/json_catalog_encoder.rb +67 -0
- data/lib/puppet/pal/pal_api.rb +15 -0
- data/lib/puppet/pal/pal_impl.rb +523 -0
- data/lib/puppet/pal/plan_signature.rb +71 -0
- data/lib/puppet/pal/script_compiler.rb +71 -0
- data/lib/puppet/pal/task_signature.rb +58 -0
- data/lib/puppet/parser/catalog_compiler.rb +24 -0
- data/lib/puppet/parser/compiler.rb +3 -1
- data/lib/puppet/parser/functions/generate.rb +7 -6
- data/lib/puppet/plugins/configuration.rb +5 -1
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +3 -1
- data/lib/puppet/pops/evaluator/deferred_resolver.rb +3 -0
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -1
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +3 -3
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +2 -2
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +19 -10
- data/lib/puppet/pops/loader/task_instantiator.rb +13 -70
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
- data/lib/puppet/pops/parser/lexer2.rb +1 -1
- data/lib/puppet/pops/pcore.rb +10 -33
- data/lib/puppet/pops/serialization/to_data_converter.rb +9 -1
- data/lib/puppet/pops/serialization.rb +1 -0
- data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
- data/lib/puppet/pops/types/string_converter.rb +18 -4
- data/lib/puppet/pops/validation/checker4_0.rb +17 -2
- data/lib/puppet/provider/exec.rb +59 -57
- data/lib/puppet/provider/group/aix.rb +18 -2
- data/lib/puppet/provider/group/windows_adsi.rb +7 -3
- data/lib/puppet/provider/nameservice.rb +1 -25
- data/lib/puppet/provider/package/dnf.rb +2 -0
- data/lib/puppet/provider/package/pkgng.rb +37 -21
- data/lib/puppet/provider/package/portage.rb +2 -2
- data/lib/puppet/provider/package/windows/exe_package.rb +16 -10
- data/lib/puppet/provider/package/windows/msi_package.rb +8 -0
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/package/windows.rb +2 -2
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/parsedfile.rb +25 -4
- data/lib/puppet/provider/service/launchd.rb +19 -3
- data/lib/puppet/provider/service/smf.rb +54 -0
- data/lib/puppet/provider/service/systemd.rb +19 -0
- data/lib/puppet/provider/service/upstart.rb +1 -0
- data/lib/puppet/provider/service/windows.rb +22 -5
- data/lib/puppet/provider/user/aix.rb +48 -2
- data/lib/puppet/provider/user/useradd.rb +2 -10
- data/lib/puppet/provider/user/windows_adsi.rb +9 -1
- data/lib/puppet/resource/catalog.rb +1 -5
- data/lib/puppet/resource.rb +3 -1
- data/lib/puppet/ssl/host.rb +26 -16
- data/lib/puppet/syntax_checkers/epp.rb +34 -0
- data/lib/puppet/syntax_checkers/pp.rb +34 -0
- data/lib/puppet/transaction/event_manager.rb +13 -1
- data/lib/puppet/transaction/persistence.rb +1 -1
- data/lib/puppet/transaction/resource_harness.rb +3 -1
- data/lib/puppet/type/group.rb +29 -1
- data/lib/puppet/type/package.rb +5 -1
- data/lib/puppet/type/resources.rb +12 -2
- data/lib/puppet/type/schedule.rb +7 -0
- data/lib/puppet/type/service.rb +12 -0
- data/lib/puppet/type/user.rb +5 -2
- data/lib/puppet/type.rb +6 -0
- data/lib/puppet/util/command_line.rb +2 -3
- data/lib/puppet/util/execution.rb +15 -1
- data/lib/puppet/util/filetype.rb +56 -8
- data/lib/puppet/util/log/destinations.rb +3 -2
- data/lib/puppet/util/logging.rb +3 -2
- data/lib/puppet/util/posix.rb +15 -0
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/storage.rb +12 -0
- data/lib/puppet/util/windows/adsi.rb +79 -2
- data/lib/puppet/util/windows/api_types.rb +1 -1
- data/lib/puppet/util/windows/process.rb +23 -3
- data/lib/puppet/util/windows/registry.rb +29 -5
- data/lib/puppet/util/windows/security.rb +14 -0
- data/lib/puppet/util/windows/service.rb +294 -74
- data/lib/puppet/util/windows/user.rb +3 -5
- data/lib/puppet/util.rb +7 -3
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +1 -0
- data/lib/puppet_pal.rb +5 -1099
- data/locales/ja/puppet.po +952 -986
- data/locales/puppet.pot +592 -347
- data/man/man5/puppet.conf.5 +26 -31
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +4 -4
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +23 -19
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +2 -2
- 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 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +26 -3
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/bad_func_load.rb +11 -0
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query +7 -1
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query.zsh +1 -0
- data/spec/fixtures/unit/provider/service/smf/svcs_fmri.out +6 -0
- data/spec/fixtures/unit/provider/service/smf/svcs_multiple_fmris.out +13 -0
- data/spec/integration/application/apply_spec.rb +4 -1
- data/spec/integration/parser/collection_spec.rb +4 -8
- data/spec/integration/provider/service/windows_spec.rb +5 -5
- data/spec/integration/ssl/key_spec.rb +0 -4
- data/spec/integration/transaction_spec.rb +559 -0
- data/spec/integration/type/file_spec.rb +6 -6
- data/spec/integration/util/windows/registry_spec.rb +39 -0
- data/spec/integration/util/windows/security_spec.rb +10 -7
- data/spec/integration/util/windows/user_spec.rb +37 -17
- data/spec/lib/puppet/test_ca.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/agent_spec.rb +2 -2
- data/spec/unit/application/apply_spec.rb +55 -2
- data/spec/unit/application/device_spec.rb +10 -7
- data/spec/unit/application/face_base_spec.rb +1 -1
- data/spec/unit/application/lookup_spec.rb +2 -1
- data/spec/unit/application/ssl_spec.rb +178 -109
- data/spec/unit/application_spec.rb +29 -11
- data/spec/unit/configurer/downloader_spec.rb +1 -1
- data/spec/unit/configurer_spec.rb +16 -5
- data/spec/unit/etc_spec.rb +25 -0
- data/spec/unit/face/node_spec.rb +1 -3
- data/spec/unit/face/parser_spec.rb +15 -0
- data/spec/unit/file_serving/fileset_spec.rb +11 -11
- data/spec/unit/functions/logging_spec.rb +10 -3
- data/spec/unit/indirector/catalog/json_spec.rb +9 -3
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +2 -2
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +36 -0
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +22 -4
- data/spec/unit/pops/loaders/loader_spec.rb +9 -17
- data/spec/unit/pops/loaders/loaders_spec.rb +48 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +7 -7
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +16 -0
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +9 -0
- data/spec/unit/pops/types/p_timespan_type_spec.rb +22 -0
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +19 -0
- data/spec/unit/pops/types/string_converter_spec.rb +25 -1
- data/spec/unit/pops/types/task_spec.rb +42 -116
- data/spec/unit/pops/validator/validator_spec.rb +24 -10
- data/spec/unit/provider/exec/posix_spec.rb +24 -0
- data/spec/unit/provider/group/aix_spec.rb +20 -6
- data/spec/unit/provider/group/ldap_spec.rb +22 -25
- data/spec/unit/provider/group/pw_spec.rb +7 -10
- data/spec/unit/provider/group/windows_adsi_spec.rb +42 -33
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +97 -103
- data/spec/unit/provider/package/aix_spec.rb +5 -8
- data/spec/unit/provider/package/apt_spec.rb +3 -6
- data/spec/unit/provider/package/dnf_spec.rb +38 -25
- data/spec/unit/provider/package/dpkg_spec.rb +18 -21
- data/spec/unit/provider/package/freebsd_spec.rb +4 -7
- data/spec/unit/provider/package/gem_spec.rb +41 -41
- data/spec/unit/provider/package/hpux_spec.rb +7 -10
- data/spec/unit/provider/package/macports_spec.rb +13 -15
- data/spec/unit/provider/package/nim_spec.rb +3 -10
- data/spec/unit/provider/package/openbsd_spec.rb +14 -17
- data/spec/unit/provider/package/pip3_spec.rb +3 -6
- data/spec/unit/provider/package/pip_spec.rb +45 -49
- data/spec/unit/provider/package/pkgin_spec.rb +13 -18
- data/spec/unit/provider/package/pkgng_spec.rb +32 -27
- data/spec/unit/provider/package/puppet_gem_spec.rb +6 -9
- data/spec/unit/provider/package/tdnf_spec.rb +9 -12
- data/spec/unit/provider/package/windows/exe_package_spec.rb +3 -3
- data/spec/unit/provider/package/windows_spec.rb +4 -4
- data/spec/unit/provider/package/yum_spec.rb +30 -16
- data/spec/unit/provider/package/zypper_spec.rb +17 -19
- data/spec/unit/provider/service/bsd_spec.rb +7 -9
- data/spec/unit/provider/service/daemontools_spec.rb +12 -16
- data/spec/unit/provider/service/debian_spec.rb +6 -10
- data/spec/unit/provider/service/freebsd_spec.rb +2 -2
- data/spec/unit/provider/service/launchd_spec.rb +19 -0
- data/spec/unit/provider/service/openbsd_spec.rb +13 -17
- data/spec/unit/provider/service/rcng_spec.rb +2 -4
- data/spec/unit/provider/service/redhat_spec.rb +12 -11
- data/spec/unit/provider/service/runit_spec.rb +7 -14
- data/spec/unit/provider/service/smf_spec.rb +77 -13
- data/spec/unit/provider/service/src_spec.rb +11 -16
- data/spec/unit/provider/service/systemd_spec.rb +39 -1
- data/spec/unit/provider/service/windows_spec.rb +39 -7
- data/spec/unit/provider/user/aix_spec.rb +43 -2
- data/spec/unit/provider/user/hpux_spec.rb +3 -5
- data/spec/unit/provider/user/ldap_spec.rb +29 -32
- data/spec/unit/provider/user/pw_spec.rb +10 -13
- data/spec/unit/provider/user/useradd_spec.rb +2 -2
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/puppet_pal_2pec.rb +6 -6
- data/spec/unit/puppet_pal_catalog_spec.rb +58 -0
- data/spec/unit/resource/catalog_spec.rb +2 -2
- data/spec/unit/resource_spec.rb +31 -0
- data/spec/unit/ssl/host_spec.rb +22 -1
- data/spec/unit/ssl/key_spec.rb +2 -4
- data/spec/unit/task_spec.rb +50 -5
- data/spec/unit/transaction/event_manager_spec.rb +12 -1
- data/spec/unit/transaction/persistence_spec.rb +4 -4
- data/spec/unit/transaction/resource_harness_spec.rb +18 -0
- data/spec/unit/type/group_spec.rb +11 -3
- data/spec/unit/type/resources_spec.rb +18 -0
- data/spec/unit/type/service_spec.rb +27 -1
- data/spec/unit/util/execution_spec.rb +77 -0
- data/spec/unit/util/filetype_spec.rb +13 -5
- data/spec/unit/util/log/destinations_spec.rb +10 -0
- data/spec/unit/util/logging_spec.rb +58 -41
- data/spec/unit/util/monkey_patches_spec.rb +18 -5
- data/spec/unit/util/posix_spec.rb +28 -0
- data/spec/unit/util/selinux_spec.rb +4 -0
- data/spec/unit/util/storage_spec.rb +107 -0
- data/spec/unit/util/suidmanager_spec.rb +1 -3
- data/spec/unit/util/windows/adsi_spec.rb +95 -0
- data/spec/unit/util/windows/service_spec.rb +377 -131
- metadata +24 -11
- data/ext/autotest/Rakefile +0 -8
- data/ext/autotest/config +0 -43
- data/ext/autotest/readme.rst +0 -16
- data/spec/fixtures/unit/provider/package/pkgng/pkg.info +0 -7
- data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +0 -1
- data/spec/watchr.rb +0 -137
|
@@ -2,6 +2,9 @@ require 'puppet/application'
|
|
|
2
2
|
require 'puppet/ssl/oids'
|
|
3
3
|
|
|
4
4
|
class Puppet::Application::Ssl < Puppet::Application
|
|
5
|
+
|
|
6
|
+
run_mode :agent
|
|
7
|
+
|
|
5
8
|
def summary
|
|
6
9
|
_("Manage SSL keys and certificates for puppet SSL clients")
|
|
7
10
|
end
|
|
@@ -13,121 +16,202 @@ puppet-ssl(8) -- #{summary}
|
|
|
13
16
|
|
|
14
17
|
SYNOPSIS
|
|
15
18
|
--------
|
|
16
|
-
Manage SSL keys and certificates for
|
|
19
|
+
Manage SSL keys and certificates for SSL clients needing
|
|
17
20
|
to communicate with a puppet infrastructure.
|
|
18
21
|
|
|
19
22
|
USAGE
|
|
20
23
|
-----
|
|
21
|
-
puppet ssl <action> [--
|
|
24
|
+
puppet ssl <action> [-h|--help] [-v|--verbose] [-d|--debug] [--localca] [--target CERTNAME]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
OPTIONS
|
|
28
|
+
-------
|
|
29
|
+
|
|
30
|
+
* --help:
|
|
31
|
+
Print this help messsge.
|
|
32
|
+
|
|
33
|
+
* --verbose:
|
|
34
|
+
Print extra information.
|
|
35
|
+
|
|
36
|
+
* --debug:
|
|
37
|
+
Enable full debugging.
|
|
38
|
+
|
|
39
|
+
* --localca
|
|
40
|
+
Also clean the local CA certificate and CRL.
|
|
41
|
+
|
|
42
|
+
* --target CERTNAME
|
|
43
|
+
Clean the specified device certificate instead of this host's certificate.
|
|
22
44
|
|
|
23
45
|
ACTIONS
|
|
24
46
|
-------
|
|
25
47
|
|
|
26
48
|
* submit_request:
|
|
27
|
-
Generate a certificate signing request (CSR) and submit it to the CA. If
|
|
28
|
-
public key pair already exist, they will be used to generate
|
|
29
|
-
key pair will be generated. If a CSR has already
|
|
30
|
-
then the operation will fail.
|
|
49
|
+
Generate a certificate signing request (CSR) and submit it to the CA. If
|
|
50
|
+
a private and public key pair already exist, they will be used to generate
|
|
51
|
+
the CSR. Otherwise a new key pair will be generated. If a CSR has already
|
|
52
|
+
been submitted with the given `certname`, then the operation will fail.
|
|
31
53
|
|
|
32
54
|
* download_cert:
|
|
33
|
-
Download a certificate for this host. If the current private key matches
|
|
34
|
-
certificate, then the certificate will be saved and used
|
|
35
|
-
there is already an existing certificate, it
|
|
55
|
+
Download a certificate for this host. If the current private key matches
|
|
56
|
+
the downloaded certificate, then the certificate will be saved and used
|
|
57
|
+
for subsequent requests. If there is already an existing certificate, it
|
|
58
|
+
will be overwritten.
|
|
36
59
|
|
|
37
60
|
* verify:
|
|
38
|
-
Verify the private key and certificate are present and match, verify the
|
|
39
|
-
issued by a trusted CA, and check revocation status.
|
|
61
|
+
Verify the private key and certificate are present and match, verify the
|
|
62
|
+
certificate is issued by a trusted CA, and check revocation status.
|
|
63
|
+
|
|
64
|
+
* clean:
|
|
65
|
+
Remove the private key and certificate related files for this host. If
|
|
66
|
+
`--localca` is specified, then also remove this host's local copy of the
|
|
67
|
+
CA certificate(s) and CRL bundle. if `--target CERTNAME` is specified, then
|
|
68
|
+
remove the files for the specified device on this host instead of this host.
|
|
40
69
|
HELP
|
|
41
70
|
end
|
|
42
71
|
|
|
43
|
-
option('--
|
|
44
|
-
options[:
|
|
72
|
+
option('--target CERTNAME') do |arg|
|
|
73
|
+
options[:target] = arg.to_s
|
|
74
|
+
end
|
|
75
|
+
option('--localca')
|
|
76
|
+
option('--verbose', '-v')
|
|
77
|
+
option('--debug', '-d')
|
|
78
|
+
|
|
79
|
+
def setup_logs
|
|
80
|
+
set_log_level(options)
|
|
81
|
+
Puppet::Util::Log.newdestination(:console)
|
|
45
82
|
end
|
|
46
83
|
|
|
47
84
|
def main
|
|
48
85
|
if command_line.args.empty?
|
|
49
|
-
|
|
50
|
-
exit(1)
|
|
86
|
+
raise Puppet::Error, _("An action must be specified.")
|
|
51
87
|
end
|
|
52
88
|
|
|
53
|
-
|
|
54
|
-
|
|
89
|
+
if options[:target]
|
|
90
|
+
# Override the following, as per lib/puppet/application/device.rb
|
|
91
|
+
Puppet[:certname] = options[:target]
|
|
92
|
+
Puppet[:confdir] = File.join(Puppet[:devicedir], Puppet[:certname])
|
|
93
|
+
Puppet[:vardir] = File.join(Puppet[:devicedir], Puppet[:certname])
|
|
94
|
+
host = Puppet::SSL::Host.new(Puppet[:certname], true)
|
|
95
|
+
Puppet.settings.use(:main, :agent, :device)
|
|
96
|
+
else
|
|
97
|
+
host = Puppet::SSL::Host.new(Puppet[:certname])
|
|
98
|
+
Puppet.settings.use(:main, :agent)
|
|
99
|
+
end
|
|
55
100
|
|
|
56
101
|
action = command_line.args.first
|
|
57
102
|
case action
|
|
58
103
|
when 'submit_request'
|
|
59
104
|
submit_request(host)
|
|
60
|
-
download_cert(host)
|
|
105
|
+
cert = download_cert(host)
|
|
106
|
+
unless cert
|
|
107
|
+
Puppet.info _("The certificate for '%{name}' has not yet been signed") % { name: host.name }
|
|
108
|
+
end
|
|
61
109
|
when 'download_cert'
|
|
62
|
-
download_cert(host)
|
|
110
|
+
cert = download_cert(host)
|
|
111
|
+
unless cert
|
|
112
|
+
raise Puppet::Error, _("The certificate for '%{name}' has not yet been signed") % { name: host.name }
|
|
113
|
+
end
|
|
63
114
|
when 'verify'
|
|
64
115
|
verify(host)
|
|
116
|
+
when 'clean'
|
|
117
|
+
clean(host)
|
|
65
118
|
else
|
|
66
|
-
|
|
67
|
-
exit(1)
|
|
119
|
+
raise Puppet::Error, _("Unknown action '%{action}'") % { action: action }
|
|
68
120
|
end
|
|
69
|
-
|
|
70
|
-
exit(0)
|
|
71
121
|
end
|
|
72
122
|
|
|
73
123
|
def submit_request(host)
|
|
74
124
|
host.ensure_ca_certificate
|
|
75
125
|
|
|
76
126
|
host.submit_request
|
|
77
|
-
|
|
127
|
+
Puppet.notice _("Submitted certificate request for '%{name}' to https://%{server}:%{port}") % {
|
|
128
|
+
name: host.name, server: Puppet[:ca_server], port: Puppet[:ca_port]
|
|
129
|
+
}
|
|
78
130
|
rescue => e
|
|
79
|
-
|
|
80
|
-
exit(1)
|
|
131
|
+
raise Puppet::Error.new(_("Failed to submit certificate request: %{message}") % { message: e.message }, e)
|
|
81
132
|
end
|
|
82
133
|
|
|
83
134
|
def download_cert(host)
|
|
84
135
|
host.ensure_ca_certificate
|
|
85
136
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
137
|
+
Puppet.info _("Downloading certificate '%{name}' from https://%{server}:%{port}") % {
|
|
138
|
+
name: host.name, server: Puppet[:ca_server], port: Puppet[:ca_port]
|
|
139
|
+
}
|
|
140
|
+
cert = host.download_host_certificate
|
|
141
|
+
return unless cert
|
|
142
|
+
|
|
143
|
+
Puppet.notice _("Downloaded certificate '%{name}' with fingerprint %{fingerprint}") % {
|
|
144
|
+
name: host.name, fingerprint: cert.fingerprint
|
|
145
|
+
}
|
|
146
|
+
cert
|
|
92
147
|
rescue => e
|
|
93
|
-
|
|
94
|
-
exit(1)
|
|
148
|
+
raise Puppet::Error.new(_("Failed to download certificate: %{message}") % { message: e.message }, e)
|
|
95
149
|
end
|
|
96
150
|
|
|
97
151
|
def verify(host)
|
|
98
152
|
host.ensure_ca_certificate
|
|
99
153
|
|
|
100
154
|
key = host.key
|
|
101
|
-
unless key
|
|
102
|
-
puts "The host's private key is missing"
|
|
103
|
-
exit(1)
|
|
104
|
-
end
|
|
155
|
+
raise _("The host's private key is missing") unless key
|
|
105
156
|
|
|
106
157
|
cert = host.check_for_certificate_on_disk(host.name)
|
|
107
|
-
unless cert
|
|
108
|
-
puts "The host's certificate is missing"
|
|
109
|
-
exit(1)
|
|
110
|
-
end
|
|
158
|
+
raise _("The host's certificate is missing") unless cert
|
|
111
159
|
|
|
112
160
|
if cert.content.public_key.to_pem != key.content.public_key.to_pem
|
|
113
|
-
|
|
114
|
-
exit(1)
|
|
161
|
+
raise _("The host's key does not match the certificate")
|
|
115
162
|
end
|
|
116
163
|
|
|
117
164
|
store = host.ssl_store
|
|
118
165
|
unless store.verify(cert.content)
|
|
119
|
-
|
|
120
|
-
|
|
166
|
+
raise _("Failed to verify certificate '%{name}': %{message} (%{error})") % {
|
|
167
|
+
name: host.name, message: store.error_string, error: store.error
|
|
168
|
+
}
|
|
121
169
|
end
|
|
122
170
|
|
|
123
|
-
|
|
171
|
+
Puppet.notice _("Verified certificate '%{name}'") % {
|
|
172
|
+
name: host.name
|
|
173
|
+
}
|
|
124
174
|
# store.chain.reverse.each_with_index do |issuer, i|
|
|
125
175
|
# indent = " " * (i+1)
|
|
126
|
-
#
|
|
176
|
+
# Puppet.notice "#{indent}#{issuer.subject.to_s}"
|
|
127
177
|
# end
|
|
128
|
-
exit(0)
|
|
129
178
|
rescue => e
|
|
130
|
-
|
|
131
|
-
|
|
179
|
+
raise Puppet::Error.new(_("Verify failed: %{message}") % { message: e.message }, e)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def clean(host)
|
|
183
|
+
# make sure cert has been removed from the CA
|
|
184
|
+
if host.name == Puppet[:ca_server]
|
|
185
|
+
cert =
|
|
186
|
+
begin
|
|
187
|
+
host.download_certificate_from_ca(host.name)
|
|
188
|
+
rescue => e
|
|
189
|
+
raise Puppet::Error.new(_("Failed to connect to the CA to determine if certificate %{certname} has been cleaned") % { certname: host.name }, e)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
if cert
|
|
193
|
+
raise Puppet::Error, _(<<END) % { certname: host.name }
|
|
194
|
+
The certificate %{certname} must be cleaned from the CA first. To fix this,
|
|
195
|
+
run the following commands on the CA:
|
|
196
|
+
puppetserver ca clean --certname %{certname}
|
|
197
|
+
puppet ssl clean
|
|
198
|
+
END
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
paths = {
|
|
203
|
+
'private key' => Puppet[:hostprivkey],
|
|
204
|
+
'public key' => Puppet[:hostpubkey],
|
|
205
|
+
'certificate request' => File.join(Puppet[:requestdir], "#{Puppet[:certname]}.pem"),
|
|
206
|
+
'certificate' => Puppet[:hostcert],
|
|
207
|
+
'private key password file' => Puppet[:passfile]
|
|
208
|
+
}
|
|
209
|
+
paths.merge!('local CA certificate' => Puppet[:localcacert], 'local CRL' => Puppet[:hostcrl]) if options[:localca]
|
|
210
|
+
paths.each_pair do |label, path|
|
|
211
|
+
if Puppet::FileSystem.exist?(path)
|
|
212
|
+
Puppet::FileSystem.unlink(path)
|
|
213
|
+
Puppet.notice _("Removed %{label} %{path}") % { label: label, path: path }
|
|
214
|
+
end
|
|
215
|
+
end
|
|
132
216
|
end
|
|
133
217
|
end
|
data/lib/puppet/application.rb
CHANGED
|
@@ -395,6 +395,8 @@ class Application
|
|
|
395
395
|
end
|
|
396
396
|
|
|
397
397
|
def setup_logs
|
|
398
|
+
handle_logdest_arg(Puppet[:logdest])
|
|
399
|
+
|
|
398
400
|
unless options[:setdest]
|
|
399
401
|
if options[:debug] || options[:verbose]
|
|
400
402
|
Puppet::Util::Log.newdestination(:console)
|
|
@@ -416,7 +418,10 @@ class Application
|
|
|
416
418
|
end
|
|
417
419
|
|
|
418
420
|
def handle_logdest_arg(arg)
|
|
421
|
+
return if options[:setdest] || arg.nil?
|
|
422
|
+
|
|
419
423
|
begin
|
|
424
|
+
Puppet[:logdest] = arg
|
|
420
425
|
Puppet::Util::Log.newdestination(arg)
|
|
421
426
|
options[:setdest] = true
|
|
422
427
|
rescue => detail
|
data/lib/puppet/configurer.rb
CHANGED
|
@@ -16,7 +16,7 @@ class Puppet::Configurer
|
|
|
16
16
|
# For benchmarking
|
|
17
17
|
include Puppet::Util
|
|
18
18
|
|
|
19
|
-
attr_reader :
|
|
19
|
+
attr_reader :environment
|
|
20
20
|
|
|
21
21
|
# Provide more helpful strings to the logging that the Agent does
|
|
22
22
|
def self.to_s
|
|
@@ -42,7 +42,6 @@ class Puppet::Configurer
|
|
|
42
42
|
# Initialize and load storage
|
|
43
43
|
def init_storage
|
|
44
44
|
Puppet::Util::Storage.load
|
|
45
|
-
@compile_time ||= Puppet::Util::Storage.cache(:configuration)[:compile_time]
|
|
46
45
|
rescue => detail
|
|
47
46
|
Puppet.log_exception(detail, _("Removing corrupt state file %{file}: %{detail}") % { file: Puppet[:statefile], detail: detail })
|
|
48
47
|
begin
|
|
@@ -397,7 +396,7 @@ class Puppet::Configurer
|
|
|
397
396
|
port = server[1] || Puppet[:masterport]
|
|
398
397
|
begin
|
|
399
398
|
http = Puppet::Network::HttpPool.http_ssl_instance(host, port)
|
|
400
|
-
response = http.get('/status/v1/simple')
|
|
399
|
+
response = http.get('/status/v1/simple/master')
|
|
401
400
|
return [host, port] if response.is_a?(Net::HTTPOK)
|
|
402
401
|
|
|
403
402
|
Puppet.debug(_("Puppet server %{host}:%{port} is unavailable: %{code} %{reason}") %
|
data/lib/puppet/defaults.rb
CHANGED
|
@@ -734,9 +734,8 @@ module Puppet
|
|
|
734
734
|
:desc => <<EOT,
|
|
735
735
|
A comma-separated list of alternate DNS names for Puppet Server. These are extra
|
|
736
736
|
hostnames (in addition to its `certname`) that the server is allowed to use when
|
|
737
|
-
serving agents. Puppet checks this setting when automatically
|
|
738
|
-
certificate for Puppet agent or Puppet Server, and
|
|
739
|
-
certificate with `puppet cert generate`. These can be either IP or DNS, and the type
|
|
737
|
+
serving agents. Puppet checks this setting when automatically creating a
|
|
738
|
+
certificate for Puppet agent or Puppet Server. These can be either IP or DNS, and the type
|
|
740
739
|
should be specified and followed with a colon. Untyped inputs will default to DNS.
|
|
741
740
|
|
|
742
741
|
In order to handle agent requests at a given hostname (like
|
|
@@ -749,23 +748,12 @@ names.
|
|
|
749
748
|
|
|
750
749
|
**Note:** The list of alternate names is locked in when the server's
|
|
751
750
|
certificate is signed. If you need to change the list later, you can't just
|
|
752
|
-
change this setting; you also need to
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
* On the CA server: Revoke and clean the server's old certificate. (`puppet cert clean <NAME>`)
|
|
756
|
-
(Note `puppet cert clean` is deprecated and will be replaced with `puppetserver ca clean`
|
|
757
|
-
in Puppet 6.)
|
|
758
|
-
* On the server: Delete the old certificate (and any old certificate signing requests)
|
|
759
|
-
from the [ssldir](https://puppet.com/docs/puppet/latest/dirs_ssldir.html).
|
|
760
|
-
* On the server: Run `puppet agent -t --ca_server <CA HOSTNAME>` to request a new certificate
|
|
761
|
-
* On the CA server: Sign the certificate request, explicitly allowing alternate names
|
|
762
|
-
(`puppet cert sign --allow-dns-alt-names <NAME>`). (Note `puppet cert sign` is deprecated
|
|
763
|
-
and will be replaced with `puppetserver ca sign` in Puppet 6.)
|
|
764
|
-
* On the server: Run `puppet agent -t --ca_server <CA HOSTNAME>` to retrieve the cert.
|
|
765
|
-
* On the server: Start Puppet Server again.
|
|
751
|
+
change this setting; you also need to regenerate the certificate. For more
|
|
752
|
+
information on that process, see the [cert regen docs]
|
|
753
|
+
(https://puppet.com/docs/puppet/latest/ssl_regenerate_certificates.html).
|
|
766
754
|
|
|
767
755
|
To see all the alternate names your servers are using, log into your CA server
|
|
768
|
-
and run `
|
|
756
|
+
and run `puppetserver ca list --all`, then check the output for `(alt names: ...)`.
|
|
769
757
|
Most agent nodes should NOT have alternate names; the only certs that should
|
|
770
758
|
have them are Puppet Server nodes that you want other agents to trust.
|
|
771
759
|
EOT
|
|
@@ -777,7 +765,7 @@ EOT
|
|
|
777
765
|
An optional file containing custom attributes to add to certificate signing
|
|
778
766
|
requests (CSRs). You should ensure that this file does not exist on your CA
|
|
779
767
|
puppet master; if it does, unwanted certificate extensions may leak into
|
|
780
|
-
certificates created with the `
|
|
768
|
+
certificates created with the `puppetserver ca generate` command.
|
|
781
769
|
|
|
782
770
|
If present, this file must be a YAML hash containing a `custom_attributes` key
|
|
783
771
|
and/or an `extension_requests` key. The value of each key must be a hash, where
|
|
@@ -863,7 +851,8 @@ EOT
|
|
|
863
851
|
:mode => "0644",
|
|
864
852
|
:owner => "service",
|
|
865
853
|
:group => "service",
|
|
866
|
-
:
|
|
854
|
+
:deprecated => :completely,
|
|
855
|
+
:desc => "This setting is deprecated."
|
|
867
856
|
},
|
|
868
857
|
:hostcert => {
|
|
869
858
|
:default => "$certdir/$certname.pem",
|
|
@@ -975,6 +964,15 @@ EOT
|
|
|
975
964
|
}
|
|
976
965
|
end
|
|
977
966
|
end
|
|
967
|
+
},
|
|
968
|
+
:logdest => {
|
|
969
|
+
:type => :string,
|
|
970
|
+
:desc => "Where to send log messages. Choose between 'syslog' (the POSIX syslog
|
|
971
|
+
service), 'eventlog' (the Windows Event Log), 'console', or the path to a log
|
|
972
|
+
file."
|
|
973
|
+
# Sure would be nice to set the Puppet::Util::Log destination here in an :on_initialize_and_write hook,
|
|
974
|
+
# unfortunately we have a large number of tests that rely on the logging not resetting itself when the
|
|
975
|
+
# settings are initialized as they test what gets logged during settings initialization.
|
|
978
976
|
}
|
|
979
977
|
)
|
|
980
978
|
|
|
@@ -987,65 +985,41 @@ EOT
|
|
|
987
985
|
:cadir => {
|
|
988
986
|
:default => "$ssldir/ca",
|
|
989
987
|
:type => :directory,
|
|
990
|
-
:owner => "service",
|
|
991
|
-
:group => "service",
|
|
992
|
-
:mode => "0755",
|
|
993
988
|
:desc => "The root directory for the certificate authority.",
|
|
994
989
|
},
|
|
995
990
|
:cacert => {
|
|
996
991
|
:default => "$cadir/ca_crt.pem",
|
|
997
992
|
:type => :file,
|
|
998
|
-
:owner => "service",
|
|
999
|
-
:group => "service",
|
|
1000
|
-
:mode => "0644",
|
|
1001
993
|
:desc => "The CA certificate.",
|
|
1002
994
|
},
|
|
1003
995
|
:cakey => {
|
|
1004
996
|
:default => "$cadir/ca_key.pem",
|
|
1005
997
|
:type => :file,
|
|
1006
|
-
:owner => "service",
|
|
1007
|
-
:group => "service",
|
|
1008
|
-
:mode => "0640",
|
|
1009
998
|
:desc => "The CA private key.",
|
|
1010
999
|
},
|
|
1011
1000
|
:capub => {
|
|
1012
1001
|
:default => "$cadir/ca_pub.pem",
|
|
1013
1002
|
:type => :file,
|
|
1014
|
-
:owner => "service",
|
|
1015
|
-
:group => "service",
|
|
1016
|
-
:mode => "0644",
|
|
1017
1003
|
:desc => "The CA public key.",
|
|
1018
1004
|
},
|
|
1019
1005
|
:cacrl => {
|
|
1020
1006
|
:default => "$cadir/ca_crl.pem",
|
|
1021
1007
|
:type => :file,
|
|
1022
|
-
:owner => "service",
|
|
1023
|
-
:group => "service",
|
|
1024
|
-
:mode => "0644",
|
|
1025
1008
|
:desc => "The certificate revocation list (CRL) for the CA.",
|
|
1026
1009
|
},
|
|
1027
1010
|
:csrdir => {
|
|
1028
1011
|
:default => "$cadir/requests",
|
|
1029
1012
|
:type => :directory,
|
|
1030
|
-
:owner => "service",
|
|
1031
|
-
:group => "service",
|
|
1032
|
-
:mode => "0755",
|
|
1033
1013
|
:desc => "Where the CA stores certificate requests.",
|
|
1034
1014
|
},
|
|
1035
1015
|
:signeddir => {
|
|
1036
1016
|
:default => "$cadir/signed",
|
|
1037
1017
|
:type => :directory,
|
|
1038
|
-
:owner => "service",
|
|
1039
|
-
:group => "service",
|
|
1040
|
-
:mode => "0755",
|
|
1041
1018
|
:desc => "Where the CA stores signed certificates.",
|
|
1042
1019
|
},
|
|
1043
1020
|
:serial => {
|
|
1044
1021
|
:default => "$cadir/serial",
|
|
1045
1022
|
:type => :file,
|
|
1046
|
-
:owner => "service",
|
|
1047
|
-
:group => "service",
|
|
1048
|
-
:mode => "0644",
|
|
1049
1023
|
:desc => "Where the serial number for certificates is stored.",
|
|
1050
1024
|
},
|
|
1051
1025
|
:autosign => {
|
|
@@ -1070,7 +1044,7 @@ EOT
|
|
|
1070
1044
|
and non-zero if the cert should not be autosigned.
|
|
1071
1045
|
|
|
1072
1046
|
If a certificate request is not autosigned, it will persist for review. An admin
|
|
1073
|
-
user can use the `
|
|
1047
|
+
user can use the `puppetserver ca sign` command to manually sign it, or can delete
|
|
1074
1048
|
the request.
|
|
1075
1049
|
|
|
1076
1050
|
For info on autosign configuration files, see
|
|
@@ -1094,9 +1068,6 @@ EOT
|
|
|
1094
1068
|
:cert_inventory => {
|
|
1095
1069
|
:default => "$cadir/inventory.txt",
|
|
1096
1070
|
:type => :file,
|
|
1097
|
-
:mode => "0644",
|
|
1098
|
-
:owner => "service",
|
|
1099
|
-
:group => "service",
|
|
1100
1071
|
:desc => "The inventory file. This is a text file to which the CA writes a
|
|
1101
1072
|
complete listing of all certificates.",
|
|
1102
1073
|
}
|
|
@@ -1410,7 +1381,20 @@ EOT
|
|
|
1410
1381
|
with the running configuration. In the case of puppet master,
|
|
1411
1382
|
this file reflects the state discovered through interacting
|
|
1412
1383
|
with clients."
|
|
1413
|
-
|
|
1384
|
+
},
|
|
1385
|
+
:statettl => {
|
|
1386
|
+
:default => "32d",
|
|
1387
|
+
:type => :ttl,
|
|
1388
|
+
:desc => "How long the Puppet agent should cache when a resource was last checked or synced.
|
|
1389
|
+
#{AS_DURATION}
|
|
1390
|
+
A value of `0` or `unlimited` will disable cache pruning.
|
|
1391
|
+
|
|
1392
|
+
This setting affects the usage of `schedule` resources, as the information
|
|
1393
|
+
about when a resource was last checked (and therefore when it needs to be
|
|
1394
|
+
checked again) is stored in the `statefile`. The `statettl` needs to be
|
|
1395
|
+
large enough to ensure that a resource will not trigger multiple times
|
|
1396
|
+
during a schedule due to its entry expiring from the cache."
|
|
1397
|
+
},
|
|
1414
1398
|
:transactionstorefile => {
|
|
1415
1399
|
:default => "$statedir/transactionstore.yaml",
|
|
1416
1400
|
:type => :file,
|
data/lib/puppet/etc.rb
CHANGED
|
@@ -103,6 +103,26 @@ module Puppet::Etc
|
|
|
103
103
|
override_field_values_to_utf8(::Etc.getpwuid(id))
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
+
# Etc::group returns a Ruby iterator that executes a block for
|
|
107
|
+
# each entry in the /etc/group file. The code-block is passed
|
|
108
|
+
# a Group struct. See getgrent above for more details.
|
|
109
|
+
def group
|
|
110
|
+
# The implementation here duplicates the logic in https://github.com/ruby/etc/blob/master/ext/etc/etc.c#L523-L537
|
|
111
|
+
# Note that we do not call ::Etc.group directly, because we
|
|
112
|
+
# want to use our wrappers for methods like getgrent, setgrent,
|
|
113
|
+
# endgrent, etc.
|
|
114
|
+
return getgrent unless block_given?
|
|
115
|
+
|
|
116
|
+
setgrent
|
|
117
|
+
begin
|
|
118
|
+
while cur_group = getgrent
|
|
119
|
+
yield cur_group
|
|
120
|
+
end
|
|
121
|
+
ensure
|
|
122
|
+
endgrent
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
106
126
|
private
|
|
107
127
|
|
|
108
128
|
# @api private
|
data/lib/puppet/face/config.rb
CHANGED
|
@@ -23,7 +23,7 @@ Puppet::Face.define(:config, '0.0.1') do
|
|
|
23
23
|
The three most commonly used sections are 'main', 'master', and 'agent'.
|
|
24
24
|
'Main' is the default, and is used by all Puppet applications. Other
|
|
25
25
|
sections can override 'main' values for specific applications --- the
|
|
26
|
-
'master' section affects
|
|
26
|
+
'master' section affects Puppet Server, and the 'agent'
|
|
27
27
|
section affects puppet agent.
|
|
28
28
|
|
|
29
29
|
Less commonly used is the 'user' section, which affects puppet apply. Any
|
|
@@ -35,7 +35,7 @@ Puppet::Face.define(:config, '0.0.1') do
|
|
|
35
35
|
|
|
36
36
|
action(:print) do
|
|
37
37
|
summary _("Examine Puppet's current settings.")
|
|
38
|
-
arguments _("
|
|
38
|
+
arguments _("all | <setting> [<setting> ...]")
|
|
39
39
|
description <<-'EOT'
|
|
40
40
|
Prints the value of a single setting or a list of settings.
|
|
41
41
|
|
|
@@ -210,7 +210,7 @@ https://puppet.com/docs/puppet/latest/configuration.html#environment
|
|
|
210
210
|
|
|
211
211
|
action(:delete) do
|
|
212
212
|
summary _("Delete a Puppet setting.")
|
|
213
|
-
arguments _("
|
|
213
|
+
arguments _("<setting>")
|
|
214
214
|
#TRANSLATORS 'main' is a specific section name and should not be translated
|
|
215
215
|
description "Deletes a setting from the specified section. (The default is the section 'main')."
|
|
216
216
|
notes <<-'EOT'
|
data/lib/puppet/face/key.rb
CHANGED
|
@@ -8,7 +8,7 @@ Puppet::Indirector::Face.define(:key, '0.0.1') do
|
|
|
8
8
|
description <<-'EOT'
|
|
9
9
|
This subcommand manages certificate private keys. Keys are created
|
|
10
10
|
automatically by puppet agent and when certificate requests are generated
|
|
11
|
-
with 'puppet
|
|
11
|
+
with 'puppet ssl submit_request'; it should not be necessary to use this
|
|
12
12
|
subcommand directly.
|
|
13
13
|
EOT
|
|
14
14
|
|
|
@@ -59,7 +59,6 @@ Puppet::Face.define(:node, '0.0.1') do
|
|
|
59
59
|
# clean signed cert for +host+
|
|
60
60
|
def clean_cert(node)
|
|
61
61
|
if Puppet.features.puppetserver_ca?
|
|
62
|
-
require 'puppetserver/ca/action/clean'
|
|
63
62
|
Puppetserver::Ca::Action::Clean.new(LoggerIO.new).run({ 'certnames' => [node] })
|
|
64
63
|
else
|
|
65
64
|
Puppet.info _("Not managing %{node} certs as this host is not a CA") % { node: node }
|
data/lib/puppet/feature/base.rb
CHANGED
data/lib/puppet/functions/abs.rb
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
# Integer($strval, 10, true) # Converts to absolute Integer using base 10 (decimal)
|
|
29
29
|
# Integer($strval, 16, true) # Converts to absolute Integer using base 16 (hex)
|
|
30
30
|
# Float($strval, true) # Converts to absolute Float
|
|
31
|
-
# ```
|
|
31
|
+
# ```
|
|
32
32
|
#
|
|
33
33
|
Puppet::Functions.create_function(:abs) do
|
|
34
34
|
dispatch :on_numeric do
|
data/lib/puppet/functions/new.rb
CHANGED
|
@@ -608,7 +608,7 @@
|
|
|
608
608
|
# | Format | String
|
|
609
609
|
# | ------ | ------
|
|
610
610
|
# | s | Unquoted string, verbatim output of control chars.
|
|
611
|
-
# | p | Programmatic representation - strings are quoted, interior quotes and control chars are escaped.
|
|
611
|
+
# | p | Programmatic representation - strings are quoted, interior quotes and control chars are escaped. Selects single or double quotes based on content, or uses double quotes if alternative flag `#` is used.
|
|
612
612
|
# | C | Each `::` name segment capitalized, quoted if alternative flag `#` is used.
|
|
613
613
|
# | c | Capitalized string, quoted if alternative flag `#` is used.
|
|
614
614
|
# | d | Downcased string, quoted if alternative flag `#` is used.
|