Giter VIP home page Giter VIP logo

puppet-php's Introduction

Deprecation notice

This module was designed for Puppet versions 2 and 3. It should work also on Puppet 4 but doesn't use any of its features.

The current Puppet 3 compatible codebase is no longer actively maintained by example42.

Still, Pull Requests that fix bugs or introduce backwards compatible features will be accepted.

Puppet module: php

This is a Puppet module for php based on the second generation layout ("NextGen") of Example42 Puppet Modules.

Made by ALessandro Franceschi / Lab42

Official site: http://www.example42.com

Official git repository: http://github.com/example42/puppet-php

Released under the terms of Apache 2 License.

This module requires functions provided by the Example42 Puppi module (you need it even if you don't use and install Puppi)

For detailed info about the logic and usage patterns of Example42 modules check the DOCS directory on Example42 main modules set.

USAGE - Basic management

  • Install php with default settings

      class { 'php': }
    
  • Install a specific version of php package

      class { 'php':
        version => '1.0.1',
      }
    
  • Remove php package

      class { 'php':
        absent => true
      }
    
  • Enable auditing without without making changes on existing php configuration files

      class { 'php':
        audit_only => true
      }
    
  • Define nginx service to be notified on changes

      class { 'php':
        service => 'nginx'
      }
    

USAGE - Module installation

  • Install a new module

      php::module { "imagick": }
    
  • Install a specific version of a module:

      php::module { "imagick":
        version => '1.0.1';
      }
    
  • Remove php module

      php::module { "imagick":
          absent => true,
      }
    
  • By default module package name is php-$title for RedHat and php5-$title . You can override this prefix.

      php::module { "apc":
        module_prefix => "php-"
      }
    

USAGE - Module Configuration

  • Configure php module to all SAPI

      php::mod { "mcrypt": }
    

    Note: [name] is filename without .ini extension from /etc/php5/mods-available/<name>.ini

  • Configure multiple php module to all SAPI

      $mods = ["mcrypt", "mongo"]
      php::mod { "$mods": }
    
  • Unconfigure php module to all SAPI

      php::mod { "xdebug"
          disable => true,
      }
    
  • Installing and configuring a Module. This will guarantee correct execution order in your classes

      php::module { 'sqlite': } -> php::mod { 'sqlite3': }
    

USAGE - Pear Management

  • Install a pear package

      php::pear::module { "XML_Util": }
    
  • Install a pear package from a remote repository

      php::pear::module { 'PHPUnit':
        repository  => 'pear.phpunit.de',
        use_package => 'no',
      }
    
  • Install a pear package will all dependencies (--alldeps)

      php::pear::module { 'PHPUnit':
        repository  => 'pear.phpunit.de',
        alldeps => 'true',
      }
    
  • Set a config option

      php::pear::config { http_proxy: value => "myproxy:8080" }
    

USAGE - Pecl Management

  • Install a pecl package

      php::pecl::module { "XML_Util": }
    
  • Install a pecl package from source specifying the preferred state (note that you must have the package 'make' installed on your system)

      php::pecl::module { "xhprof":
        use_package     => 'false',
        preferred_state => 'beta',
      }
    
  • Set a config option

      php::pecl::config { http_proxy: value => "myproxy:8080" }
    
  • Auto-answer prompts for unattended-installation (where configure might used used for instance)

      php::pecl::module { 'stomp':
        use_package     => 'false',
        auto_answer     => 'no\\n\\n',
      }
    

USAGE - Overrides and Customizations

  • Use custom sources for main config file.

      class { 'php':
        source => [ "puppet:///modules/lab42/php/php.conf-${hostname}" , "puppet:///modules/lab42/php/php.conf" ],
      }
    
  • Manage php.ini files on Debian and Suse derivatives. Here the main config file path (managed with the source/template params) defaults to /etc/php5/apache2/php.ini. To manage other files, either set a different path in config_file or use the php::conf define.

      class { 'php':
        config_file => '/etc/php5/apache2/php.ini',      # Default value on Ubuntu/Suse
        template    => 'example42/php/php.ini-apache2.erb',
      }
    
      php::conf { 'php.ini-cli':
        path     => '/etc/php5/cli/php.ini',
        template => 'example42/php/php.ini-cli.erb',
      }
    
  • Use custom source directory for the whole configuration dir

      class { 'php':
        source_dir       => 'puppet:///modules/lab42/php/conf/',
        source_dir_purge => false, # Set to true to purge any existing file not present in $source_dir
      }
    
  • Use custom template for main config file. Note that template and source arguments are alternative.

      class { 'php':
        template => 'example42/php/php.conf.erb',
      }
    
  • Automatically include a custom subclass

      class { 'php':
        my_class => 'php::example42',
      }
    

Build Status

puppet-php's People

Contributors

abednarik avatar alvagante avatar catalinpan avatar damusnet avatar davids avatar dennisoehme avatar freeaqingme avatar gabrielbull avatar ghola avatar gimler avatar gitpappy avatar gwarf avatar jberns88 avatar jessem avatar jimmykane avatar jmeyering avatar jmkgreen avatar jtreminio avatar kampfcaspar avatar lermit avatar loren-osborn avatar martinbutt avatar mdular avatar mscharley avatar rican7 avatar sephvelut avatar slashbunny avatar stubbetje avatar webflo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-php's Issues

cannot set both source and template on node X

I had successful experience getting this module to work on Ubuntu, but I am having problem trying to get it to work on RHEL 6.

I tried to configure using the default: class { 'php': }

The error I'm getting is this:-

Error: PHP: cannot set both source () and template () on node X
Error: PHP: cannot set both source () and template () on node X

I read init.pp and the error seems to be happening on this:-

  if ($php::source and $php::template) {
    fail ("PHP: cannot set both source and template")
  }

When I inspected these values, both are empty strings. So I decided to comment out that check and set both $manage_file_source and $manage_file_content to undef, but then I get error about $php::source_dir being empty when trying to create php.dir.

This is getting very frustrating. It works flawlessly on Ubuntu, but I can't cannot replicate my success on RHEL. I'm running Puppet 3.7.3 on RHEL 6, by the way.

LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Red Hat Enterprise Linux Server release 6.5 (Santiago)
``
Any idea why this is happening? Thank you.

Duplicate class declaration error

I'm not positive where this problem comes from, it may not be related to this module, but I figured I'd post here to get your opinion.

I'm using the latest version of this module. I use Foreman as my ENC. At some point recently, I started getting duplicate class declaration errors for Class[php]. The only place the class is declared parameterized that I can find is via Foreman.

Normally newer versions of puppet would provide the file in which the duplicate declaration occurred, but apparently since I'm using an ENC it is not specific.

I tried commenting out all 'include php' declarations from all classes in this module, but the error didn't go away. Only removing the php class from this server in Foreman makes the error go away.

Do you have any ideas where any other declarations of the 'php' class might be coming from or what else could cause this error with Puppet 3.4.2?

Again, I'm not sure this is even an issue with this module, but I just can't find anything else that would cause this error so I figured I'd check.

how to install the module without it installing apache...

I would like to use this module to install php on our production servers.

We're an nginx shop and don't use apache.

But I can't seem to get this module working without it installing apache. (which then leads to port conflicts on port 80).

Can someone tell me if it is possible to install this application without it installing apache? I really appreciate any help you can provide. My manifest is below:

class projects::interact::servers::app::php {
include puppi
::php::module { "cli": }
::php::module { "fpm": }
::php::module { "mysql": }
::php::module { "ldap": }
::php::module { "imagick": }
::php::module { "curl": }
::php::module { "gd": }
::php::module { "json": }
::php::module { "mysqlnd": }
::php::module { "odbc": }
::php::module { "pgsql": }
::php::module { "snmp": }
::php::module { "tidy": }
::php::module { "xsl": }

class { '::php':
service => 'nginx',
version => '5.3.10-1ubuntu3.15',
require => Class['puppi'],
}

}

Pecl module xhprof failed to install

I tried to install xhprof pecl module on Ubuntu 12.04 server by following puppet configuration

include php::pear
php::pecl::module { "xhprof":
use_package => 'false',
preferred_state => 'beta',
}

Everything look OK, but when i log on vagrant server and call "pecl list", there is no xhprof installed.

After some tests i found that problem is in absence of "make" command in new Ubuntu servers.

Please add Package { "make": ensure => present }

Not finding php.ini file on Centos6

I'm getting the following message when defining the php.ini file in Centos6

No such file or directory - /etc/php.d/conf.d/php.ini.puppettmp_1910

For what I'm able to see, the php.ini file is located in /etc/php.ini instead.

package { 'php': } in init.pp breaks apt-get on Ubuntu if install_options is left blank

Hello - great module, by the way.

I've been testing a deployment on an Ubuntu 14.04 system using the latest commit of this module (March, 2015) and I keep encountering the same error when the module tries to install php5. The error is :

Error: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold  install php5' returned 100: E: Invalid operation

I've discovered that this is caused by passing an empty value to 'install_options' in the package declaration for php in site.pp (the default behavior):

 ### Managed resources
package { 'php':
ensure => $php::manage_package,
name => $php::package,
install_options => $php::install_options,
}

This passes an invalid null argument to 'apt-get install'. I've worked around this by passing "-y" in to the install_options parameter. I'm not sure what the correct solution is, but it would appear that at least on Ubuntu 14.04 the install_options parameter does not work with an empty value.

Module installation fails

php::module { 'xdebug': }

leads to the following error:

Warning: Scope(Php::Module[xdebug]): Could not look up qualified variable 'php::package'; class php has not been evaluated
Error: Could not find dependency Package[undef] for Package[PhpModule_xdebug] at /etc/puppet/modules/php/manifests/module.pp:93

Got Apache2 Ubuntu Default Page

I am using Vagrant and Puppet Provisioner to setup nginx and php in ubuntu/trusty64 box. But the thing I got was Apache2 Ubuntu Default Page and is really shocking. I am using following modules:

# Puppetlabs Modules
apt -> git@github.com:puppetlabs/puppetlabs-apt.git
concat -> git@github.com:puppetlabs/puppetlabs-concat.git
stdlib -> git@github.com:puppetlabs/puppetlabs-stdlib.git

# Example42 Modules
puppi -> git@github.com:example42/puppi.git
nginx -> git@github.com:netmanager/nginx.git
php -> git@github.com:example42/puppet-php.git # This installed apache2

In my manifests init.pp, I have coded like this.

group { 'puppet': ensure => present }

Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] }
File { owner => 0, group => 0, mode => 0644 }

