cheffish 14.0.1 → 14.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +20 -1
- data/Rakefile +27 -32
- data/cheffish.gemspec +4 -4
- data/lib/chef/resource/chef_acl.rb +4 -4
- data/lib/chef/resource/chef_data_bag_item.rb +4 -4
- data/lib/chef/resource/chef_mirror.rb +10 -10
- data/lib/chef/resource/chef_organization.rb +2 -2
- data/lib/chef/resource/chef_resolved_cookbooks.rb +7 -7
- data/lib/chef/resource/chef_user.rb +3 -3
- data/lib/chef/resource/private_key.rb +3 -3
- data/lib/chef/resource/public_key.rb +2 -2
- data/lib/cheffish.rb +7 -7
- data/lib/cheffish/base_resource.rb +1 -1
- data/lib/cheffish/basic_chef_client.rb +1 -2
- data/lib/cheffish/chef_actor_base.rb +6 -6
- data/lib/cheffish/chef_run.rb +2 -2
- data/lib/cheffish/key_formatter.rb +1 -1
- data/lib/cheffish/merged_config.rb +1 -1
- data/lib/cheffish/node_properties.rb +1 -1
- data/lib/cheffish/recipe_dsl.rb +2 -2
- data/lib/cheffish/rspec/chef_run_support.rb +3 -3
- data/lib/cheffish/rspec/matchers/have_updated.rb +2 -2
- data/lib/cheffish/version.rb +1 -1
- data/spec/functional/fingerprint_spec.rb +27 -27
- data/spec/functional/merged_config_spec.rb +9 -9
- data/spec/functional/server_api_spec.rb +1 -1
- data/spec/integration/chef_acl_spec.rb +16 -18
- data/spec/integration/chef_client_spec.rb +3 -3
- data/spec/integration/chef_mirror_spec.rb +16 -16
- data/spec/integration/chef_node_spec.rb +4 -4
- data/spec/integration/chef_role_spec.rb +2 -2
- data/spec/integration/chef_user_spec.rb +3 -3
- data/spec/integration/private_key_spec.rb +2 -2
- data/spec/integration/recipe_dsl_spec.rb +2 -2
- data/spec/support/key_support.rb +4 -4
- data/spec/support/spec_support.rb +1 -1
- data/spec/unit/get_private_key_spec.rb +6 -6
- metadata +6 -8
- data/README.md +0 -120
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b546acb84203496cb2e896764aaaf437971b8fc1e45f62d561ab263ee78e2fea
|
4
|
+
data.tar.gz: 96d154e73378a8c2008117c1b50e4eb1077cd43db9bc1748a702dccd08e1ddb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c34534a52657f87d803ea12a629c76c3f6ae9a10e7cc982640ac4162c4db683bf0ebcae3860381f80f34eb08b8cde880faa368ffbe84b6946160ccdc0d62913
|
7
|
+
data.tar.gz: 380ffbe2f90d104b9a60820498452c1d8e496a603b8dcc17ef1218ffc7f34d231fdb3fffdc103410ff08b51e90d08d3e85ae5e3c98385a470e33b18902fc5852
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source "https://rubygems.org"
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
gem "chefstyle", "
|
6
|
+
gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
|
7
7
|
gem "rake"
|
8
8
|
gem "rspec", "~> 3.0"
|
9
9
|
end
|
@@ -18,3 +18,22 @@ else
|
|
18
18
|
gem "ohai", "~> 14"
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
group :docs do
|
23
|
+
gem "yard"
|
24
|
+
gem "redcarpet"
|
25
|
+
gem "github-markup"
|
26
|
+
end
|
27
|
+
|
28
|
+
group :debug do
|
29
|
+
gem "pry"
|
30
|
+
gem "pry-byebug"
|
31
|
+
gem "pry-stack_explorer"
|
32
|
+
gem "rb-readline"
|
33
|
+
end
|
34
|
+
|
35
|
+
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
|
36
|
+
|
37
|
+
# If you want to load debugging tools into the bundle exec sandbox,
|
38
|
+
# add these additional dependencies into Gemfile.local
|
39
|
+
eval_gemfile(__FILE__ + ".local") if File.exist?(__FILE__ + ".local")
|
data/Rakefile
CHANGED
@@ -1,47 +1,42 @@
|
|
1
|
-
require "bundler"
|
2
|
-
require "rubygems"
|
3
|
-
require "rubygems/package_task"
|
4
|
-
require "rdoc/task"
|
5
|
-
require "rspec/core/rake_task"
|
6
|
-
|
7
|
-
Bundler::GemHelper.install_tasks
|
8
|
-
|
9
|
-
task :default => :spec
|
10
|
-
|
11
|
-
desc "Run specs"
|
12
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
13
|
-
spec.pattern = "spec/**/*_spec.rb"
|
14
|
-
end
|
15
|
-
|
16
|
-
gem_spec = eval(File.read("cheffish.gemspec"))
|
17
|
-
|
18
|
-
RDoc::Task.new do |rdoc|
|
19
|
-
rdoc.rdoc_dir = "rdoc"
|
20
|
-
rdoc.title = "cheffish #{gem_spec.version}"
|
21
|
-
rdoc.rdoc_files.include("README*")
|
22
|
-
rdoc.rdoc_files.include("lib/**/*.rb")
|
23
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
24
2
|
|
25
3
|
begin
|
26
|
-
require "
|
4
|
+
require "rspec/core/rake_task"
|
27
5
|
|
28
|
-
|
29
|
-
|
30
|
-
config.future_release = Cheffish::VERSION
|
31
|
-
config.enhancement_labels = "enhancement,Enhancement,Improvement,New Feature,Feature".split(",")
|
32
|
-
config.bug_labels = "bug,Bug,Upstream Bug".split(",")
|
33
|
-
config.exclude_labels = "duplicate,question,invalid,wontfix,no_changelog,Exclude From Changelog,Question,Discussion".split(",")
|
34
|
-
config.issues = false
|
6
|
+
RSpec::Core::RakeTask.new do |t|
|
7
|
+
t.pattern = "spec/**/*_spec.rb"
|
35
8
|
end
|
36
9
|
rescue LoadError
|
10
|
+
desc "rspec is not installed, this task is disabled"
|
11
|
+
task :spec do
|
12
|
+
abort "rspec is not installed. bundle install first to make sure all dependencies are installed."
|
13
|
+
end
|
37
14
|
end
|
38
15
|
|
39
16
|
begin
|
40
17
|
require "chefstyle"
|
41
18
|
require "rubocop/rake_task"
|
19
|
+
desc "Run Chefstyle tests"
|
42
20
|
RuboCop::RakeTask.new(:style) do |task|
|
43
21
|
task.options += ["--display-cop-names", "--no-color"]
|
44
22
|
end
|
45
23
|
rescue LoadError
|
46
|
-
puts "chefstyle
|
24
|
+
puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed."
|
47
25
|
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require "yard"
|
29
|
+
YARD::Rake::YardocTask.new(:docs)
|
30
|
+
rescue LoadError
|
31
|
+
puts "yard is not available. bundle install first to make sure all dependencies are installed."
|
32
|
+
end
|
33
|
+
|
34
|
+
task :console do
|
35
|
+
require "irb"
|
36
|
+
require "irb/completion"
|
37
|
+
require "cheffish"
|
38
|
+
ARGV.clear
|
39
|
+
IRB.start
|
40
|
+
end
|
41
|
+
|
42
|
+
task default: [:style, :spec]
|
data/cheffish.gemspec
CHANGED
@@ -5,12 +5,12 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.name = "cheffish"
|
6
6
|
s.version = Cheffish::VERSION
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
|
-
s.
|
8
|
+
s.license = "Apache-2.0"
|
9
9
|
s.summary = "A library to manipulate Chef in Chef."
|
10
10
|
s.description = s.summary
|
11
11
|
s.author = "John Keiser"
|
12
12
|
s.email = "jkeiser@chef.io"
|
13
|
-
s.homepage = "
|
13
|
+
s.homepage = "https://github.com/chef/cheffish"
|
14
14
|
|
15
15
|
s.required_ruby_version = ">= 2.4.0"
|
16
16
|
|
@@ -21,6 +21,6 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = %w{ }
|
22
22
|
|
23
23
|
s.require_path = "lib"
|
24
|
-
s.files = %w{Gemfile Rakefile LICENSE
|
25
|
-
Dir.glob("{
|
24
|
+
s.files = %w{Gemfile Rakefile LICENSE} + Dir.glob("*.gemspec") +
|
25
|
+
Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
|
26
26
|
end
|
@@ -124,7 +124,7 @@ class Chef
|
|
124
124
|
# If recurse is on_change, then we will recurse if there is no ACL, or if
|
125
125
|
# the ACL has changed.
|
126
126
|
if new_resource.recursive == true || (new_resource.recursive == :on_change && (!acl || changed))
|
127
|
-
children,
|
127
|
+
children, _error = list(path, "*")
|
128
128
|
Chef::ChefFS::Parallelizer.parallel_do(children) do |child|
|
129
129
|
next if child.split("/")[-1] == "containers"
|
130
130
|
create_acl(child)
|
@@ -141,7 +141,7 @@ class Chef
|
|
141
141
|
# Get the current ACL for the given path
|
142
142
|
def current_acl(acl_path)
|
143
143
|
@current_acls ||= {}
|
144
|
-
if !@current_acls.
|
144
|
+
if !@current_acls.key?(acl_path)
|
145
145
|
@current_acls[acl_path] = begin
|
146
146
|
rest.get(rest_url(acl_path))
|
147
147
|
rescue Net::HTTPServerException => e
|
@@ -299,8 +299,8 @@ class Chef
|
|
299
299
|
#
|
300
300
|
# Result: /*/foo = [ '/organizations/foo', '/users/foo' ]
|
301
301
|
#
|
302
|
-
matches = Chef::ChefFS::Parallelizer.parallelize(matches) do |
|
303
|
-
found, error = list(
|
302
|
+
matches = Chef::ChefFS::Parallelizer.parallelize(matches) do |pth|
|
303
|
+
found, error = list(pth, part)
|
304
304
|
if error
|
305
305
|
if parts[0..index - 1].all? { |p| p != "*" }
|
306
306
|
raise error
|
@@ -112,12 +112,12 @@ class Chef
|
|
112
112
|
end
|
113
113
|
|
114
114
|
# Determine if data bag is encrypted and if so, what its version is
|
115
|
-
|
115
|
+
_first_real_key, first_real_value = (current_resource.raw_data || {}).select { |key, value| key != "id" && !value.nil? }.first
|
116
116
|
if first_real_value
|
117
117
|
if first_real_value.is_a?(Hash) &&
|
118
118
|
first_real_value["version"].is_a?(Integer) &&
|
119
119
|
first_real_value["version"] > 0 &&
|
120
|
-
first_real_value.
|
120
|
+
first_real_value.key?("encrypted_data")
|
121
121
|
|
122
122
|
current_resource.encrypt true
|
123
123
|
current_resource.encryption_version first_real_value["version"]
|
@@ -232,7 +232,7 @@ class Chef
|
|
232
232
|
result = current_decrypted.merge(new_resource.raw_data || {})
|
233
233
|
end
|
234
234
|
result["id"] = new_resource.id
|
235
|
-
|
235
|
+
_result = apply_modifiers(new_resource.raw_data_modifiers, result)
|
236
236
|
end
|
237
237
|
end
|
238
238
|
|
@@ -283,7 +283,7 @@ class Chef
|
|
283
283
|
if !new_resource.complete
|
284
284
|
raise "Cannot encrypt #{new_resource.name} due to failure to decrypt existing resource. Set 'complete true' to overwrite or add the old secret as old_secret / old_secret_path."
|
285
285
|
end
|
286
|
-
|
286
|
+
_differences = [ "overwrite data bag item (cannot decrypt old data bag item)"]
|
287
287
|
differences = (new_resource.raw_data.keys & current_resource.raw_data.keys).map { |key| "overwrite #{key}" }
|
288
288
|
differences += (new_resource.raw_data.keys - current_resource.raw_data.keys).map { |key| "add #{key}" }
|
289
289
|
differences += (current_resource.raw_data.keys - new_resource.raw_data.keys).map { |key| "remove #{key}" }
|
@@ -45,7 +45,7 @@ class Chef
|
|
45
45
|
set_or_return(
|
46
46
|
:freeze_on_upload,
|
47
47
|
arg,
|
48
|
-
:
|
48
|
+
kind_of: Boolean
|
49
49
|
)
|
50
50
|
end
|
51
51
|
|
@@ -153,11 +153,11 @@ class Chef
|
|
153
153
|
|
154
154
|
def remote_fs
|
155
155
|
config = {
|
156
|
-
:
|
157
|
-
:
|
158
|
-
:
|
159
|
-
:
|
160
|
-
:
|
156
|
+
chef_server_url: new_resource.chef_server[:chef_server_url],
|
157
|
+
node_name: new_resource.chef_server[:options][:client_name],
|
158
|
+
client_key: new_resource.chef_server[:options][:signing_key_filename],
|
159
|
+
repo_mode: repo_mode,
|
160
|
+
versioned_cookbooks: Chef::Config.versioned_cookbooks,
|
161
161
|
}
|
162
162
|
Chef::ChefFS::FileSystem::ChefServer::ChefServerRootDir.new("remote", config)
|
163
163
|
end
|
@@ -168,10 +168,10 @@ class Chef
|
|
168
168
|
|
169
169
|
def options
|
170
170
|
result = {
|
171
|
-
:
|
172
|
-
:
|
173
|
-
:
|
174
|
-
:
|
171
|
+
purge: new_resource.purge,
|
172
|
+
freeze: new_resource.freeze_on_upload,
|
173
|
+
diff: new_resource.no_diff,
|
174
|
+
dry_run: whyrun_mode?,
|
175
175
|
}
|
176
176
|
result[:diff] = !result[:diff]
|
177
177
|
result[:repo_mode] = repo_mode
|
@@ -45,7 +45,7 @@ class Chef
|
|
45
45
|
|
46
46
|
# Revoke invites and memberships when asked
|
47
47
|
invites_to_remove.each do |user|
|
48
|
-
if outstanding_invites.
|
48
|
+
if outstanding_invites.key?(user)
|
49
49
|
converge_by "revoke #{user}'s invitation to organization #{new_resource.organization_name}" do
|
50
50
|
rest.delete("#{rest.root_url}/organizations/#{new_resource.organization_name}/association_requests/#{outstanding_invites[user]}")
|
51
51
|
end
|
@@ -61,7 +61,7 @@ class Chef
|
|
61
61
|
|
62
62
|
# Invite and add members when asked
|
63
63
|
new_resource.invites.each do |user|
|
64
|
-
if !existing_members.include?(user) && !outstanding_invites.
|
64
|
+
if !existing_members.include?(user) && !outstanding_invites.key?(user)
|
65
65
|
converge_by "invite #{user} to organization #{new_resource.organization_name}" do
|
66
66
|
rest.post("#{rest.root_url}/organizations/#{new_resource.organization_name}/association_requests", { "user" => user })
|
67
67
|
end
|
@@ -31,7 +31,7 @@ class Chef
|
|
31
31
|
new_resource.cookbooks_from.each do |path|
|
32
32
|
::Dir.entries(path).each do |name|
|
33
33
|
if ::File.directory?(::File.join(path, name)) && name != "." && name != ".."
|
34
|
-
new_resource.berksfile.cookbook name, :
|
34
|
+
new_resource.berksfile.cookbook name, path: ::File.join(path, name)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -41,9 +41,9 @@ class Chef
|
|
41
41
|
# Ridley really really wants a key :/
|
42
42
|
if new_resource.chef_server[:options][:signing_key_filename]
|
43
43
|
new_resource.berksfile.upload(
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
44
|
+
server_url: new_resource.chef_server[:chef_server_url],
|
45
|
+
client_name: new_resource.chef_server[:options][:client_name],
|
46
|
+
client_key: new_resource.chef_server[:options][:signing_key_filename])
|
47
47
|
else
|
48
48
|
file = Tempfile.new("privatekey")
|
49
49
|
begin
|
@@ -51,9 +51,9 @@ class Chef
|
|
51
51
|
file.close
|
52
52
|
|
53
53
|
new_resource.berksfile.upload(
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
54
|
+
server_url: new_resource.chef_server[:chef_server_url],
|
55
|
+
client_name: new_resource.chef_server[:options][:client_name] || "me",
|
56
|
+
client_key: file.path)
|
57
57
|
|
58
58
|
ensure
|
59
59
|
file.close
|
@@ -14,9 +14,9 @@ class Chef
|
|
14
14
|
property :external_authentication_uid
|
15
15
|
property :recovery_authentication_enabled, Boolean
|
16
16
|
property :password, String # Hmm. There is no way to idempotentize this.
|
17
|
-
#property :salt # TODO server doesn't support sending or receiving these, but it's the only way to backup / restore a user
|
18
|
-
#property :hashed_password
|
19
|
-
#property :hash_type
|
17
|
+
# property :salt # TODO server doesn't support sending or receiving these, but it's the only way to backup / restore a user
|
18
|
+
# property :hashed_password
|
19
|
+
# property :hash_type
|
20
20
|
|
21
21
|
# Input key
|
22
22
|
property :source_key # String or OpenSSL::PKey::*
|
@@ -31,7 +31,7 @@ class Chef
|
|
31
31
|
|
32
32
|
# PEM-only
|
33
33
|
property :pass_phrase, String
|
34
|
-
property :cipher, OpenSSL::Cipher.ciphers, default: "
|
34
|
+
property :cipher, String, equal_to: OpenSSL::Cipher.ciphers.map { |x| x.downcase }, default: "des-ede3-cbc", coerce: proc { |x| x.downcase }
|
35
35
|
|
36
36
|
# Set this to regenerate the key if it does not have the desired characteristics (like size, type, etc.)
|
37
37
|
property :regenerate_if_different, Boolean
|
@@ -180,12 +180,12 @@ class Chef
|
|
180
180
|
def new_source_key
|
181
181
|
@new_source_key ||= begin
|
182
182
|
if new_resource.source_key.is_a?(String)
|
183
|
-
source_key,
|
183
|
+
source_key, _source_key_format = Cheffish::KeyFormatter.decode(new_resource.source_key, new_resource.source_key_pass_phrase)
|
184
184
|
source_key
|
185
185
|
elsif new_resource.source_key
|
186
186
|
new_resource.source_key
|
187
187
|
elsif new_resource.source_key_path
|
188
|
-
source_key,
|
188
|
+
source_key, _source_key_format = Cheffish::KeyFormatter.decode(IO.read(new_resource.source_key_path), new_resource.source_key_pass_phrase, new_resource.source_key_path)
|
189
189
|
source_key
|
190
190
|
else
|
191
191
|
nil
|
@@ -57,11 +57,11 @@ class Chef
|
|
57
57
|
def new_source_key
|
58
58
|
@new_source_key ||= begin
|
59
59
|
if new_resource.source_key.is_a?(String)
|
60
|
-
source_key,
|
60
|
+
source_key, _source_key_format = Cheffish::KeyFormatter.decode(new_resource.source_key, new_resource.source_key_pass_phrase)
|
61
61
|
elsif new_resource.source_key
|
62
62
|
source_key = new_resource.source_key
|
63
63
|
elsif new_resource.source_key_path
|
64
|
-
source_key,
|
64
|
+
source_key, _source_key_format = Cheffish::KeyFormatter.decode(IO.read(new_resource.source_key_path), new_resource.source_key_pass_phrase, new_resource.source_key_path)
|
65
65
|
else
|
66
66
|
return nil
|
67
67
|
end
|
data/lib/cheffish.rb
CHANGED
@@ -7,10 +7,10 @@ module Cheffish
|
|
7
7
|
|
8
8
|
def self.default_chef_server(config = profiled_config)
|
9
9
|
{
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
10
|
+
chef_server_url: config[:chef_server_url],
|
11
|
+
options: {
|
12
|
+
client_name: config[:node_name],
|
13
|
+
signing_key_filename: config[:client_key],
|
14
14
|
},
|
15
15
|
}
|
16
16
|
end
|
@@ -58,10 +58,10 @@ module Cheffish
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.honor_local_mode(local_mode_default = true, &block)
|
61
|
-
if !Chef::Config.
|
61
|
+
if !Chef::Config.key?(:local_mode) && !local_mode_default.nil?
|
62
62
|
Chef::Config.local_mode = local_mode_default
|
63
63
|
end
|
64
|
-
if Chef::Config.local_mode && !Chef::Config.
|
64
|
+
if Chef::Config.local_mode && !Chef::Config.key?(:cookbook_path) && !Chef::Config.key?(:chef_repo_path)
|
65
65
|
Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(Dir.pwd)
|
66
66
|
end
|
67
67
|
begin
|
@@ -81,7 +81,7 @@ module Cheffish
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def self.get_private_key(name, config = profiled_config)
|
84
|
-
key,
|
84
|
+
key, _key_path = get_private_key_with_path(name, config)
|
85
85
|
key
|
86
86
|
end
|
87
87
|
|
@@ -94,7 +94,7 @@ module Cheffish
|
|
94
94
|
if old_json.kind_of?(Hash) && new_json.kind_of?(Hash)
|
95
95
|
removed_keys = old_json.keys.inject({}) { |hash, key| hash[key] = true; hash }
|
96
96
|
new_json.each_pair do |new_key, new_value|
|
97
|
-
if old_json.
|
97
|
+
if old_json.key?(new_key)
|
98
98
|
removed_keys.delete(new_key)
|
99
99
|
if new_value != old_json[new_key]
|
100
100
|
json_differences_internal(old_json[new_key], new_value, print_values, name == "" ? new_key : "#{name}.#{new_key}", result)
|
@@ -29,10 +29,9 @@ module Cheffish
|
|
29
29
|
@event_catcher = BasicChefClientEvents.new
|
30
30
|
dispatcher = Chef::EventDispatch::Dispatcher.new(@event_catcher)
|
31
31
|
case events
|
32
|
-
when nil
|
33
32
|
when Array
|
34
33
|
events.each { |e| dispatcher.register(e) } if events
|
35
|
-
|
34
|
+
when !nil
|
36
35
|
dispatcher.register(events)
|
37
36
|
end
|
38
37
|
@run_context = Chef::RunContext.new(node, {}, dispatcher)
|
@@ -19,7 +19,7 @@ module Cheffish
|
|
19
19
|
description = [ "update #{actor_type} #{new_resource.name} at #{actor_path}" ] + differences
|
20
20
|
converge_by description do
|
21
21
|
result = rest.put("#{actor_path}/#{new_resource.name}", normalize_for_put(new_json))
|
22
|
-
current_public_key,
|
22
|
+
current_public_key, _current_public_key_format = Cheffish::KeyFormatter.decode(result["public_key"]) if result["public_key"]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
else
|
@@ -29,15 +29,15 @@ module Cheffish
|
|
29
29
|
end
|
30
30
|
description = [ "create #{actor_type} #{new_resource.name} at #{actor_path}" ] + differences
|
31
31
|
converge_by description do
|
32
|
-
result = rest.post(
|
33
|
-
current_public_key,
|
32
|
+
result = rest.post((actor_path).to_s, normalize_for_post(new_json))
|
33
|
+
current_public_key, _current_public_key_format = Cheffish::KeyFormatter.decode(result["public_key"]) if result["public_key"]
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
# Write out the public key
|
38
38
|
if new_resource.output_key_path
|
39
39
|
# TODO use inline_resource
|
40
|
-
key_content = Cheffish::KeyFormatter.encode(current_public_key, { :
|
40
|
+
key_content = Cheffish::KeyFormatter.encode(current_public_key, { format: new_resource.output_key_format })
|
41
41
|
if !current_resource.output_key_path
|
42
42
|
action = "create"
|
43
43
|
elsif key_content != IO.read(current_resource.output_key_path)
|
@@ -76,7 +76,7 @@ module Cheffish
|
|
76
76
|
@new_public_key ||= begin
|
77
77
|
if new_resource.source_key
|
78
78
|
if new_resource.source_key.is_a?(String)
|
79
|
-
key,
|
79
|
+
key, _key_format = Cheffish::KeyFormatter.decode(new_resource.source_key)
|
80
80
|
|
81
81
|
if key.private?
|
82
82
|
key.public_key
|
@@ -95,7 +95,7 @@ module Cheffish
|
|
95
95
|
else
|
96
96
|
source_key_str = IO.read(source_key_path)
|
97
97
|
end
|
98
|
-
source_key,
|
98
|
+
source_key, _source_key_format = Cheffish::KeyFormatter.decode(source_key_str, new_resource.source_key_pass_phrase, source_key_path)
|
99
99
|
if source_key.private?
|
100
100
|
source_key.public_key
|
101
101
|
else
|