cheffish 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/README.md +120 -117
  4. data/Rakefile +23 -23
  5. data/lib/chef/provider/chef_acl.rb +439 -434
  6. data/lib/chef/provider/chef_client.rb +53 -48
  7. data/lib/chef/provider/chef_container.rb +55 -50
  8. data/lib/chef/provider/chef_data_bag.rb +55 -50
  9. data/lib/chef/provider/chef_data_bag_item.rb +278 -273
  10. data/lib/chef/provider/chef_environment.rb +83 -78
  11. data/lib/chef/provider/chef_group.rb +83 -78
  12. data/lib/chef/provider/chef_mirror.rb +169 -164
  13. data/lib/chef/provider/chef_node.rb +87 -82
  14. data/lib/chef/provider/chef_organization.rb +155 -150
  15. data/lib/chef/provider/chef_resolved_cookbooks.rb +46 -41
  16. data/lib/chef/provider/chef_role.rb +84 -79
  17. data/lib/chef/provider/chef_user.rb +59 -54
  18. data/lib/chef/provider/private_key.rb +225 -220
  19. data/lib/chef/provider/public_key.rb +88 -82
  20. data/lib/chef/resource/chef_acl.rb +69 -65
  21. data/lib/chef/resource/chef_client.rb +48 -44
  22. data/lib/chef/resource/chef_container.rb +22 -18
  23. data/lib/chef/resource/chef_data_bag.rb +22 -18
  24. data/lib/chef/resource/chef_data_bag_item.rb +121 -114
  25. data/lib/chef/resource/chef_environment.rb +77 -71
  26. data/lib/chef/resource/chef_group.rb +53 -49
  27. data/lib/chef/resource/chef_mirror.rb +52 -48
  28. data/lib/chef/resource/chef_node.rb +22 -18
  29. data/lib/chef/resource/chef_organization.rb +69 -64
  30. data/lib/chef/resource/chef_resolved_cookbooks.rb +35 -31
  31. data/lib/chef/resource/chef_role.rb +110 -104
  32. data/lib/chef/resource/chef_user.rb +56 -52
  33. data/lib/chef/resource/private_key.rb +48 -44
  34. data/lib/chef/resource/public_key.rb +25 -21
  35. data/lib/cheffish.rb +235 -233
  36. data/lib/cheffish/actor_provider_base.rb +131 -131
  37. data/lib/cheffish/basic_chef_client.rb +184 -184
  38. data/lib/cheffish/chef_provider_base.rb +246 -246
  39. data/lib/cheffish/chef_run.rb +162 -155
  40. data/lib/cheffish/chef_run_data.rb +19 -19
  41. data/lib/cheffish/chef_run_listener.rb +30 -30
  42. data/lib/cheffish/key_formatter.rb +113 -113
  43. data/lib/cheffish/merged_config.rb +94 -94
  44. data/lib/cheffish/recipe_dsl.rb +157 -157
  45. data/lib/cheffish/rspec.rb +8 -8
  46. data/lib/cheffish/rspec/chef_run_support.rb +83 -83
  47. data/lib/cheffish/rspec/matchers.rb +4 -4
  48. data/lib/cheffish/rspec/matchers/be_idempotent.rb +16 -16
  49. data/lib/cheffish/rspec/matchers/emit_no_warnings_or_errors.rb +15 -15
  50. data/lib/cheffish/rspec/matchers/have_updated.rb +37 -37
  51. data/lib/cheffish/rspec/matchers/partially_match.rb +63 -63
  52. data/lib/cheffish/rspec/recipe_run_wrapper.rb +59 -47
  53. data/lib/cheffish/rspec/repository_support.rb +108 -108
  54. data/lib/cheffish/server_api.rb +52 -52
  55. data/lib/cheffish/version.rb +3 -3
  56. data/lib/cheffish/with_pattern.rb +21 -21
  57. data/spec/functional/fingerprint_spec.rb +64 -64
  58. data/spec/functional/merged_config_spec.rb +19 -19
  59. data/spec/functional/server_api_spec.rb +13 -13
  60. data/spec/integration/chef_acl_spec.rb +879 -879
  61. data/spec/integration/chef_client_spec.rb +105 -105
  62. data/spec/integration/chef_container_spec.rb +33 -33
  63. data/spec/integration/chef_group_spec.rb +309 -309
  64. data/spec/integration/chef_mirror_spec.rb +491 -491
  65. data/spec/integration/chef_node_spec.rb +786 -786
  66. data/spec/integration/chef_organization_spec.rb +226 -226
  67. data/spec/integration/chef_role_spec.rb +78 -0
  68. data/spec/integration/chef_user_spec.rb +85 -85
  69. data/spec/integration/private_key_spec.rb +399 -399
  70. data/spec/integration/recipe_dsl_spec.rb +28 -28
  71. data/spec/integration/rspec/converge_spec.rb +183 -183
  72. data/spec/support/key_support.rb +29 -29
  73. data/spec/support/spec_support.rb +15 -15
  74. data/spec/unit/get_private_key_spec.rb +131 -131
  75. data/spec/unit/recipe_run_wrapper_spec.rb +37 -0
  76. metadata +8 -5
