puppetserver-ca 2.0.0 → 2.0.1
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/README.md +2 -2
- data/lib/puppetserver/ca/action/enable.rb +1 -1
- data/lib/puppetserver/ca/action/generate.rb +1 -1
- data/lib/puppetserver/ca/action/import.rb +1 -1
- data/lib/puppetserver/ca/action/migrate.rb +6 -5
- data/lib/puppetserver/ca/action/setup.rb +1 -1
- data/lib/puppetserver/ca/config/puppet.rb +13 -9
- data/lib/puppetserver/ca/utils/file_system.rb +8 -0
- data/lib/puppetserver/ca/utils/http_client.rb +1 -1
- data/lib/puppetserver/ca/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33d0c2bbf4e4efae9ed5ee88619f47bfbd850b24b0e7fff02bf7e6a106d40d18
|
4
|
+
data.tar.gz: 70542df4956703b70b73ab3aa8e5cb4ef8c007925fb47dc1e2197d762e1a3269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 399ef8c2fecd89f42db48d848685f61ac9efaffa1039a8e726b4c1b60dda3d82c996c4fff2cec8d315a35bcf5643a46233ae0647a5f79e2f730055e41b404e6f
|
7
|
+
data.tar.gz: 342d56b051591b0fbf2211e3f75dd7249ff934f087f1ad2b0005cbdc4dbb0d5d6228e22b248ab22d9a4bb90dd21026daa0ac7fc363937652b5887fe971b29079
|
data/README.md
CHANGED
@@ -79,8 +79,8 @@ To test your changes on a VM:
|
|
79
79
|
1. Copy the gem to your VM: `scp puppetserver-ca-<version>.gem <your-vm>:.`
|
80
80
|
1. Install puppetserver (FOSS) by installing the relevant release package and then installing the puppetserver package. For example:
|
81
81
|
```
|
82
|
-
$ wget http://nightlies.puppet.com/yum/
|
83
|
-
$ rpm -i
|
82
|
+
$ wget http://nightlies.puppet.com/yum/puppet-nightly-release-el-7.noarch.rpm
|
83
|
+
$ rpm -i puppet-nightly-release-el-7.noarch.rpm
|
84
84
|
$ yum update
|
85
85
|
$ yum install -y puppetserver
|
86
86
|
```
|
@@ -126,7 +126,7 @@ BANNER
|
|
126
126
|
# Load, resolve, and validate puppet config settings
|
127
127
|
settings_overrides = {}
|
128
128
|
puppet = Config::Puppet.new(config_path)
|
129
|
-
puppet.load(settings_overrides, @logger)
|
129
|
+
puppet.load(cli_overrides: settings_overrides, logger: @logger)
|
130
130
|
return 1 if Errors.handle_with_usage(@logger, puppet.errors)
|
131
131
|
|
132
132
|
# We don't want generate to respect the alt names setting, since it is usually
|
@@ -56,7 +56,7 @@ BANNER
|
|
56
56
|
settings_overrides[:dns_alt_names] = input['subject-alt-names'] unless input['subject-alt-names'].empty?
|
57
57
|
|
58
58
|
puppet = Config::Puppet.new(config_path)
|
59
|
-
puppet.load(settings_overrides, @logger)
|
59
|
+
puppet.load(cli_overrides: settings_overrides, logger: @logger)
|
60
60
|
return 1 if Errors.handle_with_usage(@logger, puppet.errors)
|
61
61
|
|
62
62
|
# Load most secure signing digest we can for cers/crl/csr signing.
|
@@ -1,22 +1,23 @@
|
|
1
1
|
require 'puppetserver/ca/utils/cli_parsing'
|
2
2
|
require 'puppetserver/ca/utils/file_system'
|
3
3
|
require 'puppetserver/ca/utils/http_client'
|
4
|
+
require 'puppetserver/ca/utils/config'
|
4
5
|
|
5
6
|
module Puppetserver
|
6
7
|
module Ca
|
7
8
|
module Action
|
8
9
|
class Migrate
|
9
10
|
include Puppetserver::Ca::Utils
|
10
|
-
PUPPETSERVER_CA_DIR =
|
11
|
+
PUPPETSERVER_CA_DIR = Puppetserver::Ca::Utils::Config.new_default_cadir
|
11
12
|
|
12
|
-
SUMMARY = "Migrate the existing CA directory to
|
13
|
+
SUMMARY = "Migrate the existing CA directory to #{PUPPETSERVER_CA_DIR}"
|
13
14
|
BANNER = <<-BANNER
|
14
15
|
Usage:
|
15
16
|
puppetserver ca migrate [--help]
|
16
17
|
puppetserver ca migrate [--config PATH]
|
17
18
|
|
18
19
|
Description:
|
19
|
-
Migrate an existing CA directory to
|
20
|
+
Migrate an existing CA directory to #{PUPPETSERVER_CA_DIR}. This is for
|
20
21
|
upgrading from Puppet Platform 6.x to Puppet 7. Use the currently configured
|
21
22
|
puppet.conf file in your installation, or supply one using the `--config` flag.
|
22
23
|
Options:
|
@@ -29,7 +30,7 @@ BANNER
|
|
29
30
|
def run(input)
|
30
31
|
config_path = input['config']
|
31
32
|
puppet = Config::Puppet.new(config_path)
|
32
|
-
puppet.load(
|
33
|
+
puppet.load(logger: @logger, ca_dir_warn: false)
|
33
34
|
return 1 if HttpClient.check_server_online(puppet.settings, @logger)
|
34
35
|
|
35
36
|
errors = FileSystem.check_for_existing_files(PUPPETSERVER_CA_DIR)
|
@@ -65,7 +66,7 @@ SUCCESS_MESSAGE
|
|
65
66
|
|
66
67
|
def migrate(old_cadir, new_cadir=PUPPETSERVER_CA_DIR)
|
67
68
|
FileUtils.mv(old_cadir, new_cadir)
|
68
|
-
|
69
|
+
FileSystem.forcibly_symlink(new_cadir, old_cadir)
|
69
70
|
end
|
70
71
|
|
71
72
|
def parse(args)
|
@@ -56,7 +56,7 @@ BANNER
|
|
56
56
|
settings_overrides[:dns_alt_names] = input['subject-alt-names'] unless input['subject-alt-names'].empty?
|
57
57
|
|
58
58
|
puppet = Config::Puppet.new(config_path)
|
59
|
-
puppet.load(settings_overrides, @logger)
|
59
|
+
puppet.load(cli_overrides: settings_overrides, logger: @logger)
|
60
60
|
return 1 if Errors.handle_with_usage(@logger, puppet.errors)
|
61
61
|
|
62
62
|
# Load most secure signing digest we can for cers/crl/csr signing.
|
@@ -25,7 +25,7 @@ module Puppetserver
|
|
25
25
|
|
26
26
|
def self.parse(config_path, logger)
|
27
27
|
instance = new(config_path)
|
28
|
-
instance.load(
|
28
|
+
instance.load(logger: logger)
|
29
29
|
|
30
30
|
return instance
|
31
31
|
end
|
@@ -54,20 +54,23 @@ module Puppetserver
|
|
54
54
|
user_specific_puppet_confdir + '/puppet.conf'
|
55
55
|
end
|
56
56
|
|
57
|
-
def load(cli_overrides
|
57
|
+
def load(cli_overrides: {}, logger:, ca_dir_warn: true)
|
58
58
|
if explicitly_given_config_file_or_default_config_exists?
|
59
59
|
results = parse_text(File.read(@config_path))
|
60
60
|
end
|
61
61
|
|
62
62
|
results ||= {}
|
63
63
|
results[:main] ||= {}
|
64
|
+
# The [master] config section is deprecated
|
65
|
+
# We now favor [server], but support both for backwards compatibility
|
64
66
|
results[:master] ||= {}
|
67
|
+
results[:server] ||= {}
|
65
68
|
results[:agent] ||= {}
|
66
69
|
|
67
|
-
overrides = results[:agent].merge(results[:main]).merge(results[:master])
|
70
|
+
overrides = results[:agent].merge(results[:main]).merge(results[:master]).merge(results[:server])
|
68
71
|
overrides.merge!(cli_overrides)
|
69
72
|
|
70
|
-
@settings = resolve_settings(overrides, logger).freeze
|
73
|
+
@settings = resolve_settings(overrides, logger, ca_dir_warn: ca_dir_warn).freeze
|
71
74
|
end
|
72
75
|
|
73
76
|
def default_certname
|
@@ -84,7 +87,7 @@ module Puppetserver
|
|
84
87
|
|
85
88
|
# Resolve settings from default values, with any overrides for the
|
86
89
|
# specific settings or their dependent settings (ssldir, cadir) taken into account.
|
87
|
-
def resolve_settings(overrides = {}, logger)
|
90
|
+
def resolve_settings(overrides = {}, logger, ca_dir_warn: true)
|
88
91
|
unresolved_setting = /\$[a-z_]+/
|
89
92
|
|
90
93
|
# Returning the key for unknown keys (rather than nil) is required to
|
@@ -145,7 +148,8 @@ module Puppetserver
|
|
145
148
|
cadir = find_cadir(overrides.fetch(:cadir, false),
|
146
149
|
settings[:confdir],
|
147
150
|
settings[:ssldir],
|
148
|
-
logger
|
151
|
+
logger,
|
152
|
+
ca_dir_warn)
|
149
153
|
settings[:cadir] = substitutions['$cadir'] = cadir
|
150
154
|
|
151
155
|
|
@@ -212,7 +216,7 @@ module Puppetserver
|
|
212
216
|
private
|
213
217
|
|
214
218
|
|
215
|
-
def find_cadir(configured_cadir, confdir, ssldir, logger)
|
219
|
+
def find_cadir(configured_cadir, confdir, ssldir, logger, ca_dir_warn)
|
216
220
|
warning = 'The cadir is currently configured to be inside the ' +
|
217
221
|
'%{ssldir} directory. This config setting and the directory ' +
|
218
222
|
'location will not be used in a future version of puppet. ' +
|
@@ -221,7 +225,7 @@ module Puppetserver
|
|
221
225
|
'Use `puppetserver ca migrate --help` for more info.'
|
222
226
|
|
223
227
|
if configured_cadir
|
224
|
-
if configured_cadir.start_with?(ssldir)
|
228
|
+
if ca_dir_warn && configured_cadir.start_with?(ssldir)
|
225
229
|
logger.warn(warning % {ssldir: ssldir})
|
226
230
|
end
|
227
231
|
configured_cadir
|
@@ -230,7 +234,7 @@ module Puppetserver
|
|
230
234
|
old_cadir = Puppetserver::Ca::Utils::Config.old_default_cadir(confdir)
|
231
235
|
new_cadir = Puppetserver::Ca::Utils::Config.new_default_cadir(confdir)
|
232
236
|
if File.exist?(old_cadir) && !File.symlink?(old_cadir)
|
233
|
-
logger.warn(warning % {ssldir: ssldir})
|
237
|
+
logger.warn(warning % {ssldir: ssldir}) if ca_dir_warn
|
234
238
|
old_cadir
|
235
239
|
else
|
236
240
|
new_cadir
|
@@ -53,6 +53,14 @@ module Puppetserver
|
|
53
53
|
def self.forcibly_symlink(source, link_target)
|
54
54
|
FileUtils.remove_dir(link_target, true)
|
55
55
|
FileUtils.symlink(source, link_target)
|
56
|
+
# Ensure the symlink has the same ownership as the source.
|
57
|
+
# This requires using `FileUtils.chown` rather than `File.chown`, as
|
58
|
+
# the latter will update the ownership of the source rather than the
|
59
|
+
# link itself.
|
60
|
+
# Symlink permissions are ignored in favor of the source's permissions,
|
61
|
+
# so we don't have to change those.
|
62
|
+
source_info = File.stat(source)
|
63
|
+
FileUtils.chown(source_info.uid, source_info.gid, link_target)
|
56
64
|
end
|
57
65
|
|
58
66
|
def initialize
|
@@ -174,7 +174,7 @@ module Puppetserver
|
|
174
174
|
self.new(settings, with_client_cert: false).with_connection(status_url) do |conn|
|
175
175
|
result = conn.get
|
176
176
|
if result.body == "running"
|
177
|
-
logger.err "
|
177
|
+
logger.err "Puppetserver service is running. Please stop it before attempting to run this command."
|
178
178
|
true
|
179
179
|
else
|
180
180
|
false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppetserver-ca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: facter
|