class { 'apt':
    always_apt_update => true,
}

Class['::apt::update'] -> Package <|
    title != 'python-software-properties'
    and title != 'software-properties-common'
|>

# Package Configurations.
$sysPackages = ['vim', 'ntp']
package { $sysPackages:
    ensure => 'installed',
}

# Nginx Web-Server Configurations.
class { 'nginx':
    worker_connections      => 4096,
    keepalive_timeout       => 120,
    client_max_body_size    => '1024m',
    types_hash_max_size     => '2048',
}

nginx::resource::vhost { 'axisthemes.dev' :
    ipv6_enable => true,
    default_server => true,
    fastcgi => present,
    www_root => '/var/www/axisthemes',
}

# PHP Module Configurations.
class { 'php':
    service => 'nginx',
}

class { 'php::devel':
    require => Class['php'],
}

$phpModules = ['fpm', 'gd', 'imagick', 'mysql', 'cli', 'common', 'curl', 'intl', 'mcrypt', 'cgi', 'memcache']
php::module { $phpModules: }

$peclModules = ['xdebug']
php::pecl::module { $peclModules: }

In my Vagrantfile I have set this code:

config.vm.network "private_network", ip: "192.168.66.101"

Now whenever I browse to 192.168.66.101 I receive the Welcome to nginx! page but
if I browse 'axisthemes.dev` I receive Apache2 Ubuntu Default Page.