@@ -1,48 +1,52 @@
1
- require 'cheffish'
2
- require 'chef/resource/lwrp_base'
3
-
4
- class Chef::Resource::ChefMirror < Chef::Resource::LWRPBase
5
- self.resource_name = 'chef_mirror'
6
-
7
- actions :upload, :download, :nothing
8
- default_action :nothing
9
-
10
- def initialize(*args)
11
- super
12
- chef_server run_context.cheffish.current_chef_server
13
- end
14
-
15
- # Path of the data to mirror, e.g. nodes, nodes/*, nodes/mynode,
16
- # */*, **, roles/base, data/secrets, cookbooks/apache2, etc.
17
- attribute :path, :kind_of => String, :name_attribute => true
18
-
19
- # Local path. Can be a string (top level of repository) or hash
20
- # (:chef_repo_path, :node_path, etc.)
21
- # If neither chef_repo_path nor versioned_cookbooks are set, they default to their
22
- # Chef::Config values. If chef_repo_path is set but versioned_cookbooks is not,
23
- # versioned_cookbooks defaults to true.
24
- attribute :chef_repo_path, :kind_of => [ String, Hash ]
25
-
26
- # Whether the repo path should contain cookbooks with versioned names,
27
- # i.e. cookbooks/mysql-1.0.0, cookbooks/mysql-1.2.0, etc.
28
- # Defaults to true if chef_repo_path is specified, or to Chef::Config.versioned_cookbooks otherwise.
29
- attribute :versioned_cookbooks, :kind_of => [ TrueClass, FalseClass ]
30
-
31
- # Chef server
32
- attribute :chef_server, :kind_of => Hash
33
-
34
- # Whether to purge deleted things: if we do not have cookbooks/x locally and we
35
- # *do* have cookbooks/x remotely, then :upload with purge will delete it.
36
- # Defaults to false.
37
- attribute :purge, :kind_of => [ TrueClass, FalseClass ]
38
-
39
- # Whether to freeze cookbooks on upload
40
- attribute :freeze, :kind_of => [ TrueClass, FalseClass ]
41
-
42
- # If this is true, only new files will be copied. File contents will not be
43
- # diffed, so changed files will never be uploaded.
44
- attribute :no_diff, :kind_of => [ TrueClass, FalseClass ]
45
-
46
- # Number of parallel threads to list/upload/download with. Defaults to 10.
47
- attribute :concurrency, :kind_of => Integer
48
- 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,18 +1,22 @@
1
- require 'cheffish'
2
- require 'chef/resource/lwrp_base'
3
-
4
- class Chef::Resource::ChefNode < Chef::Resource::LWRPBase
5
- self.resource_name = 'chef_node'
6
-
7
- actions :create, :delete, :nothing
8
- default_action :create
9
-
10
- # Grab environment from with_environment
11
- def initialize(*args)
12
- super
13
- chef_environment run_context.cheffish.current_environment
14
- chef_server run_context.cheffish.current_chef_server
15
- end
16
-
17
- Cheffish.node_attributes(self)
18
- 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,64 +1,69 @@
1
- require 'cheffish'
2
- require 'chef/resource/lwrp_base'
3
- require 'chef/run_list/run_list_item'
4
-
5
- class Chef::Resource::ChefOrganization < Chef::Resource::LWRPBase
6
- self.resource_name = 'chef_organization'
7
-
8
- actions :create, :delete, :nothing
9
- default_action :create
10
-
11
- # Grab environment from with_environment
12
- def initialize(*args)
13
- super
14
- chef_server run_context.cheffish.current_chef_server
15
- @invites = nil
16
- @members = nil
17
- @remove_members = []
18
- end
19
-
20
- attribute :name, :kind_of => String, :regex => Cheffish::NAME_REGEX, :name_attribute => true
21
- attribute :full_name, :kind_of => String
22
-
23
- # A list of users who must at least be invited to the org (but may already be
24
- # members). Invites will be sent to users who are not already invited/in the org.
25
- def invites(*users)
26
- if users.size == 0
27
- @invites || []
28
- else
29
- @invites ||= []
30
- @invites |= users.flatten
31
- end
32
- end
33
-
34
- def invites_specified?
35
- !!@invites
36
- end
37
-
38
- # A list of users who must be members of the org. This will use the new Chef 12
39
- # POST /organizations/ORG/users/NAME endpoint to add them directly to the org.
40
- # If you do not have permission to perform this operation, and the users are not
41
- # a part of the org, the resource update will fail.
42
- def members(*users)
43
- if users.size == 0
44
- @members || []
45
- else
46
- @members ||= []
47
- @members |= users.flatten
48
- end
49
- end
50
-
51
- def members_specified?
52
- !!@members
53
- end
54
-
55
- # A list of users who must not be members of the org. These users will be removed
56
- # from the org and invites will be revoked (if any).
57
- def remove_members(*users)
58
- users.size == 0 ? @remove_members : (@remove_members |= users.flatten)
59
- end
60
-
61
- attribute :complete, :kind_of => [ TrueClass, FalseClass ]
62
- attribute :raw_json, :kind_of => Hash
63
- attribute :chef_server, :kind_of => Hash
64
- 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,31 +1,35 @@
1
- require 'chef/resource/lwrp_base'
2
-
3
- class Chef::Resource::ChefResolvedCookbooks < Chef::Resource::LWRPBase
4
- self.resource_name = 'chef_resolved_cookbooks'
5
-
6
- actions :resolve, :nothing
7
- default_action :resolve
8
-
9
- def initialize(*args)
10
- super
11
- require 'berkshelf'
12
- berksfile Berkshelf::Berksfile.new('/tmp/Berksfile')
13
- chef_server run_context.cheffish.current_chef_server
14
- @cookbooks_from = []
15
- end
16
-
17
- extend Forwardable
18
-
19
- def_delegators :@berksfile, :cookbook, :extension, :group, :metadata, :source
20
-
21
- def cookbooks_from(path = nil)
22
- if path
23
- @cookbooks_from << path
24
- else
25
- @cookbooks_from
26
- end
27
- end
28
-
29
- attribute :berksfile
30
- attribute :chef_server
31
- 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
@@ -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::Resource::ChefRole < Chef::Resource::LWRPBase
6
- self.resource_name = 'chef_role'
7
-
8
- actions :create, :delete, :nothing
9
- default_action :create
10
-
11
- # Grab environment from with_environment
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
- attribute :description, :kind_of => String
19
- attribute :run_list, :kind_of => Array # We should let them specify it as a series of parameters too
20
- attribute :env_run_lists, :kind_of => Hash
21
- attribute :default_attributes, :kind_of => Hash
22
- attribute :override_attributes, :kind_of => Hash
23
-
24
- # Specifies that this is a complete specification for the environment (i.e. attributes you don't specify will be
25
- # reset to their defaults)
26
- attribute :complete, :kind_of => [TrueClass, FalseClass]
27
-
28
- attribute :raw_json, :kind_of => Hash
29
- attribute :chef_server, :kind_of => Hash
30
-
31
- NOT_PASSED=Object.new
32
-
33
- # default_attribute 'ip_address', '127.0.0.1'
34
- # default_attribute [ 'pushy', 'port' ], '9000'
35
- # default_attribute 'ip_addresses' do |existing_value|
36
- # (existing_value || []) + [ '127.0.0.1' ]
37
- # end
38
- # default_attribute 'ip_address', :delete
39
- attr_reader :default_attribute_modifiers
40
- def default_attribute(attribute_path, value=NOT_PASSED, &block)
41
- @default_attribute_modifiers ||= []
42
- if value != NOT_PASSED
43
- @default_attribute_modifiers << [ attribute_path, value ]
44
- elsif block
45
- @default_attribute_modifiers << [ attribute_path, block ]
46
- else
47
- raise "default_attribute requires either a value or a block"
48
- end
49
- end
50
-
51
- # override_attribute 'ip_address', '127.0.0.1'
52
- # override_attribute [ 'pushy', 'port' ], '9000'
53
- # override_attribute 'ip_addresses' do |existing_value|
54
- # (existing_value || []) + [ '127.0.0.1' ]
55
- # end
56
- # override_attribute 'ip_address', :delete
57
- attr_reader :override_attribute_modifiers
58
- def override_attribute(attribute_path, value=NOT_PASSED, &block)
59
- @override_attribute_modifiers ||= []
60
- if value != NOT_PASSED
61
- @override_attribute_modifiers << [ attribute_path, value ]
62
- elsif block
63
- @override_attribute_modifiers << [ attribute_path, block ]
64
- else
65
- raise "override_attribute requires either a value or a block"
66
- end
67
- end
68
-
69
- # Order matters--if two things here are in the wrong order, they will be flipped in the run list
70
- # recipe 'apache', 'mysql'
71
- # recipe 'recipe@version'
72
- # recipe 'recipe'
73
- # role ''
74
- attr_reader :run_list_modifiers
75
- attr_reader :run_list_removers
76
- def recipe(*recipes)
77
- if recipes.size == 0
78
- raise ArgumentError, "At least one recipe must be specified"
79
- end
80
- @run_list_modifiers ||= []
81
- @run_list_modifiers += recipes.map { |recipe| Chef::RunList::RunListItem.new("recipe[#{recipe}]") }
82
- end
83
- def role(*roles)
84
- if roles.size == 0
85
- raise ArgumentError, "At least one role must be specified"
86
- end
87
- @run_list_modifiers ||= []
88
- @run_list_modifiers += roles.map { |role| Chef::RunList::RunListItem.new("role[#{role}]") }
89
- end
90
- def remove_recipe(*recipes)
91
- if recipes.size == 0
92
- raise ArgumentError, "At least one recipe must be specified"
93
- end
94
- @run_list_removers ||= []
95
- @run_list_removers += recipes.map { |recipe| Chef::RunList::RunListItem.new("recipe[#{recipe}]") }
96
- end
97
- def remove_role(*roles)
98
- if roles.size == 0
99
- raise ArgumentError, "At least one role must be specified"
100
- end
101
- @run_list_removers ||= []
102
- @run_list_removers += roles.map { |recipe| Chef::RunList::RunListItem.new("role[#{role}]") }
103
- end
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