cheffish 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -0
  3. data/LICENSE +201 -201
  4. data/README.md +120 -120
  5. data/Rakefile +23 -23
  6. data/cheffish.gemspec +26 -0
  7. data/lib/chef/provider/chef_acl.rb +446 -439
  8. data/lib/chef/provider/chef_client.rb +53 -53
  9. data/lib/chef/provider/chef_container.rb +55 -55
  10. data/lib/chef/provider/chef_data_bag.rb +55 -55
  11. data/lib/chef/provider/chef_data_bag_item.rb +278 -278
  12. data/lib/chef/provider/chef_environment.rb +83 -83
  13. data/lib/chef/provider/chef_group.rb +83 -83
  14. data/lib/chef/provider/chef_mirror.rb +169 -169
  15. data/lib/chef/provider/chef_node.rb +87 -87
  16. data/lib/chef/provider/chef_organization.rb +155 -155
  17. data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -46
  18. data/lib/chef/provider/chef_role.rb +84 -84
  19. data/lib/chef/provider/chef_user.rb +59 -59
  20. data/lib/chef/provider/private_key.rb +225 -225
  21. data/lib/chef/provider/public_key.rb +88 -88
  22. data/lib/chef/resource/chef_acl.rb +69 -69
  23. data/lib/chef/resource/chef_client.rb +48 -48
  24. data/lib/chef/resource/chef_container.rb +22 -22
  25. data/lib/chef/resource/chef_data_bag.rb +22 -22
  26. data/lib/chef/resource/chef_data_bag_item.rb +121 -121
  27. data/lib/chef/resource/chef_environment.rb +77 -77
  28. data/lib/chef/resource/chef_group.rb +53 -53
  29. data/lib/chef/resource/chef_mirror.rb +52 -52
  30. data/lib/chef/resource/chef_node.rb +22 -22
  31. data/lib/chef/resource/chef_organization.rb +69 -69
  32. data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -35
  33. data/lib/chef/resource/chef_role.rb +110 -110
  34. data/lib/chef/resource/chef_user.rb +56 -56
  35. data/lib/chef/resource/private_key.rb +48 -48
  36. data/lib/chef/resource/public_key.rb +25 -25
  37. data/lib/cheffish.rb +235 -235
  38. data/lib/cheffish/actor_provider_base.rb +131 -131
  39. data/lib/cheffish/basic_chef_client.rb +184 -184
  40. data/lib/cheffish/chef_provider_base.rb +246 -246
  41. data/lib/cheffish/chef_run.rb +162 -162
  42. data/lib/cheffish/chef_run_data.rb +19 -19
  43. data/lib/cheffish/chef_run_listener.rb +30 -30
  44. data/lib/cheffish/key_formatter.rb +113 -113
  45. data/lib/cheffish/merged_config.rb +98 -94
  46. data/lib/cheffish/recipe_dsl.rb +157 -157
  47. data/lib/cheffish/rspec.rb +8 -8
  48. data/lib/cheffish/rspec/chef_run_support.rb +83 -83
  49. data/lib/cheffish/rspec/matchers.rb +4 -4
  50. data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -16
  51. data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -15
  52. data/lib/cheffish/rspec/matchers/have_updated.rb +37 -37
  53. data/lib/cheffish/rspec/matchers/partially_match.rb +63 -63
  54. data/lib/cheffish/rspec/recipe_run_wrapper.rb +78 -78
  55. data/lib/cheffish/rspec/repository_support.rb +108 -108
  56. data/lib/cheffish/server_api.rb +52 -52
  57. data/lib/cheffish/version.rb +3 -3
  58. data/lib/cheffish/with_pattern.rb +21 -21
  59. data/spec/functional/fingerprint_spec.rb +64 -64
  60. data/spec/functional/merged_config_spec.rb +19 -19
  61. data/spec/functional/server_api_spec.rb +13 -13
  62. data/spec/integration/chef_acl_spec.rb +892 -879
  63. data/spec/integration/chef_client_spec.rb +105 -105
  64. data/spec/integration/chef_container_spec.rb +33 -33
  65. data/spec/integration/chef_group_spec.rb +309 -309
  66. data/spec/integration/chef_mirror_spec.rb +491 -491
  67. data/spec/integration/chef_node_spec.rb +786 -786
  68. data/spec/integration/chef_organization_spec.rb +226 -226
  69. data/spec/integration/chef_role_spec.rb +78 -78
  70. data/spec/integration/chef_user_spec.rb +85 -85
  71. data/spec/integration/private_key_spec.rb +399 -399
  72. data/spec/integration/recipe_dsl_spec.rb +28 -28
  73. data/spec/integration/rspec/converge_spec.rb +183 -183
  74. data/spec/support/key_support.rb +29 -29
  75. data/spec/support/spec_support.rb +15 -15
  76. data/spec/unit/get_private_key_spec.rb +131 -131
  77. data/spec/unit/recipe_run_wrapper_spec.rb +37 -37
  78. metadata +7 -5
