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,84 +1,84 @@
|
|
1
|
-
require 'cheffish/chef_provider_base'
|
2
|
-
require 'chef/resource/chef_role'
|
3
|
-
require 'chef/chef_fs/data_handler/role_data_handler'
|
4
|
-
|
5
|
-
class Chef
|
6
|
-
class Provider
|
7
|
-
class ChefRole < Cheffish::ChefProviderBase
|
8
|
-
provides :chef_role
|
9
|
-
|
10
|
-
def whyrun_supported?
|
11
|
-
true
|
12
|
-
end
|
13
|
-
|
14
|
-
action :create do
|
15
|
-
differences = json_differences(current_json, new_json)
|
16
|
-
|
17
|
-
if current_resource_exists?
|
18
|
-
if differences.size > 0
|
19
|
-
description = [ "update role #{new_resource.name} at #{rest.url}" ] + differences
|
20
|
-
converge_by description do
|
21
|
-
rest.put("roles/#{new_resource.name}", normalize_for_put(new_json))
|
22
|
-
end
|
23
|
-
end
|
24
|
-
else
|
25
|
-
description = [ "create role #{new_resource.name} at #{rest.url}" ] + differences
|
26
|
-
converge_by description do
|
27
|
-
rest.post("roles", normalize_for_post(new_json))
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
action :delete do
|
33
|
-
if current_resource_exists?
|
34
|
-
converge_by "delete role #{new_resource.name} at #{rest.url}" do
|
35
|
-
rest.delete("roles/#{new_resource.name}")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def load_current_resource
|
41
|
-
begin
|
42
|
-
@current_resource = json_to_resource(rest.get("roles/#{new_resource.name}"))
|
43
|
-
rescue Net::HTTPServerException => e
|
44
|
-
if e.response.code == "404"
|
45
|
-
@current_resource = not_found_resource
|
46
|
-
else
|
47
|
-
raise
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def augment_new_json(json)
|
53
|
-
# Apply modifiers
|
54
|
-
json['run_list'] = apply_run_list_modifiers(new_resource.run_list_modifiers, new_resource.run_list_removers, json['run_list'])
|
55
|
-
json['default_attributes'] = apply_modifiers(new_resource.default_attribute_modifiers, json['default_attributes'])
|
56
|
-
json['override_attributes'] = apply_modifiers(new_resource.override_attribute_modifiers, json['override_attributes'])
|
57
|
-
json
|
58
|
-
end
|
59
|
-
|
60
|
-
#
|
61
|
-
# Helpers
|
62
|
-
#
|
63
|
-
|
64
|
-
def resource_class
|
65
|
-
Chef::Resource::ChefRole
|
66
|
-
end
|
67
|
-
|
68
|
-
def data_handler
|
69
|
-
Chef::ChefFS::DataHandler::RoleDataHandler.new
|
70
|
-
end
|
71
|
-
|
72
|
-
def keys
|
73
|
-
{
|
74
|
-
'name' => :name,
|
75
|
-
'description' => :description,
|
76
|
-
'run_list' => :run_list,
|
77
|
-
'env_run_lists' => :env_run_lists,
|
78
|
-
'default_attributes' => :default_attributes,
|
79
|
-
'override_attributes' => :override_attributes
|
80
|
-
}
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
1
|
+
require 'cheffish/chef_provider_base'
|
2
|
+
require 'chef/resource/chef_role'
|
3
|
+
require 'chef/chef_fs/data_handler/role_data_handler'
|
4
|
+
|
5
|
+
class Chef
|
6
|
+
class Provider
|
7
|
+
class ChefRole < Cheffish::ChefProviderBase
|
8
|
+
provides :chef_role
|
9
|
+
|
10
|
+
def whyrun_supported?
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
action :create do
|
15
|
+
differences = json_differences(current_json, new_json)
|
16
|
+
|
17
|
+
if current_resource_exists?
|
18
|
+
if differences.size > 0
|
19
|
+
description = [ "update role #{new_resource.name} at #{rest.url}" ] + differences
|
20
|
+
converge_by description do
|
21
|
+
rest.put("roles/#{new_resource.name}", normalize_for_put(new_json))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
else
|
25
|
+
description = [ "create role #{new_resource.name} at #{rest.url}" ] + differences
|
26
|
+
converge_by description do
|
27
|
+
rest.post("roles", normalize_for_post(new_json))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
action :delete do
|
33
|
+
if current_resource_exists?
|
34
|
+
converge_by "delete role #{new_resource.name} at #{rest.url}" do
|
35
|
+
rest.delete("roles/#{new_resource.name}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def load_current_resource
|
41
|
+
begin
|
42
|
+
@current_resource = json_to_resource(rest.get("roles/#{new_resource.name}"))
|
43
|
+
rescue Net::HTTPServerException => e
|
44
|
+
if e.response.code == "404"
|
45
|
+
@current_resource = not_found_resource
|
46
|
+
else
|
47
|
+
raise
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def augment_new_json(json)
|
53
|
+
# Apply modifiers
|
54
|
+
json['run_list'] = apply_run_list_modifiers(new_resource.run_list_modifiers, new_resource.run_list_removers, json['run_list'])
|
55
|
+
json['default_attributes'] = apply_modifiers(new_resource.default_attribute_modifiers, json['default_attributes'])
|
56
|
+
json['override_attributes'] = apply_modifiers(new_resource.override_attribute_modifiers, json['override_attributes'])
|
57
|
+
json
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Helpers
|
62
|
+
#
|
63
|
+
|
64
|
+
def resource_class
|
65
|
+
Chef::Resource::ChefRole
|
66
|
+
end
|
67
|
+
|
68
|
+
def data_handler
|
69
|
+
Chef::ChefFS::DataHandler::RoleDataHandler.new
|
70
|
+
end
|
71
|
+
|
72
|
+
def keys
|
73
|
+
{
|
74
|
+
'name' => :name,
|
75
|
+
'description' => :description,
|
76
|
+
'run_list' => :run_list,
|
77
|
+
'env_run_lists' => :env_run_lists,
|
78
|
+
'default_attributes' => :default_attributes,
|
79
|
+
'override_attributes' => :override_attributes
|
80
|
+
}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -1,59 +1,59 @@
|
|
1
|
-
require 'cheffish/actor_provider_base'
|
2
|
-
require 'chef/resource/chef_user'
|
3
|
-
require 'chef/chef_fs/data_handler/user_data_handler'
|
4
|
-
|
5
|
-
class Chef
|
6
|
-
class Provider
|
7
|
-
class ChefUser < Cheffish::ActorProviderBase
|
8
|
-
provides :chef_user
|
9
|
-
|
10
|
-
def whyrun_supported?
|
11
|
-
true
|
12
|
-
end
|
13
|
-
|
14
|
-
action :create do
|
15
|
-
create_actor
|
16
|
-
end
|
17
|
-
|
18
|
-
action :delete do
|
19
|
-
delete_actor
|
20
|
-
end
|
21
|
-
|
22
|
-
#
|
23
|
-
# Helpers
|
24
|
-
#
|
25
|
-
# Gives us new_json, current_json, not_found_json, etc.
|
26
|
-
|
27
|
-
def actor_type
|
28
|
-
'user'
|
29
|
-
end
|
30
|
-
|
31
|
-
def actor_path
|
32
|
-
"#{rest.root_url}/users"
|
33
|
-
end
|
34
|
-
|
35
|
-
def resource_class
|
36
|
-
Chef::Resource::ChefUser
|
37
|
-
end
|
38
|
-
|
39
|
-
def data_handler
|
40
|
-
Chef::ChefFS::DataHandler::UserDataHandler.new
|
41
|
-
end
|
42
|
-
|
43
|
-
def keys
|
44
|
-
{
|
45
|
-
'name' => :name,
|
46
|
-
'username' => :name,
|
47
|
-
'display_name' => :display_name,
|
48
|
-
'admin' => :admin,
|
49
|
-
'email' => :email,
|
50
|
-
'password' => :password,
|
51
|
-
'external_authentication_uid' => :external_authentication_uid,
|
52
|
-
'recovery_authentication_enabled' => :recovery_authentication_enabled,
|
53
|
-
'public_key' => :source_key
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
1
|
+
require 'cheffish/actor_provider_base'
|
2
|
+
require 'chef/resource/chef_user'
|
3
|
+
require 'chef/chef_fs/data_handler/user_data_handler'
|
4
|
+
|
5
|
+
class Chef
|
6
|
+
class Provider
|
7
|
+
class ChefUser < Cheffish::ActorProviderBase
|
8
|
+
provides :chef_user
|
9
|
+
|
10
|
+
def whyrun_supported?
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
action :create do
|
15
|
+
create_actor
|
16
|
+
end
|
17
|
+
|
18
|
+
action :delete do
|
19
|
+
delete_actor
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Helpers
|
24
|
+
#
|
25
|
+
# Gives us new_json, current_json, not_found_json, etc.
|
26
|
+
|
27
|
+
def actor_type
|
28
|
+
'user'
|
29
|
+
end
|
30
|
+
|
31
|
+
def actor_path
|
32
|
+
"#{rest.root_url}/users"
|
33
|
+
end
|
34
|
+
|
35
|
+
def resource_class
|
36
|
+
Chef::Resource::ChefUser
|
37
|
+
end
|
38
|
+
|
39
|
+
def data_handler
|
40
|
+
Chef::ChefFS::DataHandler::UserDataHandler.new
|
41
|
+
end
|
42
|
+
|
43
|
+
def keys
|
44
|
+
{
|
45
|
+
'name' => :name,
|
46
|
+
'username' => :name,
|
47
|
+
'display_name' => :display_name,
|
48
|
+
'admin' => :admin,
|
49
|
+
'email' => :email,
|
50
|
+
'password' => :password,
|
51
|
+
'external_authentication_uid' => :external_authentication_uid,
|
52
|
+
'recovery_authentication_enabled' => :recovery_authentication_enabled,
|
53
|
+
'public_key' => :source_key
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|