How to force immediate execution of LWRP calls?


#1

I have a recipe I’m working on that installs a system of software to Windows machines. I’ve written a LWRP to handle installing and uninstalling the Windows services that we use. There are up to a dozen that can be installed on a client machine, depending on its role, etc. I have the details of the services in a hash in the recipe attributes, and am iterating through that, calling the uninstall and install LWRPs. I need to do things in a specific order:

  1. Uninstall services
  2. Modify files, permissions, user accounts, etc.
  3. Install services

Currently, the chef-client (Chef 11.2) run is running all of the install/uninstall calls together at the end of the run.

How can I force execution in the order calls are made in the recipe?

I’ve looked at notifications, but it seems very clunky to have to explicitly define each resource with no action, and then do some kind of call with a ‘notify :install’…

Suggestions from the hive mind?

Thanks!

-Pete


#2

You can ensure your ordering with notifications and immediate actions

foo_resource “foo” do
notifies :create, “template[bar]”, :immediately
end

see http://docs.opscode.com/resource_common_notifications.html

On Thu, Mar 21, 2013 at 11:52 AM, Peter Loron peterl@standingwave.orgwrote:

I have a recipe I’m working on that installs a system of software to
Windows machines. I’ve written a LWRP to handle installing and uninstalling
the Windows services that we use. There are up to a dozen that can be
installed on a client machine, depending on its role, etc. I have the
details of the services in a hash in the recipe attributes, and am
iterating through that, calling the uninstall and install LWRPs. I need to
do things in a specific order:

  1. Uninstall services
  2. Modify files, permissions, user accounts, etc.
  3. Install services

Currently, the chef-client (Chef 11.2) run is running all of the
install/uninstall calls together at the end of the run.

How can I force execution in the order calls are made in the recipe?

I’ve looked at notifications, but it seems very clunky to have to
explicitly define each resource with no action, and then do some kind of
call with a ‘notify :install’…

Suggestions from the hive mind?

Thanks!

-Pete