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.

When using Vagrant (and subsequently Chef), I'm provisioning my VM using Zend Server CE, which automatically installs the usually *AMP stack.

I'd like to install some packages via PEAR, for which the "php" cookbook already has a "pear" and "pear_channel" provider. However, by calling require_recipe("php"), default.rb is ran automatically which attempts to reinstall PHP.

I just want to take advantage of it's few providers without executing default.rb.

Is there a way to do this?

share|improve this question
    
I don't know why this was voted down, but it isn't necessary. I think a lot of people newer to chef run into this. –  Kyle Mar 2 '12 at 0:33
add comment

2 Answers

up vote 2 down vote accepted

You need to make sure all your chef recipes are idempotent and nondestructive for your environment. Chef will always run default.rb when you require or include the recipe.

Two ways to fix this:

  1. Make your PHP recipe check for installed PHP binaries, and do nothing if they are found
  2. Move the installation steps to a new recipe file outside of default.rb

Number one is the best solution, but if you do indeed have situations where you want to use PEAR but not have chef manage php, you could do the second.

share|improve this answer
    
Thanks for this. The Opscode cookbooks for PHP attempt a second installation on top of Zend Server CE's PHP. I initially went with #2 and removed the forced installation of PHP, but ran into difficulties even referencing the providers. Finally, moving the pear portions into my own "zend" cookbook sufficed. –  Eric Mar 2 '12 at 4:52
add comment

You can specify that your cookbook depends on the opscode php cookbook by adding depends 'php' to your cookbook's metadata.rb. By using depends, you don't have to actually run the php cookbook. See http://wiki.opscode.com/display/chef/Metadata#Metadata-depends

Then, assuming the php cookbook is available from your chef server, a chef-client run will pull down the php cookbook, so that the php_pear and php_pear_channel resources are available. In your own recipe, simply add instructions according to the php cookbook:

php_pear "DB" do
  action :install
end
share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.