Recipes execution order

Hello,

I have a recipe like this, using Chef 12.21:

include_recipe 'websphere-mq::91'

[....]

execute "Configuring Queue Manager objects, queues, channels, listerners, etc." do
 environment ({ 'HOME' => ::Dir.home('mqm'), 'USER' => 'mqm' })
 command "su - mqm -c 'runmqsc < /opt/mqm/saveqm/file.mqsc > /opt/mqm/saveqm/file.log'; echo \"OK\""
end

When I run, the recipe broke with this:

  ArgumentError
  -------------
  user mqm doesn't exist

Yea, this user does not exist yes, it supposed to be created in the very first include.
How can I fix this? :slight_smile:

Thanks!!

you'd need to delay evaluation of the environment with lazy {} as described here: https://docs.chef.io/resource_common.html#lazy-evaluation . ::Dir.home is calculated based on the state at the beginning of the run, unless you delay it.