cheffish 1.3.1 → 1.4.0
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/LICENSE +201 -201
- data/README.md +120 -117
- data/Rakefile +23 -23
- data/lib/chef/provider/chef_acl.rb +439 -434
- data/lib/chef/provider/chef_client.rb +53 -48
- data/lib/chef/provider/chef_container.rb +55 -50
- data/lib/chef/provider/chef_data_bag.rb +55 -50
- data/lib/chef/provider/chef_data_bag_item.rb +278 -273
- data/lib/chef/provider/chef_environment.rb +83 -78
- data/lib/chef/provider/chef_group.rb +83 -78
- data/lib/chef/provider/chef_mirror.rb +169 -164
- data/lib/chef/provider/chef_node.rb +87 -82
- data/lib/chef/provider/chef_organization.rb +155 -150
- data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -41
- data/lib/chef/provider/chef_role.rb +84 -79
- data/lib/chef/provider/chef_user.rb +59 -54
- data/lib/chef/provider/private_key.rb +225 -220
- data/lib/chef/provider/public_key.rb +88 -82
- data/lib/chef/resource/chef_acl.rb +69 -65
- data/lib/chef/resource/chef_client.rb +48 -44
- data/lib/chef/resource/chef_container.rb +22 -18
- data/lib/chef/resource/chef_data_bag.rb +22 -18
- data/lib/chef/resource/chef_data_bag_item.rb +121 -114
- data/lib/chef/resource/chef_environment.rb +77 -71
- data/lib/chef/resource/chef_group.rb +53 -49
- data/lib/chef/resource/chef_mirror.rb +52 -48
- data/lib/chef/resource/chef_node.rb +22 -18
- data/lib/chef/resource/chef_organization.rb +69 -64
- data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -31
- data/lib/chef/resource/chef_role.rb +110 -104
- data/lib/chef/resource/chef_user.rb +56 -52
- data/lib/chef/resource/private_key.rb +48 -44
- data/lib/chef/resource/public_key.rb +25 -21
- data/lib/cheffish.rb +235 -233
- 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 -155
- 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.rb +8 -8
- data/lib/cheffish/rspec/chef_run_support.rb +83 -83
- data/lib/cheffish/rspec/matchers.rb +4 -4
- 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/recipe_run_wrapper.rb +59 -47
- data/lib/cheffish/rspec/repository_support.rb +108 -108
- data/lib/cheffish/server_api.rb +52 -52
- data/lib/cheffish/version.rb +3 -3
- data/lib/cheffish/with_pattern.rb +21 -21
- 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 -0
- 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 -0
- metadata +8 -5
@@ -1,48 +1,52 @@
|
|
1
|
-
require 'cheffish'
|
2
|
-
require 'chef/resource/lwrp_base'
|
3
|
-
|
4
|
-
class Chef
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
1
|
+
require 'cheffish'
|
2
|
+
require 'chef/resource/lwrp_base'
|
3
|
+
|
4
|
+
class Chef
|
5
|
+
class Resource
|
6
|
+
class ChefMirror < Chef::Resource::LWRPBase
|
7
|
+
self.resource_name = 'chef_mirror'
|
8
|
+
|
9
|
+
actions :upload, :download, :nothing
|
10
|
+
default_action :nothing
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
super
|
14
|
+
chef_server run_context.cheffish.current_chef_server
|
15
|
+
end
|
16
|
+
|
17
|
+
# Path of the data to mirror, e.g. nodes, nodes/*, nodes/mynode,
|
18
|
+
# */*, **, roles/base, data/secrets, cookbooks/apache2, etc.
|
19
|
+
attribute :path, :kind_of => String, :name_attribute => true
|
20
|
+
|
21
|
+
# Local path. Can be a string (top level of repository) or hash
|
22
|
+
# (:chef_repo_path, :node_path, etc.)
|
23
|
+
# If neither chef_repo_path nor versioned_cookbooks are set, they default to their
|
24
|
+
# Chef::Config values. If chef_repo_path is set but versioned_cookbooks is not,
|
25
|
+
# versioned_cookbooks defaults to true.
|
26
|
+
attribute :chef_repo_path, :kind_of => [ String, Hash ]
|
27
|
+
|
28
|
+
# Whether the repo path should contain cookbooks with versioned names,
|
29
|
+
# i.e. cookbooks/mysql-1.0.0, cookbooks/mysql-1.2.0, etc.
|
30
|
+
# Defaults to true if chef_repo_path is specified, or to Chef::Config.versioned_cookbooks otherwise.
|
31
|
+
attribute :versioned_cookbooks, :kind_of => [ TrueClass, FalseClass ]
|
32
|
+
|
33
|
+
# Chef server
|
34
|
+
attribute :chef_server, :kind_of => Hash
|
35
|
+
|
36
|
+
# Whether to purge deleted things: if we do not have cookbooks/x locally and we
|
37
|
+
# *do* have cookbooks/x remotely, then :upload with purge will delete it.
|
38
|
+
# Defaults to false.
|
39
|
+
attribute :purge, :kind_of => [ TrueClass, FalseClass ]
|
40
|
+
|
41
|
+
# Whether to freeze cookbooks on upload
|
42
|
+
attribute :freeze, :kind_of => [ TrueClass, FalseClass ]
|
43
|
+
|
44
|
+
# If this is true, only new files will be copied. File contents will not be
|
45
|
+
# diffed, so changed files will never be uploaded.
|
46
|
+
attribute :no_diff, :kind_of => [ TrueClass, FalseClass ]
|
47
|
+
|
48
|
+
# Number of parallel threads to list/upload/download with. Defaults to 10.
|
49
|
+
attribute :concurrency, :kind_of => Integer
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,18 +1,22 @@
|
|
1
|
-
require 'cheffish'
|
2
|
-
require 'chef/resource/lwrp_base'
|
3
|
-
|
4
|
-
class Chef
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
require 'cheffish'
|
2
|
+
require 'chef/resource/lwrp_base'
|
3
|
+
|
4
|
+
class Chef
|
5
|
+
class Resource
|
6
|
+
class ChefNode < Chef::Resource::LWRPBase
|
7
|
+
self.resource_name = 'chef_node'
|
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_environment run_context.cheffish.current_environment
|
16
|
+
chef_server run_context.cheffish.current_chef_server
|
17
|
+
end
|
18
|
+
|
19
|
+
Cheffish.node_attributes(self)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,64 +1,69 @@
|
|
1
|
-
require 'cheffish'
|
2
|
-
require 'chef/resource/lwrp_base'
|
3
|
-
require 'chef/run_list/run_list_item'
|
4
|
-
|
5
|
-
class Chef
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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 ChefOrganization < Chef::Resource::LWRPBase
|
8
|
+
self.resource_name = 'chef_organization'
|
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
|
+
@invites = nil
|
18
|
+
@members = nil
|
19
|
+
@remove_members = []
|
20
|
+
end
|
21
|
+
|
22
|
+
attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
|
23
|
+
attribute :full_name, :kind_of => String
|
24
|
+
|
25
|
+
# A list of users who must at least be invited to the org (but may already be
|
26
|
+
# members). Invites will be sent to users who are not already invited/in the org.
|
27
|
+
def invites(*users)
|
28
|
+
if users.size == 0
|
29
|
+
@invites || []
|
30
|
+
else
|
31
|
+
@invites ||= []
|
32
|
+
@invites |= users.flatten
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def invites_specified?
|
37
|
+
!!@invites
|
38
|
+
end
|
39
|
+
|
40
|
+
# A list of users who must be members of the org. This will use the
|
41
|
+
# new Chef 12 POST /organizations/ORG/users endpoint to add them
|
42
|
+
# directly to the org. If you do not have permission to perform
|
43
|
+
# this operation, and the users are not a part of the org, the
|
44
|
+
# resource update will fail.
|
45
|
+
def members(*users)
|
46
|
+
if users.size == 0
|
47
|
+
@members || []
|
48
|
+
else
|
49
|
+
@members ||= []
|
50
|
+
@members |= users.flatten
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def members_specified?
|
55
|
+
!!@members
|
56
|
+
end
|
57
|
+
|
58
|
+
# A list of users who must not be members of the org. These users will be removed
|
59
|
+
# from the org and invites will be revoked (if any).
|
60
|
+
def remove_members(*users)
|
61
|
+
users.size == 0 ? @remove_members : (@remove_members |= users.flatten)
|
62
|
+
end
|
63
|
+
|
64
|
+
attribute :complete, :kind_of => [ TrueClass, FalseClass ]
|
65
|
+
attribute :raw_json, :kind_of => Hash
|
66
|
+
attribute :chef_server, :kind_of => Hash
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -1,31 +1,35 @@
|
|
1
|
-
require 'chef/resource/lwrp_base'
|
2
|
-
|
3
|
-
class Chef
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
1
|
+
require 'chef/resource/lwrp_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Resource
|
5
|
+
class ChefResolvedCookbooks < Chef::Resource::LWRPBase
|
6
|
+
self.resource_name = 'chef_resolved_cookbooks'
|
7
|
+
|
8
|
+
actions :resolve, :nothing
|
9
|
+
default_action :resolve
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
super
|
13
|
+
require 'berkshelf'
|
14
|
+
berksfile Berkshelf::Berksfile.new('/tmp/Berksfile')
|
15
|
+
chef_server run_context.cheffish.current_chef_server
|
16
|
+
@cookbooks_from = []
|
17
|
+
end
|
18
|
+
|
19
|
+
extend Forwardable
|
20
|
+
|
21
|
+
def_delegators :@berksfile, :cookbook, :extension, :group, :metadata, :source
|
22
|
+
|
23
|
+
def cookbooks_from(path = nil)
|
24
|
+
if path
|
25
|
+
@cookbooks_from << path
|
26
|
+
else
|
27
|
+
@cookbooks_from
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
attribute :berksfile
|
32
|
+
attribute :chef_server
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,104 +1,110 @@
|
|
1
|
-
require 'cheffish'
|
2
|
-
require 'chef/resource/lwrp_base'
|
3
|
-
require 'chef/run_list/run_list_item'
|
4
|
-
|
5
|
-
class Chef
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
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
|