cheffish 1.4.1 → 1.4.2
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 -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,77 +1,77 @@
|
|
1
|
-
require 'cheffish'
|
2
|
-
require 'chef/resource/lwrp_base'
|
3
|
-
require 'chef/environment'
|
4
|
-
|
5
|
-
class Chef
|
6
|
-
class Resource
|
7
|
-
class ChefEnvironment < Chef::Resource::LWRPBase
|
8
|
-
self.resource_name = 'chef_environment'
|
9
|
-
|
10
|
-
actions :create, :delete, :nothing
|
11
|
-
default_action :create
|
12
|
-
|
13
|
-
def initialize(*args)
|
14
|
-
super
|
15
|
-
chef_server run_context.cheffish.current_chef_server
|
16
|
-
end
|
17
|
-
|
18
|
-
attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
|
19
|
-
attribute :description, :kind_of => String
|
20
|
-
attribute :cookbook_versions, :kind_of => Hash, :callbacks => {
|
21
|
-
"should have valid cookbook versions" => lambda { |value| Chef::Environment.validate_cookbook_versions(value) }
|
22
|
-
}
|
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 'ip_address', '127.0.0.1'
|
38
|
-
# default [ 'pushy', 'port' ], '9000'
|
39
|
-
# default 'ip_addresses' do |existing_value|
|
40
|
-
# (existing_value || []) + [ '127.0.0.1' ]
|
41
|
-
# end
|
42
|
-
# default 'ip_address', :delete
|
43
|
-
attr_reader :default_attribute_modifiers
|
44
|
-
def default(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 requires either a value or a block"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# override 'ip_address', '127.0.0.1'
|
56
|
-
# override [ 'pushy', 'port' ], '9000'
|
57
|
-
# override 'ip_addresses' do |existing_value|
|
58
|
-
# (existing_value || []) + [ '127.0.0.1' ]
|
59
|
-
# end
|
60
|
-
# override 'ip_address', :delete
|
61
|
-
attr_reader :override_attribute_modifiers
|
62
|
-
def override(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 requires either a value or a block"
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
alias :attributes :default_attributes
|
74
|
-
alias :attribute :default
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
1
|
+
require 'cheffish'
|
2
|
+
require 'chef/resource/lwrp_base'
|
3
|
+
require 'chef/environment'
|
4
|
+
|
5
|
+
class Chef
|
6
|
+
class Resource
|
7
|
+
class ChefEnvironment < Chef::Resource::LWRPBase
|
8
|
+
self.resource_name = 'chef_environment'
|
9
|
+
|
10
|
+
actions :create, :delete, :nothing
|
11
|
+
default_action :create
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
chef_server run_context.cheffish.current_chef_server
|
16
|
+
end
|
17
|
+
|
18
|
+
attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
|
19
|
+
attribute :description, :kind_of => String
|
20
|
+
attribute :cookbook_versions, :kind_of => Hash, :callbacks => {
|
21
|
+
"should have valid cookbook versions" => lambda { |value| Chef::Environment.validate_cookbook_versions(value) }
|
22
|
+
}
|
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 'ip_address', '127.0.0.1'
|
38
|
+
# default [ 'pushy', 'port' ], '9000'
|
39
|
+
# default 'ip_addresses' do |existing_value|
|
40
|
+
# (existing_value || []) + [ '127.0.0.1' ]
|
41
|
+
# end
|
42
|
+
# default 'ip_address', :delete
|
43
|
+
attr_reader :default_attribute_modifiers
|
44
|
+
def default(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 requires either a value or a block"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# override 'ip_address', '127.0.0.1'
|
56
|
+
# override [ 'pushy', 'port' ], '9000'
|
57
|
+
# override 'ip_addresses' do |existing_value|
|
58
|
+
# (existing_value || []) + [ '127.0.0.1' ]
|
59
|
+
# end
|
60
|
+
# override 'ip_address', :delete
|
61
|
+
attr_reader :override_attribute_modifiers
|
62
|
+
def override(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 requires either a value or a block"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
alias :attributes :default_attributes
|
74
|
+
alias :attribute :default
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -1,53 +1,53 @@
|
|
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 ChefGroup < Chef::Resource::LWRPBase
|
8
|
-
self.resource_name = 'chef_group'
|
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
|
-
@users = []
|
18
|
-
@clients = []
|
19
|
-
@groups = []
|
20
|
-
@remove_users = []
|
21
|
-
@remove_clients = []
|
22
|
-
@remove_groups = []
|
23
|
-
end
|
24
|
-
|
25
|
-
attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
|
26
|
-
def users(*users)
|
27
|
-
users.size == 0 ? @users : (@users |= users.flatten)
|
28
|
-
end
|
29
|
-
def clients(*clients)
|
30
|
-
clients.size == 0 ? @clients : (@clients |= clients.flatten)
|
31
|
-
end
|
32
|
-
def groups(*groups)
|
33
|
-
groups.size == 0 ? @groups : (@groups |= groups.flatten)
|
34
|
-
end
|
35
|
-
def remove_users(*remove_users)
|
36
|
-
remove_users.size == 0 ? @remove_users : (@remove_users |= remove_users.flatten)
|
37
|
-
end
|
38
|
-
def remove_clients(*remove_clients)
|
39
|
-
remove_clients.size == 0 ? @remove_clients : (@remove_clients |= remove_clients.flatten)
|
40
|
-
end
|
41
|
-
def remove_groups(*remove_groups)
|
42
|
-
remove_groups.size == 0 ? @remove_groups : (@remove_groups |= remove_groups.flatten)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Specifies that this is a complete specification for the environment (i.e. attributes you don't specify will be
|
46
|
-
# reset to their defaults)
|
47
|
-
attribute :complete, :kind_of => [TrueClass, FalseClass]
|
48
|
-
|
49
|
-
attribute :raw_json, :kind_of => Hash
|
50
|
-
attribute :chef_server, :kind_of => Hash
|
51
|
-
end
|
52
|
-
end
|
53
|
-
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 ChefGroup < Chef::Resource::LWRPBase
|
8
|
+
self.resource_name = 'chef_group'
|
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
|
+
@users = []
|
18
|
+
@clients = []
|
19
|
+
@groups = []
|
20
|
+
@remove_users = []
|
21
|
+
@remove_clients = []
|
22
|
+
@remove_groups = []
|
23
|
+
end
|
24
|
+
|
25
|
+
attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
|
26
|
+
def users(*users)
|
27
|
+
users.size == 0 ? @users : (@users |= users.flatten)
|
28
|
+
end
|
29
|
+
def clients(*clients)
|
30
|
+
clients.size == 0 ? @clients : (@clients |= clients.flatten)
|
31
|
+
end
|
32
|
+
def groups(*groups)
|
33
|
+
groups.size == 0 ? @groups : (@groups |= groups.flatten)
|
34
|
+
end
|
35
|
+
def remove_users(*remove_users)
|
36
|
+
remove_users.size == 0 ? @remove_users : (@remove_users |= remove_users.flatten)
|
37
|
+
end
|
38
|
+
def remove_clients(*remove_clients)
|
39
|
+
remove_clients.size == 0 ? @remove_clients : (@remove_clients |= remove_clients.flatten)
|
40
|
+
end
|
41
|
+
def remove_groups(*remove_groups)
|
42
|
+
remove_groups.size == 0 ? @remove_groups : (@remove_groups |= remove_groups.flatten)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Specifies that this is a complete specification for the environment (i.e. attributes you don't specify will be
|
46
|
+
# reset to their defaults)
|
47
|
+
attribute :complete, :kind_of => [TrueClass, FalseClass]
|
48
|
+
|
49
|
+
attribute :raw_json, :kind_of => Hash
|
50
|
+
attribute :chef_server, :kind_of => Hash
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,52 +1,52 @@
|
|
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
|
+
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,22 +1,22 @@
|
|
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
|
+
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,69 +1,69 @@
|
|
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
|
+
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,35 +1,35 @@
|
|
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
|
+
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
|