Class: Chef::Resource::ChefRole
- Inherits:
-
LWRPBase
- Object
- LWRPBase
- Chef::Resource::ChefRole
- Defined in:
- lib/chef/resource/chef_role.rb
Constant Summary collapse
- NOT_PASSED =
Object.new
Instance Attribute Summary collapse
-
#default_attribute_modifiers ⇒ Object
readonly
default_attribute ‘ip_address’, ‘127.0.0.1’ default_attribute [ ‘pushy’, ‘port’ ], ‘9000’ default_attribute ‘ip_addresses’ do |existing_value| (existing_value || []) + [ ‘127.0.0.1’ ] end default_attribute ‘ip_address’, :delete.
-
#override_attribute_modifiers ⇒ Object
readonly
override_attribute ‘ip_address’, ‘127.0.0.1’ override_attribute [ ‘pushy’, ‘port’ ], ‘9000’ override_attribute ‘ip_addresses’ do |existing_value| (existing_value || []) + [ ‘127.0.0.1’ ] end override_attribute ‘ip_address’, :delete.
-
#run_list_modifiers ⇒ Object
readonly
Order matters–if two things here are in the wrong order, they will be flipped in the run list recipe ‘apache’, ‘mysql’ recipe ‘recipe@version’ recipe ‘recipe’ role ”.
-
#run_list_removers ⇒ Object
readonly
Returns the value of attribute run_list_removers.
Instance Method Summary collapse
- #default_attribute(attribute_path, value = NOT_PASSED, &block) ⇒ Object
-
#initialize(*args) ⇒ ChefRole
constructor
Grab environment from with_environment.
- #override_attribute(attribute_path, value = NOT_PASSED, &block) ⇒ Object
- #recipe(*recipes) ⇒ Object
- #remove_recipe(*recipes) ⇒ Object
- #remove_role(*roles) ⇒ Object
- #role(*roles) ⇒ Object
Constructor Details
#initialize(*args) ⇒ ChefRole
Grab environment from with_environment
12 13 14 15 |
# File 'lib/chef/resource/chef_role.rb', line 12 def initialize(*args) super chef_server run_context.cheffish.current_chef_server end |
Instance Attribute Details
#default_attribute_modifiers ⇒ Object (readonly)
default_attribute ‘ip_address’, ‘127.0.0.1’ default_attribute [ ‘pushy’, ‘port’ ], ‘9000’ default_attribute ‘ip_addresses’ do |existing_value|
(existing_value || []) + [ '127.0.0.1' ]
end default_attribute ‘ip_address’, :delete
39 40 41 |
# File 'lib/chef/resource/chef_role.rb', line 39 def default_attribute_modifiers @default_attribute_modifiers end |
#override_attribute_modifiers ⇒ Object (readonly)
override_attribute ‘ip_address’, ‘127.0.0.1’ override_attribute [ ‘pushy’, ‘port’ ], ‘9000’ override_attribute ‘ip_addresses’ do |existing_value|
(existing_value || []) + [ '127.0.0.1' ]
end override_attribute ‘ip_address’, :delete
57 58 59 |
# File 'lib/chef/resource/chef_role.rb', line 57 def override_attribute_modifiers @override_attribute_modifiers end |
#run_list_modifiers ⇒ Object (readonly)
Order matters–if two things here are in the wrong order, they will be flipped in the run list recipe ‘apache’, ‘mysql’ recipe ‘recipe@version’ recipe ‘recipe’ role ”
74 75 76 |
# File 'lib/chef/resource/chef_role.rb', line 74 def run_list_modifiers @run_list_modifiers end |
#run_list_removers ⇒ Object (readonly)
Returns the value of attribute run_list_removers.
75 76 77 |
# File 'lib/chef/resource/chef_role.rb', line 75 def run_list_removers @run_list_removers end |
Instance Method Details
#default_attribute(attribute_path, value = NOT_PASSED, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chef/resource/chef_role.rb', line 40 def default_attribute(attribute_path, value=NOT_PASSED, &block) @default_attribute_modifiers ||= [] if value != NOT_PASSED @default_attribute_modifiers << [ attribute_path, value ] elsif block @default_attribute_modifiers << [ attribute_path, block ] else raise "default_attribute requires either a value or a block" end end |
#override_attribute(attribute_path, value = NOT_PASSED, &block) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/chef/resource/chef_role.rb', line 58 def override_attribute(attribute_path, value=NOT_PASSED, &block) @override_attribute_modifiers ||= [] if value != NOT_PASSED @override_attribute_modifiers << [ attribute_path, value ] elsif block @override_attribute_modifiers << [ attribute_path, block ] else raise "override_attribute requires either a value or a block" end end |
#recipe(*recipes) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/chef/resource/chef_role.rb', line 76 def recipe(*recipes) if recipes.size == 0 raise ArgumentError, "At least one recipe must be specified" end @run_list_modifiers ||= [] @run_list_modifiers += recipes.map { |recipe| Chef::RunList::RunListItem.new("recipe[#{recipe}]") } end |
#remove_recipe(*recipes) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/chef/resource/chef_role.rb', line 90 def remove_recipe(*recipes) if recipes.size == 0 raise ArgumentError, "At least one recipe must be specified" end @run_list_removers ||= [] @run_list_removers += recipes.map { |recipe| Chef::RunList::RunListItem.new("recipe[#{recipe}]") } end |
#remove_role(*roles) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/chef/resource/chef_role.rb', line 97 def remove_role(*roles) if roles.size == 0 raise ArgumentError, "At least one role must be specified" end @run_list_removers ||= [] @run_list_removers += roles.map { |recipe| Chef::RunList::RunListItem.new("role[#{role}]") } end |
#role(*roles) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/chef/resource/chef_role.rb', line 83 def role(*roles) if roles.size == 0 raise ArgumentError, "At least one role must be specified" end @run_list_modifiers ||= [] @run_list_modifiers += roles.map { |role| Chef::RunList::RunListItem.new("role[#{role}]") } end |