djoos-cookbooks / composer

Repository for composer cookbook
http://community.opscode.com/cookbooks/composer
MIT License
27 stars 38 forks source link

Skipping the php package for an already installed php version #57

Closed Mulkave closed 9 years ago

Mulkave commented 9 years ago

Using it with AWS OpsWorks I have specified and installed php 5.5 on the machine already but when composer (this cookbook) requires php it tries to install an older version of php, error below:

Berksfile

source "https://supermarket.chef.io"

cookbook 'composer', '~> 2.2.0'

Log

[2015-09-12T12:10:18+00:00] INFO: ruby_block[Check that the ECS agent is running] called
[2015-09-12T12:10:18+00:00] INFO: Processing package[php] action install (php::package line 59)
[2015-09-12T12:10:18+00:00] INFO: package[php] installing php-5.3.29-1.8.amzn1 from amzn-updates repository

================================================================================
Error executing action `install` on resource 'package[php]'
================================================================================

Chef::Exceptions::Exec
----------------------
returned 1, expected 0

Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage2/cookbooks/php/recipes/package.rb

59:     package pkg do
60:       action :install
61:       options node['php']['package_options']
62:     end
63:   end

Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache.stage2/cookbooks/php/recipes/package.rb:59:in `block in from_file'

package("php") do
action [:install]
retries 0
retry_delay 2
package_name "php"
version "5.3.29-1.8.amzn1"
cookbook_name "php"
recipe_name "package"
end

[2015-09-12T12:10:21+00:00] INFO: Running queued delayed notifications before re-raising exception
[2015-09-12T12:10:21+00:00] ERROR: Running exception handlers
[2015-09-12T12:10:21+00:00] ERROR: Exception handlers complete
[2015-09-12T12:10:21+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2015-09-12T12:10:22+00:00] ERROR: package[php] (php::package line 59) had an error: Chef::Exceptions::Exec:  returned 1, expected 0
[2015-09-12T12:10:22+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
djoos commented 9 years ago

Hi @Mulkave,

thanks for reaching out!

The php cookbook doesn't think you've got PHP installed already, which is why it tries to install it again. I'd suggest you to set the php_recipe (see below) to your cookbook/recipe used to install PHP. You can tweak the PHP recipe used in the Composer cookbook easily via (default['composer']['php_recipe'] = 'php::default').

Hope this helps - thanks in advance for your feedback!

Kind regards, David

Mulkave commented 9 years ago

@djoos thanks for the explanation! Will give it a try tonight and let you know.

Cheers,

Mulkave commented 9 years ago

@djoos unfortunately in my case this didn't work (by default) since php was installed as a system package without using a recipe, it's a feature in OpsWorks where you can specify packages to be installed on setup.

But! Your solution works by specifying a recipe that simply does nothing :smile: in my case and for whoever faces this in the future, this custom Chef JSON worked:

{
  "composer": {
    "php_recipe": "opsworks_ecs::deploy"
  }
}

Thanks!

teaforchris commented 9 years ago

@Mulkave I had a similar scenario with php56 already installed, and your solution works perfectly, but my approach was to create my own no-operation recipe with nothing in it, and set node['composer']['php_recipe'] to mycookbook::noop. This way, its a bit more verbose, plus negates any risk of opsworks_ecs::deploy ever being updated TO do something (its currently "not implemented" but that could change!)

Mulkave commented 9 years ago

@cp5w :+1: thanks for sharing, indeed that's a better approach than my lazy one :smile:

jujubetz commented 8 years ago

Thanks guys, helped alot! A quick question; i've forked composer cookbook, changed the attribute: node['composer']['php_recipe'] to my cookbook and set the "depends" to my empty cookbook, this should work ?