Class: Chef::Resource::ChefRole

Inherits:
Cheffish::BaseResource show all
Defined in:
lib/chef/resource/chef_role.rb

Constant Summary

Constants included from Cheffish::BaseProperties

Cheffish::BaseProperties::ArrayType

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Cheffish::BaseProperties

#initialize

Instance Attribute Details

#default_attribute_modifiersObject (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



24
25
26
# File 'lib/chef/resource/chef_role.rb', line 24

def default_attribute_modifiers
  @default_attribute_modifiers
end

#override_attribute_modifiersObject (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



42
43
44
# File 'lib/chef/resource/chef_role.rb', line 42

def override_attribute_modifiers
  @override_attribute_modifiers
end

#run_list_modifiersObject (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 ”



59
60
61
# File 'lib/chef/resource/chef_role.rb', line 59

def run_list_modifiers
  @run_list_modifiers
end

#run_list_removersObject (readonly)

Returns the value of attribute run_list_removers.



60
61
62
# File 'lib/chef/resource/chef_role.rb', line 60

def run_list_removers
  @run_list_removers
end

Instance Method Details

#default_attribute(attribute_path, value = NOT_PASSED, &block) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/chef/resource/chef_role.rb', line 25

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



43
44
45
46
47
48
49
50
51
52
# File 'lib/chef/resource/chef_role.rb', line 43

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



61
62
63
64
65
66
67
68
# File 'lib/chef/resource/chef_role.rb', line 61

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



79
80
81
82
83
84
85
86
# File 'lib/chef/resource/chef_role.rb', line 79

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



88
89
90
91
92
93
94
95
# File 'lib/chef/resource/chef_role.rb', line 88

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



70
71
72
73
74
75
76
77
# File 'lib/chef/resource/chef_role.rb', line 70

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