Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to get the rvm_passeneger recipe to work, I seem to having problems with the order of execution and variable/attribute scope.

https://github.com/fnichol/chef-rvm_passenger/blob/master/recipes/apache2.rb

The ruby block on line 35 executes after the apache_module LWRP request on line 73.

As I understand it when you have multiple recipes, all of the 'similar tasks' in this case 'apache_module' are converged from all of the run_list recipes at 'compilation time'. In my case I only have one recipe, rvm_passenger, but it includes 'apache2' and 'rvm'.

Looking at the debug logs the standard apache modules are installed at the same time as the additional passenger module. However, in my case, the ruby block defined on line 35 of the above recipe needs to run first because the configuration for the module is dependent on the value of an attribute defined inside the block.

I've tested this by hard-coding the value I need in to line 74; this works great but isn't a long term solution.

Can anyone help me out with this, I see it as two problems:

1) I need to get this recipe working as intended 2) I need to understand why this behaviour occurs, I'm new to Ruby and Chef and the recipes order of execution is extremely confusing to me, surely I must be able chain events in order to get around this problem?

Many thanks

Andrew

share|improve this question
    
Further to this I've removed lines 73 onward and the recipe executes as expected (but doesn't enable the module, only the configuration is created). I'm convinced the problem lies with the execution of the module enable as part of the apache2 recipe run prior to the Ruby code block executing. –  Andrew Taylor Aug 30 '12 at 12:31
    
Further, Further to this, I've duplicated the lines from the lwrp that execute a2enmod and called them directly from the rvm_passenger recipe in place of lines 73 onwards. This fixes||fudges my problem, I'd still like to understand the correct method for the same solution however. –  Andrew Taylor Aug 30 '12 at 14:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.