(Note)
I have check and found that apache2 was installed through this puppet-php module.
I am Nginx lover and really don't prefer apache. Also I love example42 modules. What was the case I didn't understand.

APC dependent on apache

I'm getting the following error:

Error: Could not find dependent Service[apache2] for Package[PhpModule_apc] at /tmp/vagrant-puppet-3/modules-0/php/manifests/module.pp:82

Unless I'm missing something, shouldn't I be able to use APC with Nginx?

metadata.json file permissions are incorrect

I have clean install of puppetserver
Ran puppet module install example42-php to install.

Added the following snippit to my site.pp manifest:

class{ 'php':
}

Running puppet agent -t resulted in the following:

Info: Retrieving pluginfacts
Error: /File[/opt/puppetlabs/puppet/cache/facts.d]: Failed to generate additional resources using 'eval_generate': Error 400 on SERVER: Permission denied - /etc/puppetlabs/code/environments/production/modules/php/metadata.json
Error: /File[/opt/puppetlabs/puppet/cache/facts.d]: Could not evaluate: Could not retrieve file metadata for puppet:///pluginfacts: Error 400 on SERVER: Permission denied - /etc/puppetlabs/code/environments/production/modules/php/metadata.json
Info: Retrieving plugin
Error: /File[/opt/puppetlabs/puppet/cache/lib]: Failed to generate additional resources using 'eval_generate': Error 400 on SERVER: Permission denied - /etc/puppetlabs/code/environments/production/modules/php/metadata.json
Error: /File[/opt/puppetlabs/puppet/cache/lib]: Could not evaluate: Could not retrieve file metadata for puppet:///plugins: Error 400 on SERVER: Permission denied - /etc/puppetlabs/code/environments/production/modules/php/metadata.json
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Function Call, Permission denied - /etc/puppetlabs/code/environments/production/modules/php/metadata.json at /etc/puppetlabs/code/environments/production/manifests/sandbox.pp:2:3 on node xxxx
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Discovered that the metadata.json had file permission of 640. Changed it to 644 and ran puppet agent -t and it was successful.

php package name required by module installation

in module.pp, on line 91 (last before closing parenthesis) there is:

require => Package['php'],

it should be

require => Package[$php::package],

otherwise, installing another php package (php55, php56 from another repo (epel/remi as example for Fedora/Centos/RHEL) will cause the module part to be ignored as the require clause will be missed.


update:
same in init.php:
251: package { "${php::package}":
263: require => Package["${php::package}"],

Duplicate declaration: Package[php-devel]

When installing packages from both PECL and PEAR I receive the following error.

Error: Duplicate declaration: Package[php-devel] is already declared in file /tmp/vagrant-puppet/modules-0/php/manifests/module.pp at line 71; cannot redeclare on node

Custom module (PHP extension) support?

I'd like to add PDFlib as a PHP extension to my installation.
Unfortunately it is only available as a ZIP download which contains a .so file.
So I could extract this and grad the right file, but I found no info in the docs about how to start using a custom extension, any advices?

Still trouble setting the new PHP configuration folders

Still having trouble configuring PHP new config location

If setting an ini then the above solution fails due to ini.pp :

# = Define: php::ini
#
define php::ini (
    $value       = '',
    $template    = 'extra-ini.erb',
    $target      = 'extra.ini',
    $service     = $php::service,
    $config_dir  = $php::config_dir
) {

  include php

  file { "${config_dir}/conf.d/${target}":
    ensure  => 'present',
    content => template("php/${template}"),
    require => Package['php'],
    notify  => Service[$service],
  }

  file { "${config_dir}/cli/conf.d/${target}":
    ensure  => 'present',
    content => template("php/${template}"),
    require => Package['php'],
  }

}

As you can see setting the above config to apache2 will excpect for cli to be apache2/cli/conf.d/ etc

Also the conf define does not support variables as far as I can see.

Parameter notify failed

Last commit seems to break this, I'm using Puppet 3.

Error: Failed to apply catalog: Parameter notify failed on Package[PhpModule_ps]: No title provided and true is not a valid resource reference at /usr/share/puppet/modules/php/manifests/module.pp:78

Ubuntu PHP package configuration upgrade

Env:

PHP 5.4.6-1ubuntu1.1 (cli) (built: Nov 15 2012 01:18:34)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

Ubuntu 12.10

The /etc/php5 structure has changed. Now with this structure:

.
├── cli
│   ├── conf.d -> ../conf.d
│   └── php.ini
├── conf.d
│   ├── 10-pdo.ini -> ../mods-available/pdo.ini
│   └── 20-apc.ini -> ../mods-available/apc.ini
├── fpm
│   ├── conf.d -> ../conf.d
│   ├── php-fpm.conf
│   ├── php.ini
│   └── pool.d
│       └── www.conf
└── mods-available
    ├── apc.ini
    └── pdo.ini

So this module is not working for the latest php package.

I have not tested other releases and so can't provide a good solution.

service => 'nginx' seems broken

declaring

class { 'php':
service => 'nginx'
}

seems not to be working correctly: it installs apache2 dependencies, which leads to nginx startup failure.

if i manually purge apache2 and ensure php5-cli + php5-cgi to be installed before applying again the module still tries to write apache module config:

Error: Could not set 'present' on ensure: No such file or directory - /etc/php5/apache2/php.ini at 257:/vagrant/puppet/vendor/php/manifests/init.pp

Impossible to upgrade pecl library

There seems to be an undocumented $version parameter which does in itself work, but if you change the value to a new version nothing happens at execution.

Looks like you check if 'pecl info ' comes back with something sensible without noting the version installed.

To work around we must uninstall the pecl module then re-run the puppet agent.

Installing PHP 5.4

Hello, was wondering how to install PHP 5.4 using this puppet module. So far I only get to install version 5.3.

I think supporting version 5.4 could be a great enhancement to this module.

php::ini not working with centos family systems

Hi,

I could not find a way to configure .ini files using the module. I have updated the ini.pp with the following lines:

 }else{

 case $::osfamily {

 'RedHat', 'Fedora', 'CentOS', 'Scientific', 'SLC', 'Ascendos', 'CloudLinux', 'PSBM', 'OracleLinux', 'OVS', 'OEL', 'Linux' :{

   file { "${config_dir}/${target}":
     ensure  => 'present',
     content => template($template),
     require => Package[$php::package],
     notify  => Service[$service],
   }
   }

 'Ubuntu', 'Debian', 'Mint', 'SLES', 'OpenSuSE': {

   file { "${config_dir}/${sapi_target}/conf.d/${target}":
     ensure  => 'present',
     content => template($template),
     require => Package['php'],
     notify  => Service[$service],
   }
  }
 }
}

In the configuration with the correct hiera_hash I have added:

php::ini:
        'xdebug_disable':
                value:
                        - #zend_extension=xdebug.so
                target: xdebug.ini
                sapi_target: none

and now everything works.

I am not sure if this will satisfy all systems but in case everyone agrees can I create a pull request with this fix?

Many thanks

PHP PEAR could not evaluate invalid byte sequence in UTF-8

Im on a centos 6.5 x64 box with puppet 3.6.2. Ruby is installed with RVM and I get this error with 1.8.7, 1.9.3 and 2.1.2

modules are installed with librarian puppet.

In my set up file I have the below. The drush section give me Could not evaluate: invalid byte sequence in UTF-8

# drush
php::pear::module { 'Console_Table':
    repository => 'pear.php.net',
    alldeps => 'true',
    use_package => 'no',
}
php::pear::module { 'drush':
    repository => 'pear.drush.org',
    alldeps => 'true',
    use_package => 'no',
    require => Php::Pear::Module['Console_Table']
}

Here is more of the dump info

==> izanagi: Debug: /Stage[main]/Main/Node[default]/Php::Pear::Module[drush]/Php::Pear::Config[auto_discover]/Exec[pear-config-set-auto_discover]/unless: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/apc.so' - /usr/lib64/php/modules/apc.so: file too short in Unknown on line 0
==> izanagi: 
==> izanagi: Debug: /Stage[main]/Main/Node[default]/Php::Pear::Module[drush]/Php::Pear::Config[auto_discover]/Exec[pear-config-set-auto_discover]/unless: 1
==> izanagi: Debug: Exec[pear-drush](provider=posix): Executing check 'pear info pear.drush.org/drush'
==> izanagi: Debug: Executing 'pear info pear.drush.org/drush'
==> izanagi: Error: /Stage[main]/Main/Node[default]/Php::Pear::Module[drush]/Exec[pear-drush]: Could not evaluate: invalid byte sequence in UTF-8

Pear info returns some code that is causing this error.

pear info pear.drush.org/drush

Php::Pear::Config[auto_discover] is already declared

Duplicate declaration: Php::Pear::Config[auto_discover] is already declared in file /tmp/vagrant-puppet/modules-0/php/manifests/pear/module.pp at line 62; cannot redeclare at /tmp/vagrant-puppet/modules-0/php/manifests/pear/module.pp:62 on node precise64.wag320n

with a config file having:

php::pear::module { 'PHPUnit':
use_package => false,
repository => 'pear.phpunit.de',
}
php::pear::module { 'PHPUnit_Selenium':
use_package => false,
repository => 'pear.phpunit.de',
}

removing

      if $repository != 'pear.php.net' {
        @php::pear::config { 'auto_discover':
          value => '1',
          before => Exec["pear-${name}"],
        }
        Php::Pear::Config <| title == 'auto_discover' |>
      }

fixes this?

Has the PHP 5 config directory changed structure?

Hi

I'm using the Ubuntu Precise 64bit box from vagrantup.com (http://files.vagrantup.com/precise64.box) and I'm using puppet-php I've got PHP installed and setup via the ppa:ondrej/php5 repository (version installed is 5.5.4+dfsg-1+debphp.org~precise+1).

However there's a problem copying the apache2 php.ini template into places. Looking at the error message and the ini.pp file, puppet-php is trying to copy the ini settings to /etc/php5/conf.d but that doesn't exist. And according to phpinfo() apache is using the ini file in /etc/php5/apache2/conf.d.

I've looked on a my own ubuntu 13.04 install and /etc/php5/conf.d exists and /etc/php5/apache2/conf.d is a symlink to it. However on my vagrant box /etc/php5/conf.d doesn't exist and /etc/php5/apache2/conf.d is a real folder containing symlinks to the module configs.

I've currently fixed it by editing puppet-php's ini.pp file and telling it to copy to the apache2 directory instead but I'm wandering is there a better way I can do this without hacking the puppet-php module (i.e. in my own puppet file) or any ideas why the /etc/php5 folder structure is different? Has it changed in new versions of PHP?

I suppose one option would be moving the folder and symlinking it in my puppet script, is that the best solution?

Thanks,
Tom

Multiple ini declarations

what syntax do I use if I want to set more than one ini setting? For example, I want this:

upload_max_filesize = 200M
memory_limit=512M

Originally, I had this defined:

php::ini { "memory_limit":
value => 'memory_limit=512M'
}

which set the memory limit, but maybe I was doing it wrong. When I tried this:

php::ini { "memory_limit":
value => 'memory_limit=512M'
}

php::ini { "upload_max_filesize":
value => 'upload_max_filesize = 200M'
}

I get a duplicate declaration error, which makes sense, I guess. I'm just too new to puppet syntax to figure this out, but it's probably something simple. Any help?

hiera create_resource error for php::augeas

Hiera doesn't pass the right value which need to be validated by any2bool when I create resources.
The error is:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: any2bool(): Unknown type of boolean given at /etc/puppet/modules/php/manifests/init.pp:180

*.pp file

    $myphpAugeas = hiera_hash('php::augeas', {})
    create_resources('php::augeas', $myphpAugeas)

*.yaml file

        php::augeas:
                   'php-memorylimit':
                           entry: 'PHP/memory_limit'
                           value: 512M

                   'php-date_timezone':
                           entry: 'Date/date.timezone'
                           value: 'Europe/London'

To fix this I have changed this line:
$bool_augeas=any2bool($augeas)
to
$bool_augeas=($augeas)

I am wondering is there any other alternative for this? If not is it possible to have this in the module to be able to pull from puppetforge?

Thanks

Enabling a custom php module on ubuntu 14.04

I have compiled a custom php module on ubuntu and am having trouble getting it to be enabled instead of just installed.

The module package includes the file /etc/php5/mods-available/${name}.ini , and puppet is able to find the right package to install from the repo at php5-${name}, but I do not automatically get a link in /etc/php5/apache/conf.d so that the module will be enabled.

I was wondering if this behavior is expected? I looked at a few other php modules apt packages and it looks like they do typically have the ${name}.ini included in the package. I assume the typical manual way of doing this is to issue a php5enmod on ubuntu.

It appears that the rest of the php modules i have installed via puppet do get a symlink in the relevant conf.d directory. Is that because their postist script is doing the equivalent of php5enmod, or am I missing some puppet option?

different session_handler

it's not possible use redis (or memcache) as session handler

php::pecl::module { 'redis' }

php::ini { "ini_settings":
value => '
session.save_handler = redis
session.save_path = tcp://127.0.0.1:6379'
}

error message: Error: Parameter creates failed on Exec[mkdir -p tcp://127.0.0.1:6379]: creates must be a fully qualified path at /tmp/vagrant-puppet-3/manifests/nodes/Php.pp:139

Cannot install php (5.6.19) on Centos 7x

I'm unable to install php version 5.6.19, using the following class definition, within my Centos 7x environment:

class { 'php':
  version => '5.6.19',
}

Since I'm using puppet to provision my vagrant instance of centos 7x, I've reduced the above thought to the following configure_php.pp definition:

# variables
$working_dir = '/home/provisioner'

## define $PATH for all execs
Exec {path => ['/usr/bin/', '/usr/sbin/']}

## update yum using the added EPEL repository
class update_yum {
    exec { 'update-yum':
        command => 'yum -y update',
        timeout => 750,
    }
}

## install php
class install_php {
    ## set dependency
    require update_yum

    ## install php
    class { 'php': }
}

## constructor
class constructor {
    ## set dependency
    contain update_yum
    contain install_php
}
include constructor

When I run the above manifest, within my vagrant implementation:

[provisioner@drupal-demonstration ~]$ vagrant up
...
==> default: Running provisioner: puppet...
==> default: Running Puppet with environment development...
==> default: Error: Evaluation Error: Unknown function: 'params_lookup'. at /tmp
/vagrant-puppet/modules-3caf511b1ed192516806c35da44e64ef/php/manifests/init.pp:1
52:26 on node drupal-demonstration.com
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

In an attempt reduce the debug time, I implemented the same test, within the terminal console:

[provisioner@drupal-demonstration ~]$ cd ~
[provisioner@drupal-demonstration ~]$ ls
[provisioner@drupal-demonstration ~]$ puppet module install example42-php
Notice: Preparing to install into /home/provisioner/.puppetlabs/etc/code/modules
 ...
Notice: Created target directory /home/provisioner/.puppetlabs/etc/code/modules
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/home/provisioner/.puppetlabs/etc/code/modules
└─┬ example42-php (v2.0.25)
  └── example42-puppi (v2.1.12)
[provisioner@drupal-demonstration ~]$ sudo vi install_php.pp
[provisioner@drupal-demonstration ~]$ puppet apply install_php.pp
Warning: Config file /home/provisioner/.puppetlabs/etc/code/hiera.yaml not found
, using Hiera defaults
Notice: Compiled catalog for drupal-demonstration.com in environment production
in 1.57 seconds
Error: Could not find dependent Service[httpd] for File[php.conf] at /home/provi
sioner/.puppetlabs/etc/code/modules/php/manifests/init.pp:258

The following was my install_php.pp defintion:

## install php
class install_php {
    class { 'php': }
}
contain install_php

Fix php5-mcrypt on Ubuntu 13.10 +

When Installing PHPMyAdmin I came to know that this plugin should have fix for php5-mcrypt extension or module. I have used the code like this:

# PHP Module Configurations.
class { 'php':
  service   => 'nginx',
}

class { 'php::devel':
  require => Class['php'],
}

$phpModules = ['fpm', 'gd', 'imagick', 'mysql', 'cli', 'common', 'curl', 'intl', 'mcrypt', 'cgi', 'memcache']
php::module { $phpModules:
  service_autorestart => true,
}

$peclModules = ['xdebug']
php::pecl::module { $peclModules: }

### This will ensure fix for this issue
exec { 'enabling_mcrypt': 
  command => 'php5enmod mcrypt && service nginx reload',
  require => Package['php5-mcrypt'],
}
### End of fix

# PHPMyAdmin Resources Configurations.
package { 'phpmyadmin':
  ensure => present,
  require => Package['nginx'],
} 

I have used this solution from serverfault.com. Please do some updates for this issues.

Also When I echo phpinfo(); there was no mcrypt support enable. But after that exec I have see like this table:
image 1

Installing PHP 5.6

If I try to install PHP 5.6 I get the following error

==> default: Error: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install php5-fpm=5.6' returned 100: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: E: Version '5.6' for 'php5-fpm' was not found
==> default: 
==> default: Error: /Stage[main]/Php/Package[php]/ensure: change from 5.5.9+dfsg-1ubuntu4.11 to 5.6 failed: Could not update: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold --force-yes install php5-fpm=5.6' returned 100: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: E: Version '5.6' for 'php5-fpm' was not found
==> default:

Config:

class { 'php':
  version             => '5.6',
  package             => "php5-fpm",
  service             => "php5-fpm",
  service_autorestart => false,
  config_file         => "/etc/php5/fpm/php.ini",
  require => [
    Exec['apt-update']
  ]
}

Issue with locking PHP to particular version

We had an issue recently where we were trying to lock PHP to a specific point release. It worked fine when that was the latest version in the repo but as soon as the repo released a new version it broke. To fix it we had to specify the version for each and every module we were using. Is this the intended behaviour in this scenario? Or should the Php::Module define use $php::version by default? I'm happy to create a pull request if necessary...

php::pear::module {...} prepends 'php-' to the module name

Not sure if I'm misunderstanding this, but whenever I try

php::pear::module
{
    'PHPUnit':
        repository  => 'pear.phpunit.de',
        alldeps => 'true',
}

or similar with another module, it fails because php- gets prepended to the module name. How do I prevent this?

err: /Stage[main]//Php::Pear::Module[PHPUnit]/Package[pear-PHPUnit]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install php-PHPUnit' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package php-PHPUnit

Automatic enabling of a pecl module.

To install a module with pecl I can run the following.

php::pecl::module { "mongo":
  use_package     => 'false',
}

but it doesn't enable it automatically. I have to manually add extension=extension_name to the php.ini.

Its not documented what the best way to do this is, if there is a manifest in the module that can do that or should I use the puppet file resource. If someone can tell me what the best option is I will gladly document it and do a PR.

php::augeas writes to php.ini before php package is installed

Hi,

On the initial puppet run php::augeas writes the values on the php.ini before the php package installation. This results in the php.ini having only the php::augeas values.

As a "fix" I have added require => Package['php'] on the augeas.pp:

                 $changes = $ensure ? {
                           present => [ "set '${entry}' '${value}'" ],
                           absent  => [ "rm '${entry}'" ],
                           require => Package['php'],
                                       }

                 augeas { "php_ini-${name}":
                           incl    => $target,
                           lens    => 'Php.lns',
                           changes => $changes,
                           require => Package['php'],
                                      }

and now works as expected.

I am wondering, how can I change the behaviour without modifying the module or creating a wrapper class?

Thanks

php::module {'mcrypt':} requires epel

I have

include ::epel

I've tried to set:

class {'php':
  require => Class['epel']
}
php::module {'mcrypt':}

and

Class['epel']->Php::Module['mcrypt']

but no luck. Upon second puppet run it works fine but first run it doesn't apply epel and refresh before trying to install mcrypt

Calling a single PECL module fails.

If you do the following on a fresh install of CentOS 6 with the latest git clones of puppet-php/puppi and the latest package of puppet from the puppetlabs repo:

node default {

    class { 'php': }
    php::pecl::module{'amqp': use_package => 'false'; }

}

You will get this error:

Error: /Stage[main]//Node[default]/Php::Pecl::Module[amqp]/Exec[pecl-amqp]: Could not evaluate: Could not find command 'pecl'

I've also seen an error referring to a require for php::pear not being satisfied. You need to add a one line include in pecl/module.pp of include php::pear near the one for php::devel. There's a requirement for it later but it's never actually included.

Mongo cannot be found

Hello @example42!

First of all, thanks for sharing this useful module.

I'm facing some problems when trying to install the mongo extension:

$host_name = "bookess.dev"
$doc_root = "/var/www/bookess/web/"

group { 'puppet': ensure => present }
Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] }
File { owner => 0, group => 0, mode => 0644 }

file { "/dev/shm/bookess":
  ensure => directory,
  purge => true,
  force => true,
  owner => vagrant,
  group => vagrant
}

file { "/var/lock/apache2":
  ensure => directory,
  owner => vagrant
}

exec { "ApacheUserChange" :
  command => "sed -i 's/export APACHE_RUN_USER=.*/export APACHE_RUN_USER=vagrant/ ; s/export APACHE_RUN_GROUP=.*/export APACHE_RUN_GROUP=vagrant/' /etc/apache2/envvars",
  require => [ Package["apache"], File["/var/lock/apache2"] ],
  notify  => Service['apache'],
}

class {'apt':
  always_apt_update => true,
}

Class['::apt::update'] -> Package <|
    title != 'python-software-properties'
and title != 'software-properties-common'
|>

apt::key { '4F4EA0AAE5267A6C': }

apt::ppa { 'ppa:ondrej/php5-oldstable':
  require => Apt::Key['4F4EA0AAE5267A6C']
}

package { [
    'build-essential',
    'vim',
    'curl',
    'git-core',
    'mc'
  ]:
  ensure  => 'installed',
}

class { 'apache': }

apache::dotconf { 'custom':
  content => 'EnableSendfile Off',
}

apache::module { 'rewrite': }

apache::vhost { "${host_name}":
  server_name   => "${host_name}",
  serveraliases => [
    "www.${host_name}"
  ],
  docroot       => "${doc_root}",
  port          => '80',
  env_variables => [
    'VAGRANT VAGRANT'
  ],
  priority      => '1',
}

class { 'php':
  service             => 'apache',
  service_autorestart => false,
  module_prefix       => '',
}

php::module { 'php5-mysql': }
php::module { 'php5-cli': }
php::module { 'php5-curl': }
php::module { 'php5-intl': }
php::module { 'php5-mcrypt': }
php::module { 'php5-gd': }
php::module { 'php-apc': }

class { 'php::devel':
  require => Class['php'],
}

class { 'php::pear':
  require => Class['php'],
}

php::pear::module { 'PHPUnit':
  repository  => 'pear.phpunit.de',
  use_package => 'no',
  require => Class['php::pear']
}

php::pecl::module { 'mongo': }

php::pecl::module { 'xdebug': }

class { 'composer':
  command_name => 'composer',
  target_dir   => '/usr/local/bin',
  auto_update => true,
  require => Package['php5', 'curl'],
}

php::ini { 'php_ini_configuration':
  value   => [
    'date.timezone = "UTC"',
    'display_errors = On',
    'error_reporting = -1',
    'short_open_tag = 0',
    'memory_limit = 128M',
    'xdebug.default_enable = 1',
    'xdebug.remote_autostart = 0',
    'xdebug.remote_connect_back = 1',
    'xdebug.remote_enable = 1',
    'xdebug.remote_handler = "dbgp"',
    'xdebug.remote_port = 9000'
  ],
  notify  => Service['apache'],
  require => Class['php']
}
err: /Stage[main]//Php::Pecl::Module[mongo]/Package[php-mongo]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install php5-mongo' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package php5-mongo

I added the ppa manually but it didn't work:

apt::key { '4F4EA0AAE5267A6C': }

apt::ppa { 'ppa:ondrej/php5-oldstable':
  require => Apt::Key['4F4EA0AAE5267A6C']
}

apt::ppa { 'ppa:chris-lea/mongodb-drivers': 
    require => Apt::Key['4F4EA0AAE5267A6C']
}
err: /Stage[main]//Php::Pecl::Module[mongo]/Package[php-mongo]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install php5-mongo' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php5-mongo : Depends: phpapi-20090626
E: Unable to correct problems, you have held broken packages.

Do you have any idea how can I solve that?

Thanks in advance.

PHP PECL php.ini

Hi,
The pecl::module.pp updates php.ini file after installing the required module.
Would it not be better to have it update/create php.d/.ini file instead and add within it extension=.so ?
I think it is much neater when some extensions (ex: xdebug) require additional configs.

Express (or document) dependency between PHP modules and mods

I think that there is a dependency between modules and mods, which should either be expressed in puppet, or be document so that people express them in their manifests.

I'll explain: before being to enable for example mod "sqlite3", you need to install the module "sqlite" first:

php::module { 'sqlite': } -> php::mod { 'sqlite3': }

Once you think about it, it's logical, but it's not what I had expected. If you omit the ->, your system may or may not be set up correctly after the first run of puppet, depending on the (random) order of execution.

From the documentation, I had expected that you declare things and you're fine, I still think that that would be the ideal behavior. I am not sure how this would have to be done in puppet-php. If it is not possible, it should at least be documented.

Support array for installing pear modules

It would be nice to install multiple PEAR modules with one call like this:

php::pear::module { ["Cache_Lite", "Crypt_RC4" ]:
alldeps => 'true',
use_package => 'false',
}

Missing variables and documentation

This role is missing some of its parameter definitions. While the work around is easy (define them) its unfortunate to find out they are missing by running the module.

I noticed that some of the missing variables (like those related to monitoring) are also missing from the documentation at the top of init.pp - I'm guessing some integration has gone awry somewhere.

# puppet agent --test --verbose
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Undefined variable "::php::params::monitor_tool"; Undefined variable "monitor_tool" at [...]
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Undefined variable "::php::params::monitor_target"; Undefined variable "monitor_target" at [...]
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Undefined variable "::php::params::config_file_init"; Undefined variable "config_file_init" at [...]
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Undefined variable "::php::params::pid_file"; Undefined variable "pid_file" at [...]

There might be others missing but this was the point where i stopped for today.

PHP5-FPM conf and Nginx vhost bug

I am using netmanagers/puppet-nginx and example42/puppet-php for vagrant machine.
I have installed the php module like this:

group { 'puppet': ensure => present }

Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] }
File { owner => 0, group => 0, mode => 0644 }

class { 'apt':
    always_apt_update => true,
}

Class['::apt::update'] -> Package <|
    title != 'python-software-properties'
    and title != 'software-properties-common'
|>

# Package Configurations.
$sysPackages = ['vim', 'ntp']
package { $sysPackages:
    ensure => 'installed',
}

# Apache Web-Server Configurations.
class { 'apache':
  disable => true
}

# Nginx Web-Server Configurations.
class { 'nginx':
    worker_connections      => 4096,
    keepalive_timeout       => 120,
    client_max_body_size    => '1024m',
    types_hash_max_size     => '2048',
}

nginx::resource::vhost { 'axisthemes.dev' :
    fastcgi => present,
    www_root => '/var/www/axisthemes',
}

# PHP Module Configurations.
class { 'php':
    service => 'nginx',
}

class { 'php::devel':
    require => Class['php'],
}

$phpModules = ['fpm', 'gd', 'imagick', 'mysql', 'cli', 'common', 'curl', 'intl', 'mcrypt', 'cgi', 'memcache']
php::module { $phpModules: }

$peclModules = ['xdebug']
php::pecl::module { $peclModules: }

I want to use the default fastcgi template and won't prefer to build my own. So the problem is that I receive 502 Bad Gateway. I figure out that the /etc/php5/fpm/pool.d/www.conf has this kind of setting:

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php5-fpm.sock ### Note-1: we have to deal with this line.

But puppet-nginx will generate this kind of setting:

  location ~ \.php$ {
    try_files $uri =404;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    ### Note-2: this line won't match Note-1.
    fastcgi_pass  unix:/var/run/php5-fpm-www-data.sock; 

    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO        $fastcgi_script_name;
    include fastcgi_params;
  }

This above is generated from puppet-nginx/templates/vhost/vhost_fastcgi.erb:

  location ~ \.php$ {
    try_files $uri =404;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    fastcgi_pass  unix:/var/run/php5-fpm-<%= @real_owner %>.sock;

    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO        $fastcgi_script_name;
    include fastcgi_params;
  }

So the solution to get rid of 502 Bad Gateway is inject <%= @real_owner %> in /etc/php5/fpm/pool.d/www.conf like this:

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php5-fpm-<%= @real_owner %>.sock ### Note-1: This is the solution how to achieve this kind of settings.

php pear wrong version installed

Hi,

I am using php55 and the wrong version of pear package is installed before the php55 and also before the repository. To fix this I have added a require in the php::pear class like below.

package { 'php-pear':
ensure => $version,
name => $package,
install_options => $real_install_options,
require => Package[$php::package],
}

Is there any other way recommended I can use to fix this without modifying the module?

Many thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.