cheffish 0.5.beta → 0.5.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cheffish/chef_provider_base.rb +1 -1
- data/lib/cheffish/key_formatter.rb +3 -0
- data/lib/cheffish/merged_config.rb +2 -0
- data/lib/cheffish/recipe_dsl.rb +1 -1
- data/lib/cheffish/server_api.rb +42 -0
- data/lib/cheffish/version.rb +1 -1
- data/lib/cheffish.rb +26 -4
- data/spec/functional/fingerprint_spec.rb +1 -1
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbb58577cfee92cbd7ef6d37539b9f400ba8bdff
|
4
|
+
data.tar.gz: 336b434a5558e161c1d554c25d8ad4bbe4bad981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81b68668a3e3b3bcef775768121b52576d10d758999a6d59d9aaaf36dd1aade4f03d04e1fb2229c61cc50f5fd09721ca74f83b91496b7b973a1674b0fbcd872a
|
7
|
+
data.tar.gz: 3332ae787bb68204a1637857e0ca065b1b4773bface77b3b3df940299507684c5d4493d1ce53618c936fc543bb3b2135e5c187204feca2bc6412e215d823780e
|
@@ -5,7 +5,7 @@ require 'chef/provider/lwrp_base'
|
|
5
5
|
module Cheffish
|
6
6
|
class ChefProviderBase < Chef::Provider::LWRPBase
|
7
7
|
def rest
|
8
|
-
@rest ||= Cheffish.chef_server_api(new_resource.chef_server
|
8
|
+
@rest ||= Cheffish.chef_server_api(new_resource.chef_server)
|
9
9
|
end
|
10
10
|
|
11
11
|
def current_resource_exists?
|
@@ -56,6 +56,9 @@ module Cheffish
|
|
56
56
|
hexes = Digest::MD5.hexdigest(data)
|
57
57
|
hexes.scan(/../).join(':')
|
58
58
|
when :pkcs8sha1fingerprint
|
59
|
+
if RUBY_VERSION.to_f >= 2.0
|
60
|
+
raise "PKCS8 SHA1 not supported in Ruby #{RUBY_VERSION}"
|
61
|
+
end
|
59
62
|
pkcs8_pem = key.to_pem_pkcs8
|
60
63
|
pkcs8_base64 = pkcs8_pem.split("\n").reject { |l| l =~ /^-----/ }
|
61
64
|
pkcs8_data = Base64.decode64(pkcs8_base64.join)
|
data/lib/cheffish/recipe_dsl.rb
CHANGED
@@ -31,7 +31,7 @@ class Chef
|
|
31
31
|
def with_chef_local_server(options, &block)
|
32
32
|
options[:host] ||= '127.0.0.1'
|
33
33
|
options[:log_level] ||= Chef::Log.level
|
34
|
-
options[:port] ||=
|
34
|
+
options[:port] ||= 8901
|
35
35
|
|
36
36
|
# Create the data store chef-zero will use
|
37
37
|
options[:data_store] ||= begin
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/http'
|
20
|
+
require 'chef/http/authenticator'
|
21
|
+
require 'chef/http/cookie_manager'
|
22
|
+
require 'chef/http/decompressor'
|
23
|
+
require 'chef/http/json_input'
|
24
|
+
require 'chef/http/json_output'
|
25
|
+
require 'chef/http/remote_request_id'
|
26
|
+
|
27
|
+
module Cheffish
|
28
|
+
# Exactly like Chef::ServerAPI, but requires you to pass in what keys you want (no defaults)
|
29
|
+
class ServerAPI < Chef::HTTP
|
30
|
+
|
31
|
+
def initialize(url, options = {})
|
32
|
+
super(url, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
use Chef::HTTP::JSONInput
|
36
|
+
use Chef::HTTP::JSONOutput
|
37
|
+
use Chef::HTTP::CookieManager
|
38
|
+
use Chef::HTTP::Decompressor
|
39
|
+
use Chef::HTTP::Authenticator
|
40
|
+
use Chef::HTTP::RemoteRequestID
|
41
|
+
end
|
42
|
+
end
|
data/lib/cheffish/version.rb
CHANGED
data/lib/cheffish.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'chef/run_list/run_list_item'
|
2
2
|
require 'cheffish/basic_chef_client'
|
3
|
-
require '
|
3
|
+
require 'cheffish/server_api'
|
4
4
|
require 'chef/knife'
|
5
5
|
require 'chef/config_fetcher'
|
6
6
|
require 'chef/log'
|
@@ -23,8 +23,8 @@ module Cheffish
|
|
23
23
|
}
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.chef_server_api(
|
27
|
-
|
26
|
+
def self.chef_server_api(chef_server = default_chef_server)
|
27
|
+
Cheffish::ServerAPI.new(chef_server[:chef_server_url], chef_server[:options] || {})
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.profiled_config(config = Chef::Config)
|
@@ -59,7 +59,7 @@ module Cheffish
|
|
59
59
|
|
60
60
|
def self.honor_local_mode(local_mode_default = true)
|
61
61
|
if !Chef::Config.has_key?(:local_mode) && !local_mode_default.nil?
|
62
|
-
Chef::Config.local_mode =
|
62
|
+
Chef::Config.local_mode = local_mode_default
|
63
63
|
end
|
64
64
|
if Chef::Config.local_mode && !Chef::Config.has_key?(:cookbook_path) && !Chef::Config.has_key?(:chef_repo_path)
|
65
65
|
Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(Dir.pwd)
|
@@ -74,6 +74,28 @@ module Cheffish
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
def self.get_private_key(name, config = profiled_chef_config)
|
78
|
+
if config[:private_keys] && config[:private_keys][name]
|
79
|
+
if config[:private_keys][name].is_a?(String)
|
80
|
+
IO.read(config[:private_keys][name])
|
81
|
+
else
|
82
|
+
config[:private_keys][name].to_pem
|
83
|
+
end
|
84
|
+
elsif config[:private_key_paths]
|
85
|
+
config[:private_key_paths].each do |private_key_path|
|
86
|
+
Dir.entries(private_key_path).each do |key|
|
87
|
+
ext = File.extname(key)
|
88
|
+
if ext == '' || ext == '.pem'
|
89
|
+
key_name = key[0..-(ext.length+1)]
|
90
|
+
if key_name == name
|
91
|
+
return IO.read("#{private_key_path}/#{key}")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
77
99
|
NOT_PASSED=Object.new
|
78
100
|
|
79
101
|
def self.node_attributes(klass)
|
@@ -39,7 +39,7 @@ EOF
|
|
39
39
|
|
40
40
|
context 'when computing key fingperprints' do
|
41
41
|
|
42
|
-
it 'computes the PKCS#8 SHA1 private key fingerprint correctly' do
|
42
|
+
it 'computes the PKCS#8 SHA1 private key fingerprint correctly', :pending => (RUBY_VERSION.to_f >= 2.0) do
|
43
43
|
expect(key_to_format(sample_private_key, :pkcs8sha1fingerprint)).to eq(
|
44
44
|
'88:7e:3a:bd:26:9f:b5:c5:d8:ae:52:f9:df:0b:64:a4:5c:17:0a:87')
|
45
45
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheffish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.beta
|
4
|
+
version: 0.5.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: openssl_pkcs8
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: A library to manipulate Chef in Chef.
|
@@ -74,9 +74,9 @@ extra_rdoc_files:
|
|
74
74
|
- README.md
|
75
75
|
- LICENSE
|
76
76
|
files:
|
77
|
-
- Rakefile
|
78
77
|
- LICENSE
|
79
78
|
- README.md
|
79
|
+
- Rakefile
|
80
80
|
- lib/chef/provider/chef_client.rb
|
81
81
|
- lib/chef/provider/chef_data_bag.rb
|
82
82
|
- lib/chef/provider/chef_data_bag_item.rb
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/chef/resource/in_parallel.rb
|
97
97
|
- lib/chef/resource/private_key.rb
|
98
98
|
- lib/chef/resource/public_key.rb
|
99
|
+
- lib/cheffish.rb
|
99
100
|
- lib/cheffish/actor_provider_base.rb
|
100
101
|
- lib/cheffish/basic_chef_client.rb
|
101
102
|
- lib/cheffish/chef_provider_base.rb
|
@@ -104,9 +105,9 @@ files:
|
|
104
105
|
- lib/cheffish/key_formatter.rb
|
105
106
|
- lib/cheffish/merged_config.rb
|
106
107
|
- lib/cheffish/recipe_dsl.rb
|
108
|
+
- lib/cheffish/server_api.rb
|
107
109
|
- lib/cheffish/version.rb
|
108
110
|
- lib/cheffish/with_pattern.rb
|
109
|
-
- lib/cheffish.rb
|
110
111
|
- spec/functional/fingerprint_spec.rb
|
111
112
|
- spec/integration/chef_client_spec.rb
|
112
113
|
- spec/integration/chef_node_spec.rb
|
@@ -124,17 +125,17 @@ require_paths:
|
|
124
125
|
- lib
|
125
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
127
|
requirements:
|
127
|
-
- -
|
128
|
+
- - ">="
|
128
129
|
- !ruby/object:Gem::Version
|
129
130
|
version: '0'
|
130
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
132
|
requirements:
|
132
|
-
- -
|
133
|
+
- - ">"
|
133
134
|
- !ruby/object:Gem::Version
|
134
135
|
version: 1.3.1
|
135
136
|
requirements: []
|
136
137
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.2.2
|
138
139
|
signing_key:
|
139
140
|
specification_version: 4
|
140
141
|
summary: A library to manipulate Chef in Chef.
|