Question

I am attempting to install PHP APC on Puppet but I do not know how to go about this? Pear is already installed and when I try and execute the command to install PHP APC I presented with an error message.

pecl.pp:

class php::pecl {
    include php
     exec { "pecl install php-apc":
    require => Package["php-pear"]
    }
}

pear.pp:

class php::pear {
  include php

  # upgrade PEAR
  exec { "pear upgrade":
    require => Package["php-pear"]
  }

  # install PHPUnit
  exec { "pear config-set auto_discover 1":
    require => Exec["pear upgrade"]
  }




  # create pear temp directory for channel-add
  file { "/tmp/pear/temp":
    require => Exec["pear config-set auto_discover 1"],
    ensure => "directory",
    owner => "root",
    group => "root",
    mode => 777
  }

  # discover channels
  exec { "pear channel-discover pear.phpunit.de; true":
    require => [File["/tmp/pear/temp"], Exec["pear config-set auto_discover 1"]]
  }

  exec { "pear channel-discover pear.symfony-project.com; true":
    require => [File["/tmp/pear/temp"], Exec["pear config-set auto_discover 1"]]
  }

  exec { "pear channel-discover components.ez.no; true":
    require => [File["/tmp/pear/temp"], Exec["pear config-set auto_discover 1"]]
  }

  # clear cache before install phpunit
  exec { "pear clear-cache":
    require => [Exec["pear channel-discover pear.phpunit.de; true"], Exec["pear channel-discover pear.symfony-project.com; true"], Exec["pear channel-discover components.ez.no; true"]]
  }

  # install phpunit
  exec { "pear install -a -f phpunit/PHPUnit":
    require => Exec["pear clear-cache"]
  }

  # install apc
  exec { "pear install -a -f pear/php-apc":
    require => Exec["pear clear-cache"]
  }


}

php init.pp class:

class php {

  # package install list
  $packages = [
    "php5",
    "php5-cli",
    "php5-mysql",
    "php-pear",
    "php5-dev",
    "php5-gd",
    "php5-mcrypt",
    "libapache2-mod-php5",
  ]

  package { $packages:
    ensure => present,
    require => Exec["apt-get update"]
  }
    }

Error message:

err: /Stage[main]/Php::Pear/Exec[pear install -a -f pear/php-apc]/returns: change from notrun to 0 failed: pear install -a -f pear/php-apc returned 1 instead of one of [0] at /tmp/vagrant-puppet-1/modules-0/php/manifests/pear.pp:52
err: /Stage[main]/Php::Pecl/Exec[pecl install php-apc]/returns: change from notrun to 0 failed: pecl install php-apc returned 1 instead of one of [0] at /tmp/vagrant-puppet-1/modules-0/php/manifests/pecl.pp:5
Was it helpful?

Solution 2

Turns out the package is actually called apc and not php-apc - doh!

Working code:

  exec { "pecl install apc":
    require => Exec["pear clear-cache"]
  }

OTHER TIPS

I would suggest that you use a tried and trusted puppet module which can install PHP and pecl extensions for you.

Have a look at the following puppet module which will most likely help.

https://forge.puppetlabs.com/example42/php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top