cheffish 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +201 -201
- data/README.md +120 -120
- data/Rakefile +23 -23
- data/lib/chef/provider/chef_acl.rb +439 -439
- data/lib/chef/provider/chef_client.rb +53 -53
- data/lib/chef/provider/chef_container.rb +55 -55
- data/lib/chef/provider/chef_data_bag.rb +55 -55
- data/lib/chef/provider/chef_data_bag_item.rb +278 -278
- data/lib/chef/provider/chef_environment.rb +83 -83
- data/lib/chef/provider/chef_group.rb +83 -83
- data/lib/chef/provider/chef_mirror.rb +169 -169
- data/lib/chef/provider/chef_node.rb +87 -87
- data/lib/chef/provider/chef_organization.rb +155 -155
- data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -46
- data/lib/chef/provider/chef_role.rb +84 -84
- data/lib/chef/provider/chef_user.rb +59 -59
- data/lib/chef/provider/private_key.rb +225 -225
- data/lib/chef/provider/public_key.rb +88 -88
- data/lib/chef/resource/chef_acl.rb +69 -69
- data/lib/chef/resource/chef_client.rb +48 -48
- data/lib/chef/resource/chef_container.rb +22 -22
- data/lib/chef/resource/chef_data_bag.rb +22 -22
- data/lib/chef/resource/chef_data_bag_item.rb +121 -121
- data/lib/chef/resource/chef_environment.rb +77 -77
- data/lib/chef/resource/chef_group.rb +53 -53
- data/lib/chef/resource/chef_mirror.rb +52 -52
- data/lib/chef/resource/chef_node.rb +22 -22
- data/lib/chef/resource/chef_organization.rb +69 -69
- data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -35
- data/lib/chef/resource/chef_role.rb +110 -110
- data/lib/chef/resource/chef_user.rb +56 -56
- data/lib/chef/resource/private_key.rb +48 -48
- data/lib/chef/resource/public_key.rb +25 -25
- data/lib/cheffish/actor_provider_base.rb +131 -131
- data/lib/cheffish/basic_chef_client.rb +184 -184
- data/lib/cheffish/chef_provider_base.rb +246 -246
- data/lib/cheffish/chef_run.rb +162 -162
- data/lib/cheffish/chef_run_data.rb +19 -19
- data/lib/cheffish/chef_run_listener.rb +30 -30
- data/lib/cheffish/key_formatter.rb +113 -113
- data/lib/cheffish/merged_config.rb +94 -94
- data/lib/cheffish/recipe_dsl.rb +157 -157
- data/lib/cheffish/rspec/chef_run_support.rb +83 -83
- data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -16
- data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -15
- data/lib/cheffish/rspec/matchers/have_updated.rb +37 -37
- data/lib/cheffish/rspec/matchers/partially_match.rb +63 -63
- data/lib/cheffish/rspec/matchers.rb +4 -4
- data/lib/cheffish/rspec/recipe_run_wrapper.rb +78 -59
- data/lib/cheffish/rspec/repository_support.rb +108 -108
- data/lib/cheffish/rspec.rb +8 -8
- data/lib/cheffish/server_api.rb +52 -52
- data/lib/cheffish/version.rb +3 -3
- data/lib/cheffish/with_pattern.rb +21 -21
- data/lib/cheffish.rb +235 -235
- data/spec/functional/fingerprint_spec.rb +64 -64
- data/spec/functional/merged_config_spec.rb +19 -19
- data/spec/functional/server_api_spec.rb +13 -13
- data/spec/integration/chef_acl_spec.rb +879 -879
- data/spec/integration/chef_client_spec.rb +105 -105
- data/spec/integration/chef_container_spec.rb +33 -33
- data/spec/integration/chef_group_spec.rb +309 -309
- data/spec/integration/chef_mirror_spec.rb +491 -491
- data/spec/integration/chef_node_spec.rb +786 -786
- data/spec/integration/chef_organization_spec.rb +226 -226
- data/spec/integration/chef_role_spec.rb +78 -78
- data/spec/integration/chef_user_spec.rb +85 -85
- data/spec/integration/private_key_spec.rb +399 -399
- data/spec/integration/recipe_dsl_spec.rb +28 -28
- data/spec/integration/rspec/converge_spec.rb +183 -183
- data/spec/support/key_support.rb +29 -29
- data/spec/support/spec_support.rb +15 -15
- data/spec/unit/get_private_key_spec.rb +131 -131
- data/spec/unit/recipe_run_wrapper_spec.rb +37 -37
- metadata +3 -2
@@ -1,110 +1,110 @@
|
|
1
|
-
require 'cheffish'
|
2
|
-
require 'chef/resource/lwrp_base'
|
3
|
-
require 'chef/run_list/run_list_item'
|
4
|
-
|
5
|
-
class Chef
|
6
|
-
class Resource
|
7
|
-
class ChefRole < Chef::Resource::LWRPBase
|
8
|
-
self.resource_name = 'chef_role'
|
9
|
-
|
10
|
-
actions :create, :delete, :nothing
|
11
|
-
default_action :create
|
12
|
-
|
13
|
-
# Grab environment from with_environment
|
14
|
-
def initialize(*args)
|
15
|
-
super
|
16
|
-
chef_server run_context.cheffish.current_chef_server
|
17
|
-
end
|
18
|
-
|
19
|
-
attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
|
20
|
-
attribute :description, :kind_of => String
|
21
|
-
attribute :run_list, :kind_of => Array # We should let them specify it as a series of parameters too
|
22
|
-
attribute :env_run_lists, :kind_of => Hash
|
23
|
-
attribute :default_attributes, :kind_of => Hash
|
24
|
-
attribute :override_attributes, :kind_of => Hash
|
25
|
-
|
26
|
-
# Specifies that this is a complete specification for the environment (i.e. attributes you don't specify will be
|
27
|
-
# reset to their defaults)
|
28
|
-
attribute :complete, :kind_of => [TrueClass, FalseClass]
|
29
|
-
|
30
|
-
attribute :raw_json, :kind_of => Hash
|
31
|
-
attribute :chef_server, :kind_of => Hash
|
32
|
-
|
33
|
-
# `NOT_PASSED` is defined in chef-12.5.0, this guard will ensure we
|
34
|
-
# don't redefine it if it's already there
|
35
|
-
NOT_PASSED=Object.new unless defined?(NOT_PASSED)
|
36
|
-
|
37
|
-
# default_attribute 'ip_address', '127.0.0.1'
|
38
|
-
# default_attribute [ 'pushy', 'port' ], '9000'
|
39
|
-
# default_attribute 'ip_addresses' do |existing_value|
|
40
|
-
# (existing_value || []) + [ '127.0.0.1' ]
|
41
|
-
# end
|
42
|
-
# default_attribute 'ip_address', :delete
|
43
|
-
attr_reader :default_attribute_modifiers
|
44
|
-
def default_attribute(attribute_path, value=NOT_PASSED, &block)
|
45
|
-
@default_attribute_modifiers ||= []
|
46
|
-
if value != NOT_PASSED
|
47
|
-
@default_attribute_modifiers << [ attribute_path, value ]
|
48
|
-
elsif block
|
49
|
-
@default_attribute_modifiers << [ attribute_path, block ]
|
50
|
-
else
|
51
|
-
raise "default_attribute requires either a value or a block"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# override_attribute 'ip_address', '127.0.0.1'
|
56
|
-
# override_attribute [ 'pushy', 'port' ], '9000'
|
57
|
-
# override_attribute 'ip_addresses' do |existing_value|
|
58
|
-
# (existing_value || []) + [ '127.0.0.1' ]
|
59
|
-
# end
|
60
|
-
# override_attribute 'ip_address', :delete
|
61
|
-
attr_reader :override_attribute_modifiers
|
62
|
-
def override_attribute(attribute_path, value=NOT_PASSED, &block)
|
63
|
-
@override_attribute_modifiers ||= []
|
64
|
-
if value != NOT_PASSED
|
65
|
-
@override_attribute_modifiers << [ attribute_path, value ]
|
66
|
-
elsif block
|
67
|
-
@override_attribute_modifiers << [ attribute_path, block ]
|
68
|
-
else
|
69
|
-
raise "override_attribute requires either a value or a block"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
# Order matters--if two things here are in the wrong order, they will be flipped in the run list
|
74
|
-
# recipe 'apache', 'mysql'
|
75
|
-
# recipe 'recipe@version'
|
76
|
-
# recipe 'recipe'
|
77
|
-
# role ''
|
78
|
-
attr_reader :run_list_modifiers
|
79
|
-
attr_reader :run_list_removers
|
80
|
-
def recipe(*recipes)
|
81
|
-
if recipes.size == 0
|
82
|
-
raise ArgumentError, "At least one recipe must be specified"
|
83
|
-
end
|
84
|
-
@run_list_modifiers ||= []
|
85
|
-
@run_list_modifiers += recipes.map { |recipe| Chef::RunList::RunListItem.new("recipe[#{recipe}]") }
|
86
|
-
end
|
87
|
-
def role(*roles)
|
88
|
-
if roles.size == 0
|
89
|
-
raise ArgumentError, "At least one role must be specified"
|
90
|
-
end
|
91
|
-
@run_list_modifiers ||= []
|
92
|
-
@run_list_modifiers += roles.map { |role| Chef::RunList::RunListItem.new("role[#{role}]") }
|
93
|
-
end
|
94
|
-
def remove_recipe(*recipes)
|
95
|
-
if recipes.size == 0
|
96
|
-
raise ArgumentError, "At least one recipe must be specified"
|
97
|
-
end
|
98
|
-
@run_list_removers ||= []
|
99
|
-
@run_list_removers += recipes.map { |recipe| Chef::RunList::RunListItem.new("recipe[#{recipe}]") }
|
100
|
-
end
|
101
|
-
def remove_role(*roles)
|
102
|
-
if roles.size == 0
|
103
|
-
raise ArgumentError, "At least one role must be specified"
|
104
|
-
end
|
105
|
-
@run_list_removers ||= []
|
106
|
-
@run_list_removers += roles.map { |recipe| Chef::RunList::RunListItem.new("role[#{role}]") }
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
1
|
+
require 'cheffish'
|
2
|
+
require 'chef/resource/lwrp_base'
|
3
|
+
require 'chef/run_list/run_list_item'
|
4
|
+
|
5
|
+
class Chef
|
6
|
+
class Resource
|
7
|
+
class ChefRole < Chef::Resource::LWRPBase
|
8
|
+
self.resource_name = 'chef_role'
|
9
|
+
|
10
|
+
actions :create, :delete, :nothing
|
11
|
+
default_action :create
|
12
|
+
|
13
|
+
# Grab environment from with_environment
|
14
|
+
def initialize(*args)
|
15
|
+
super
|
16
|
+
chef_server run_context.cheffish.current_chef_server
|
17
|
+
end
|
18
|
+
|
19
|
+
attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
|
20
|
+
attribute :description, :kind_of => String
|
21
|
+
attribute :run_list, :kind_of => Array # We should let them specify it as a series of parameters too
|
22
|
+
attribute :env_run_lists, :kind_of => Hash
|
23
|
+
attribute :default_attributes, :kind_of => Hash
|
24
|
+
attribute :override_attributes, :kind_of => Hash
|
25
|
+
|
26
|
+
# Specifies that this is a complete specification for the environment (i.e. attributes you don't specify will be
|
27
|
+
# reset to their defaults)
|
28
|
+
attribute :complete, :kind_of => [TrueClass, FalseClass]
|
29
|
+
|
30
|
+
attribute :raw_json, :kind_of => Hash
|
31
|
+
attribute :chef_server, :kind_of => Hash
|
32
|
+
|
33
|
+
# `NOT_PASSED` is defined in chef-12.5.0, this guard will ensure we
|
34
|
+
# don't redefine it if it's already there
|
35
|
+
NOT_PASSED=Object.new unless defined?(NOT_PASSED)
|
36
|
+
|
37
|
+
# default_attribute 'ip_address', '127.0.0.1'
|
38
|
+
# default_attribute [ 'pushy', 'port' ], '9000'
|
39
|
+
# default_attribute 'ip_addresses' do |existing_value|
|
40
|
+
# (existing_value || []) + [ '127.0.0.1' ]
|
41
|
+
# end
|
42
|
+
# default_attribute 'ip_address', :delete
|
43
|
+
attr_reader :default_attribute_modifiers
|
44
|
+
def default_attribute(attribute_path, value=NOT_PASSED, &block)
|
45
|
+
@default_attribute_modifiers ||= []
|
46
|
+
if value != NOT_PASSED
|
47
|
+
@default_attribute_modifiers << [ attribute_path, value ]
|
48
|
+
elsif block
|
49
|
+
@default_attribute_modifiers << [ attribute_path, block ]
|
50
|
+
else
|
51
|
+
raise "default_attribute requires either a value or a block"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# override_attribute 'ip_address', '127.0.0.1'
|
56
|
+
# override_attribute [ 'pushy', 'port' ], '9000'
|
57
|
+
# override_attribute 'ip_addresses' do |existing_value|
|
58
|
+
# (existing_value || []) + [ '127.0.0.1' ]
|
59
|
+
# end
|
60
|
+
# override_attribute 'ip_address', :delete
|
61
|
+
attr_reader :override_attribute_modifiers
|
62
|
+
def override_attribute(attribute_path, value=NOT_PASSED, &block)
|
63
|
+
@override_attribute_modifiers ||= []
|
64
|
+
if value != NOT_PASSED
|
65
|
+
@override_attribute_modifiers << [ attribute_path, value ]
|
66
|
+
elsif block
|
67
|
+
@override_attribute_modifiers << [ attribute_path, block ]
|
68
|
+
else
|
69
|
+
raise "override_attribute requires either a value or a block"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Order matters--if two things here are in the wrong order, they will be flipped in the run list
|
74
|
+
# recipe 'apache', 'mysql'
|
75
|
+
# recipe 'recipe@version'
|
76
|
+
# recipe 'recipe'
|
77
|
+
# role ''
|
78
|
+
attr_reader :run_list_modifiers
|
79
|
+
attr_reader :run_list_removers
|
80
|
+
def recipe(*recipes)
|
81
|
+
if recipes.size == 0
|
82
|
+
raise ArgumentError, "At least one recipe must be specified"
|
83
|
+
end
|
84
|
+
@run_list_modifiers ||= []
|
85
|
+
@run_list_modifiers += recipes.map { |recipe| Chef::RunList::RunListItem.new("recipe[#{recipe}]") }
|
86
|
+
end
|
87
|
+
def role(*roles)
|
88
|
+
if roles.size == 0
|
89
|
+
raise ArgumentError, "At least one role must be specified"
|
90
|
+
end
|
91
|
+
@run_list_modifiers ||= []
|
92
|
+
@run_list_modifiers += roles.map { |role| Chef::RunList::RunListItem.new("role[#{role}]") }
|
93
|
+
end
|
94
|
+
def remove_recipe(*recipes)
|
95
|
+
if recipes.size == 0
|
96
|
+
raise ArgumentError, "At least one recipe must be specified"
|
97
|
+
end
|
98
|
+
@run_list_removers ||= []
|
99
|
+
@run_list_removers += recipes.map { |recipe| Chef::RunList::RunListItem.new("recipe[#{recipe}]") }
|
100
|
+
end
|
101
|
+
def remove_role(*roles)
|
102
|
+
if roles.size == 0
|
103
|
+
raise ArgumentError, "At least one role must be specified"
|
104
|
+
end
|
105
|
+
@run_list_removers ||= []
|
106
|
+
@run_list_removers += roles.map { |recipe| Chef::RunList::RunListItem.new("role[#{role}]") }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -1,56 +1,56 @@
|
|
1
|
-
require 'cheffish'
|
2
|
-
require 'chef/resource/lwrp_base'
|
3
|
-
|
4
|
-
class Chef
|
5
|
-
class Resource
|
6
|
-
class ChefUser < Chef::Resource::LWRPBase
|
7
|
-
self.resource_name = 'chef_user'
|
8
|
-
|
9
|
-
actions :create, :delete, :nothing
|
10
|
-
default_action :create
|
11
|
-
|
12
|
-
# Grab environment from with_environment
|
13
|
-
def initialize(*args)
|
14
|
-
super
|
15
|
-
chef_server run_context.cheffish.current_chef_server
|
16
|
-
end
|
17
|
-
|
18
|
-
# Client attributes
|
19
|
-
attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
|
20
|
-
attribute :display_name, :kind_of => String
|
21
|
-
attribute :admin, :kind_of => [TrueClass, FalseClass]
|
22
|
-
attribute :email, :kind_of => String
|
23
|
-
attribute :external_authentication_uid
|
24
|
-
attribute :recovery_authentication_enabled, :kind_of => [TrueClass, FalseClass]
|
25
|
-
attribute :password, :kind_of => String # Hmm. There is no way to idempotentize this.
|
26
|
-
#attribute :salt # TODO server doesn't support sending or receiving these, but it's the only way to backup / restore a user
|
27
|
-
#attribute :hashed_password
|
28
|
-
#attribute :hash_type
|
29
|
-
|
30
|
-
# Input key
|
31
|
-
attribute :source_key # String or OpenSSL::PKey::*
|
32
|
-
attribute :source_key_path, :kind_of => String
|
33
|
-
attribute :source_key_pass_phrase
|
34
|
-
|
35
|
-
# Output public key (if so desired)
|
36
|
-
attribute :output_key_path, :kind_of => String
|
37
|
-
attribute :output_key_format, :kind_of => Symbol, :default => :openssh, :equal_to => [ :pem, :der, :openssh ]
|
38
|
-
|
39
|
-
# If this is set, client is not patchy
|
40
|
-
attribute :complete, :kind_of => [TrueClass, FalseClass]
|
41
|
-
|
42
|
-
attribute :raw_json, :kind_of => Hash
|
43
|
-
attribute :chef_server, :kind_of => Hash
|
44
|
-
|
45
|
-
# Proc that runs just before the resource executes. Called with (resource)
|
46
|
-
def before(&block)
|
47
|
-
block ? @before = block : @before
|
48
|
-
end
|
49
|
-
|
50
|
-
# Proc that runs after the resource completes. Called with (resource, json, private_key, public_key)
|
51
|
-
def after(&block)
|
52
|
-
block ? @after = block : @after
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
1
|
+
require 'cheffish'
|
2
|
+
require 'chef/resource/lwrp_base'
|
3
|
+
|
4
|
+
class Chef
|
5
|
+
class Resource
|
6
|
+
class ChefUser < Chef::Resource::LWRPBase
|
7
|
+
self.resource_name = 'chef_user'
|
8
|
+
|
9
|
+
actions :create, :delete, :nothing
|
10
|
+
default_action :create
|
11
|
+
|
12
|
+
# Grab environment from with_environment
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
chef_server run_context.cheffish.current_chef_server
|
16
|
+
end
|
17
|
+
|
18
|
+
# Client attributes
|
19
|
+
attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
|
20
|
+
attribute :display_name, :kind_of => String
|
21
|
+
attribute :admin, :kind_of => [TrueClass, FalseClass]
|
22
|
+
attribute :email, :kind_of => String
|
23
|
+
attribute :external_authentication_uid
|
24
|
+
attribute :recovery_authentication_enabled, :kind_of => [TrueClass, FalseClass]
|
25
|
+
attribute :password, :kind_of => String # Hmm. There is no way to idempotentize this.
|
26
|
+
#attribute :salt # TODO server doesn't support sending or receiving these, but it's the only way to backup / restore a user
|
27
|
+
#attribute :hashed_password
|
28
|
+
#attribute :hash_type
|
29
|
+
|
30
|
+
# Input key
|
31
|
+
attribute :source_key # String or OpenSSL::PKey::*
|
32
|
+
attribute :source_key_path, :kind_of => String
|
33
|
+
attribute :source_key_pass_phrase
|
34
|
+
|
35
|
+
# Output public key (if so desired)
|
36
|
+
attribute :output_key_path, :kind_of => String
|
37
|
+
attribute :output_key_format, :kind_of => Symbol, :default => :openssh, :equal_to => [ :pem, :der, :openssh ]
|
38
|
+
|
39
|
+
# If this is set, client is not patchy
|
40
|
+
attribute :complete, :kind_of => [TrueClass, FalseClass]
|
41
|
+
|
42
|
+
attribute :raw_json, :kind_of => Hash
|
43
|
+
attribute :chef_server, :kind_of => Hash
|
44
|
+
|
45
|
+
# Proc that runs just before the resource executes. Called with (resource)
|
46
|
+
def before(&block)
|
47
|
+
block ? @before = block : @before
|
48
|
+
end
|
49
|
+
|
50
|
+
# Proc that runs after the resource completes. Called with (resource, json, private_key, public_key)
|
51
|
+
def after(&block)
|
52
|
+
block ? @after = block : @after
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,48 +1,48 @@
|
|
1
|
-
require 'openssl/cipher'
|
2
|
-
require 'chef/resource/lwrp_base'
|
3
|
-
|
4
|
-
class Chef
|
5
|
-
class Resource
|
6
|
-
class PrivateKey < Chef::Resource::LWRPBase
|
7
|
-
self.resource_name = 'private_key'
|
8
|
-
|
9
|
-
actions :create, :delete, :regenerate, :nothing
|
10
|
-
default_action :create
|
11
|
-
|
12
|
-
# Path to private key. Set to :none to create the key in memory and not on disk.
|
13
|
-
attribute :path, :kind_of => [ String, Symbol ], :name_attribute => true
|
14
|
-
attribute :format, :kind_of => Symbol, :default => :pem, :equal_to => [ :pem, :der ]
|
15
|
-
attribute :type, :kind_of => Symbol, :default => :rsa, :equal_to => [ :rsa, :dsa ] # TODO support :ec
|
16
|
-
# These specify an optional public_key you can spit out if you want.
|
17
|
-
attribute :public_key_path, :kind_of => String
|
18
|
-
attribute :public_key_format, :kind_of => Symbol, :default => :openssh, :equal_to => [ :openssh, :pem, :der ]
|
19
|
-
# Specify this if you want to copy another private key but give it a different format / password
|
20
|
-
attribute :source_key
|
21
|
-
attribute :source_key_path, :kind_of => String
|
22
|
-
attribute :source_key_pass_phrase
|
23
|
-
|
24
|
-
# RSA and DSA
|
25
|
-
attribute :size, :kind_of => Integer, :default => 2048
|
26
|
-
|
27
|
-
# RSA-only
|
28
|
-
attribute :exponent, :kind_of => Integer # For RSA
|
29
|
-
|
30
|
-
# PEM-only
|
31
|
-
attribute :pass_phrase, :kind_of => String
|
32
|
-
attribute :cipher, :kind_of => String, :default => 'DES-EDE3-CBC', :equal_to => OpenSSL::Cipher.ciphers
|
33
|
-
|
34
|
-
# Set this to regenerate the key if it does not have the desired characteristics (like size, type, etc.)
|
35
|
-
attribute :regenerate_if_different, :kind_of => [TrueClass, FalseClass]
|
36
|
-
|
37
|
-
# Proc that runs after the resource completes. Called with (resource, private_key)
|
38
|
-
def after(&block)
|
39
|
-
block ? @after = block : @after
|
40
|
-
end
|
41
|
-
|
42
|
-
# We are not interested in Chef's cloning behavior here.
|
43
|
-
def load_prior_resource(*args)
|
44
|
-
Chef::Log.debug("Overloading #{resource_name}.load_prior_resource with NOOP")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
1
|
+
require 'openssl/cipher'
|
2
|
+
require 'chef/resource/lwrp_base'
|
3
|
+
|
4
|
+
class Chef
|
5
|
+
class Resource
|
6
|
+
class PrivateKey < Chef::Resource::LWRPBase
|
7
|
+
self.resource_name = 'private_key'
|
8
|
+
|
9
|
+
actions :create, :delete, :regenerate, :nothing
|
10
|
+
default_action :create
|
11
|
+
|
12
|
+
# Path to private key. Set to :none to create the key in memory and not on disk.
|
13
|
+
attribute :path, :kind_of => [ String, Symbol ], :name_attribute => true
|
14
|
+
attribute :format, :kind_of => Symbol, :default => :pem, :equal_to => [ :pem, :der ]
|
15
|
+
attribute :type, :kind_of => Symbol, :default => :rsa, :equal_to => [ :rsa, :dsa ] # TODO support :ec
|
16
|
+
# These specify an optional public_key you can spit out if you want.
|
17
|
+
attribute :public_key_path, :kind_of => String
|
18
|
+
attribute :public_key_format, :kind_of => Symbol, :default => :openssh, :equal_to => [ :openssh, :pem, :der ]
|
19
|
+
# Specify this if you want to copy another private key but give it a different format / password
|
20
|
+
attribute :source_key
|
21
|
+
attribute :source_key_path, :kind_of => String
|
22
|
+
attribute :source_key_pass_phrase
|
23
|
+
|
24
|
+
# RSA and DSA
|
25
|
+
attribute :size, :kind_of => Integer, :default => 2048
|
26
|
+
|
27
|
+
# RSA-only
|
28
|
+
attribute :exponent, :kind_of => Integer # For RSA
|
29
|
+
|
30
|
+
# PEM-only
|
31
|
+
attribute :pass_phrase, :kind_of => String
|
32
|
+
attribute :cipher, :kind_of => String, :default => 'DES-EDE3-CBC', :equal_to => OpenSSL::Cipher.ciphers
|
33
|
+
|
34
|
+
# Set this to regenerate the key if it does not have the desired characteristics (like size, type, etc.)
|
35
|
+
attribute :regenerate_if_different, :kind_of => [TrueClass, FalseClass]
|
36
|
+
|
37
|
+
# Proc that runs after the resource completes. Called with (resource, private_key)
|
38
|
+
def after(&block)
|
39
|
+
block ? @after = block : @after
|
40
|
+
end
|
41
|
+
|
42
|
+
# We are not interested in Chef's cloning behavior here.
|
43
|
+
def load_prior_resource(*args)
|
44
|
+
Chef::Log.debug("Overloading #{resource_name}.load_prior_resource with NOOP")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
require 'openssl/cipher'
|
2
|
-
require 'chef/resource/lwrp_base'
|
3
|
-
|
4
|
-
class Chef
|
5
|
-
class Resource
|
6
|
-
class PublicKey < Chef::Resource::LWRPBase
|
7
|
-
self.resource_name = 'public_key'
|
8
|
-
|
9
|
-
actions :create, :delete, :nothing
|
10
|
-
default_action :create
|
11
|
-
|
12
|
-
attribute :path, :kind_of => String, :name_attribute => true
|
13
|
-
attribute :format, :kind_of => Symbol, :default => :openssh, :equal_to => [ :pem, :der, :openssh ]
|
14
|
-
|
15
|
-
attribute :source_key
|
16
|
-
attribute :source_key_path, :kind_of => String
|
17
|
-
attribute :source_key_pass_phrase
|
18
|
-
|
19
|
-
# We are not interested in Chef's cloning behavior here.
|
20
|
-
def load_prior_resource(*args)
|
21
|
-
Chef::Log.debug("Overloading #{resource_name}.load_prior_resource with NOOP")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
require 'openssl/cipher'
|
2
|
+
require 'chef/resource/lwrp_base'
|
3
|
+
|
4
|
+
class Chef
|
5
|
+
class Resource
|
6
|
+
class PublicKey < Chef::Resource::LWRPBase
|
7
|
+
self.resource_name = 'public_key'
|
8
|
+
|
9
|
+
actions :create, :delete, :nothing
|
10
|
+
default_action :create
|
11
|
+
|
12
|
+
attribute :path, :kind_of => String, :name_attribute => true
|
13
|
+
attribute :format, :kind_of => Symbol, :default => :openssh, :equal_to => [ :pem, :der, :openssh ]
|
14
|
+
|
15
|
+
attribute :source_key
|
16
|
+
attribute :source_key_path, :kind_of => String
|
17
|
+
attribute :source_key_pass_phrase
|
18
|
+
|
19
|
+
# We are not interested in Chef's cloning behavior here.
|
20
|
+
def load_prior_resource(*args)
|
21
|
+
Chef::Log.debug("Overloading #{resource_name}.load_prior_resource with NOOP")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|