@@ -1,22 +1,22 @@
1
- require 'cheffish'
2
- require 'chef/resource/lwrp_base'
3
-
4
- class Chef
5
- class Resource
6
- class ChefDataBag < Chef::Resource::LWRPBase
7
- self.resource_name = 'chef_data_bag'
8
-
9
- actions :create, :delete, :nothing
10
- default_action :create
11
-
12
- def initialize(*args)
13
- super
14
- chef_server run_context.cheffish.current_chef_server
15
- end
16
-
17
- attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
18
-
19
- attribute :chef_server, :kind_of => Hash
20
- end
21
- end
22
- end
1
+ require 'cheffish'
2
+ require 'chef/resource/lwrp_base'
3
+
4
+ class Chef
5
+ class Resource
6
+ class ChefDataBag < Chef::Resource::LWRPBase
7
+ self.resource_name = 'chef_data_bag'
8
+
9
+ actions :create, :delete, :nothing
10
+ default_action :create
11
+
12
+ def initialize(*args)
13
+ super
14
+ chef_server run_context.cheffish.current_chef_server
15
+ end
16
+
17
+ attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
18
+
19
+ attribute :chef_server, :kind_of => Hash
20
+ end
21
+ end
22
+ end
@@ -1,121 +1,121 @@
1
- require 'cheffish'
2
- require 'chef/config'
3
- require 'chef/resource/lwrp_base'
4
-
5
- class Chef
6
- class Resource
7
- class ChefDataBagItem < Chef::Resource::LWRPBase
8
- self.resource_name = 'chef_data_bag_item'
9
-
10
- actions :create, :delete, :nothing
11
- default_action :create
12
-
13
- def initialize(*args)
14
- super
15
- name @name
16
- if !data_bag
17
- data_bag run_context.cheffish.current_data_bag
18
- end
19
- if run_context.cheffish.current_data_bag_item_encryption
20
- @encrypt = true if run_context.cheffish.current_data_bag_item_encryption[:encrypt_all]
21
- @secret = run_context.cheffish.current_data_bag_item_encryption[:secret]
22
- @secret_path = run_context.cheffish.current_data_bag_item_encryption[:secret_path] || run_context.config[:encrypted_data_bag_secret]
23
- @encryption_cipher = run_context.cheffish.current_data_bag_item_encryption[:encryption_cipher]
24
- @encryption_version = run_context.cheffish.current_data_bag_item_encryption[:encryption_version] || run_context.config[:data_bag_encrypt_version]
25
- @old_secret = run_context.cheffish.current_data_bag_item_encryption[:old_secret]
26
- @old_secret_path = run_context.cheffish.current_data_bag_item_encryption[:old_secret_path]
27
- end
28
- chef_server run_context.cheffish.current_chef_server
29
- end
30
-
31
- def name(*args)
32
- result = super(*args)
33
- if args.size == 1
34
- parts = name.split('/')
35
- if parts.size == 1
36
- @id = parts[0]
37
- elsif parts.size == 2
38
- @data_bag = parts[0]
39
- @id = parts[1]
40
- else
41
- raise "Name #{args[0].inspect} must be a string with 1 or 2 parts, either 'id' or 'data_bag/id"
42
- end
43
- end
44
- result
45
- end
46
-
47
- # `NOT_PASSED` is defined in chef-12.5.0, this guard will ensure we
48
- # don't redefine it if it's already there
49
- NOT_PASSED = Object.new unless defined?(NOT_PASSED)
50
-
51
- def id(value = NOT_PASSED)
52
- if value == NOT_PASSED
53
- @id
54
- else
55
- @id = value
56
- name data_bag ? "#{data_bag}/#{id}" : id
57
- end
58
- end
59
- def data_bag(value = NOT_PASSED)
60
- if value == NOT_PASSED
61
- @data_bag
62
- else
63
- @data_bag = value
64
- name data_bag ? "#{data_bag}/#{id}" : id
65
- end
66
- end
67
- attribute :raw_data, :kind_of => Hash
68
-
69
- # If secret or secret_path are set, encrypt is assumed true. encrypt exists mainly for with_secret and with_secret_path
70
- attribute :encrypt, :kind_of => [TrueClass, FalseClass]
71
- #attribute :secret, :kind_of => String
72
- def secret(new_secret = nil)
73
- if !new_secret
74
- @secret
75
- else
76
- @secret = new_secret
77
- @encrypt = true if @encrypt.nil?
78
- end
79
- end
80
- #attribute :secret_path, :kind_of => String
81
- def secret_path(new_secret_path = nil)
82
- if !new_secret_path
83
- @secret_path
84
- else
85
- @secret_path = new_secret_path
86
- @encrypt = true if @encrypt.nil?
87
- end
88
- end
89
- attribute :encryption_version, :kind_of => Integer
90
-
91
- # Old secret (or secrets) to read the old data bag when we are changing keys and re-encrypting data
92
- attribute :old_secret, :kind_of => [String, Array]
93
- attribute :old_secret_path, :kind_of => [String, Array]
94
-
95
- # Specifies that this is a complete specification for the environment (i.e. attributes you don't specify will be
96
- # reset to their defaults)
97
- attribute :complete, :kind_of => [TrueClass, FalseClass]
98
-
99
- attribute :raw_json, :kind_of => Hash
100
- attribute :chef_server, :kind_of => Hash
101
-
102
- # value 'ip_address', '127.0.0.1'
103
- # value [ 'pushy', 'port' ], '9000'
104
- # value 'ip_addresses' do |existing_value|
105
- # (existing_value || []) + [ '127.0.0.1' ]
106
- # end
107
- # value 'ip_address', :delete
108
- attr_reader :raw_data_modifiers
109
- def value(raw_data_path, value=NOT_PASSED, &block)
110
- @raw_data_modifiers ||= []
111
- if value != NOT_PASSED
112
- @raw_data_modifiers << [ raw_data_path, value ]
113
- elsif block
114
- @raw_data_modifiers << [ raw_data_path, block ]
115
- else
116
- raise "value requires either a value or a block"
117
- end
118
- end
119
- end
120
- end
121
- end
1
+ require 'cheffish'
2
+ require 'chef/config'
3
+ require 'chef/resource/lwrp_base'
4
+
5
+ class Chef
6
+ class Resource
7
+ class ChefDataBagItem < Chef::Resource::LWRPBase
8
+ self.resource_name = 'chef_data_bag_item'
9
+
10
+ actions :create, :delete, :nothing
11
+ default_action :create
12
+
13
+ def initialize(*args)
14
+ super
15
+ name @name
16
+ if !data_bag
17
+ data_bag run_context.cheffish.current_data_bag
18
+ end
19
+ if run_context.cheffish.current_data_bag_item_encryption
20
+ @encrypt = true if run_context.cheffish.current_data_bag_item_encryption[:encrypt_all]
21
+ @secret = run_context.cheffish.current_data_bag_item_encryption[:secret]
22
+ @secret_path = run_context.cheffish.current_data_bag_item_encryption[:secret_path] || run_context.config[:encrypted_data_bag_secret]
23
+ @encryption_cipher = run_context.cheffish.current_data_bag_item_encryption[:encryption_cipher]
24
+ @encryption_version = run_context.cheffish.current_data_bag_item_encryption[:encryption_version] || run_context.config[:data_bag_encrypt_version]
25
+ @old_secret = run_context.cheffish.current_data_bag_item_encryption[:old_secret]
26
+ @old_secret_path = run_context.cheffish.current_data_bag_item_encryption[:old_secret_path]
27
+ end
28
+ chef_server run_context.cheffish.current_chef_server
29
+ end
30
+
31
+ def name(*args)
32
+ result = super(*args)
33
+ if args.size == 1
34
+ parts = name.split('/')
35
+ if parts.size == 1
36
+ @id = parts[0]
37
+ elsif parts.size == 2
38
+ @data_bag = parts[0]
39
+ @id = parts[1]
40
+ else
41
+ raise "Name #{args[0].inspect} must be a string with 1 or 2 parts, either 'id' or 'data_bag/id"
42
+ end
43
+ end
44
+ result
45
+ end
46
+
47
+ # `NOT_PASSED` is defined in chef-12.5.0, this guard will ensure we
48
+ # don't redefine it if it's already there
49
+ NOT_PASSED = Object.new unless defined?(NOT_PASSED)
50
+
51
+ def id(value = NOT_PASSED)
52
+ if value == NOT_PASSED
53
+ @id
54
+ else
55
+ @id = value
56
+ name data_bag ? "#{data_bag}/#{id}" : id
57
+ end
58
+ end
59
+ def data_bag(value = NOT_PASSED)
60
+ if value == NOT_PASSED
61
+ @data_bag
62
+ else
63
+ @data_bag = value
64
+ name data_bag ? "#{data_bag}/#{id}" : id
65
+ end
66
+ end
67
+ attribute :raw_data, :kind_of => Hash
68
+
69
+ # If secret or secret_path are set, encrypt is assumed true. encrypt exists mainly for with_secret and with_secret_path
70
+ attribute :encrypt, :kind_of => [TrueClass, FalseClass]
71
+ #attribute :secret, :kind_of => String
72
+ def secret(new_secret = nil)
73
+ if !new_secret
74
+ @secret
75
+ else
76
+ @secret = new_secret
77
+ @encrypt = true if @encrypt.nil?
78
+ end
79
+ end
80
+ #attribute :secret_path, :kind_of => String
81
+ def secret_path(new_secret_path = nil)
82
+ if !new_secret_path
83
+ @secret_path
84
+ else
85
+ @secret_path = new_secret_path
86
+ @encrypt = true if @encrypt.nil?
87
+ end
88
+ end
89
+ attribute :encryption_version, :kind_of => Integer
90
+
91
+ # Old secret (or secrets) to read the old data bag when we are changing keys and re-encrypting data
92
+ attribute :old_secret, :kind_of => [String, Array]
93
+ attribute :old_secret_path, :kind_of => [String, Array]
94
+
95
+ # Specifies that this is a complete specification for the environment (i.e. attributes you don't specify will be
96
+ # reset to their defaults)
97
+ attribute :complete, :kind_of => [TrueClass, FalseClass]
98
+
99
+ attribute :raw_json, :kind_of => Hash
100
+ attribute :chef_server, :kind_of => Hash
101
+
102
+ # value 'ip_address', '127.0.0.1'
103
+ # value [ 'pushy', 'port' ], '9000'
104
+ # value 'ip_addresses' do |existing_value|
105
+ # (existing_value || []) + [ '127.0.0.1' ]
106
+ # end
107
+ # value 'ip_address', :delete
108
+ attr_reader :raw_data_modifiers
109
+ def value(raw_data_path, value=NOT_PASSED, &block)
110
+ @raw_data_modifiers ||= []
111
+ if value != NOT_PASSED
112
+ @raw_data_modifiers << [ raw_data_path, value ]
113
+ elsif block
114
+ @raw_data_modifiers << [ raw_data_path, block ]
115
+ else
116
+ raise "value requires either a value or a block"
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -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