Multiple actions in an LWRP

I’ve built an LWRP for the RedHat alternatives, picking out a couple
of the actions it looks like this:

action :install do
execute “alternatives-install-#{new_resource.name}” do
command = "/usr/sbin/alternatives --install"
command << " “#{new_resource.link}”"
command << " “#{new_resource.link_group}”"
command << " “#{new_resource.path}”"
command << " “#{new_resource.priority}”"
new_resource.slaves.each do |s|
command << " --slave “#{s[:link]}” “#{s[:name]}” “#{s[:path]}”"
end
command command
end
end

action :set do
execute “alternatives-set-#{new_resource.name}” do
command = "/usr/sbin/alternatives --set"
command << " “#{new_resource.link_group}” “#{new_resource.path}”"
command command
end
end

How do I make it work so you can invoke two actions from a single
instance of the resource? If I do

action [:install, :set]

inside a recipe, the set never seems to happen?


Alex Kiernan

On Tue, Nov 22, 2011 at 9:37 AM, Alex Kiernan alex.kiernan@gmail.com wrote:

I've built an LWRP for the RedHat alternatives, picking out a couple
of the actions it looks like this:

action :install do
execute "alternatives-install-#{new_resource.name}" do
command = "/usr/sbin/alternatives --install"
command << " "#{new_resource.link}""
command << " "#{new_resource.link_group}""
command << " "#{new_resource.path}""
command << " "#{new_resource.priority}""
new_resource.slaves.each do |s|
command << " --slave "#{s[:link]}" "#{s[:name]}" "#{s[:path]}""
end
command command
end
end

action :set do
execute "alternatives-set-#{new_resource.name}" do
command = "/usr/sbin/alternatives --set"
command << " "#{new_resource.link_group}" "#{new_resource.path}""
command command
end
end

How do I make it work so you can invoke two actions from a single
instance of the resource? If I do

action [:install, :set]

inside a recipe, the set never seems to happen?

Ignore me... operator error - it's working fine. The call to :set was
conditional on a condition which never fired :expressionless: