Giter Club home page Giter Club logo

puppet-phpfpm's Introduction

puppet-phpfpm

Build Status

Overview

This module manages the php-fpm daemon and pools only. Managing php, php extensions, pear, pecl, nginx, apache, etc are out of the scope of this module.

The module has been tested on Ubuntu, CentOS/RHEL, Archlinux and Amazon AMI.

  • phpfpm : Class that installs and configures php-fpm itself.
  • phpfpm::pool : Definition used to configure a fpm pool

Parameters

The name of the parameters mirror the name of the config variables in the php-fpm configuration file and the pool configuration file. However, be sure to replace periods with underscores, as puppet does not support parameter names with periods.

For example, if your pool configuration should set the pm.status_path option to "/mystatus", the pm.max_requests option to "900", and chroot to "/www", you would use the following parameters in your manifest:

phpfpm::pool { 'mypool':
    chroot          => '/www',
    pm_status_path  => '/mystatus',
    pm_max_requests => 900,
}

Please see the php-fpm configuration file comments for detailed explanations about what each option does.

Custom Parameters

$phpfpm::poold_purge : Delete all files in the pool.d folder that aren't managed by Puppet.

Examples

You must include the phpfpm class prior to configuring pools.

Install php-fpm with default options and a default pool called 'www' (packaging defaults on Ubuntu).

include phpfpm

Install php-fpm with non-default options:

class { 'phpfpm':
    process_max => 20,
    log_level   => 'warning',
    error_log   => '/var/log/phpfpm.log',
}

Install php-fpm and remove the default pool that ships with Ubuntu:

include phpfpm

phpfpm::pool { 'www':
    ensure => 'absent',
}

Do the same and add a pool named "main":

include phpfpm

phpfpm::pool { 'www':
    ensure => 'absent',
}

# TCP pool using 127.0.0.1, port 9000, upstream defaults
phpfpm::pool { 'main': }

Alternatively, use the purge flag to remove all non-managed pools, then create a pool named "main":

class { 'phpfpm':
    poold_purge => true,
}

# TCP pool using 127.0.0.1, port 9000, upstream defaults
phpfpm::pool { 'main': }

Use a custom template file, which you must provide, to generate the main FPM configuration file:

class { 'phpfpm':
    config_template_file => 'site/phpfpm/my-php-fpm.conf.erb',
}

Add a few custom pools with advanced options:

class { 'phpfpm':
    poold_purge => true,
}

# Pool running as a different user
phpfpm::pool { 'user_bob':
    listen => '127.0.0.1:9999',
    user   => 'bob',
    group  => 'users',
}

# Pool with dynamic process manager, TCP socket
phpfpm::pool { 'main':
    listen                 => '127.0.0.1:9000',
    listen_allowed_clients => '127.0.0.1',
    pm                     => 'dynamic',
    pm_max_children        => 10,
    pm_start_servers       => 4,
    pm_min_spare_servers   => 2,
    pm_max_spare_servers   => 6,
    pm_max_requests        => 500,
    pm_status_path         => '/status',
    ping_path              => '/ping',
    ping_response          => 'pong',
    env                    => {
        'ODBCINI' => '"/etc/odbc.ini"',
    },
    php_admin_flag         => {
        'expose_php' => 'Off',
    },
    php_admin_value        => {
        'max_execution_time' => '300',
    },
}

# Pool using a custom template file that you provide, rather than the stock template
phpfpm::pool { 'www':
    listen             => '127.0.0.1:9001',
    pool_template_file => 'site/phpfpm/mypool.conf.erb',
}

Notify the php-fpm daemon of your custom php configuration changes:

class { 'phpfpm':
    poold_purge => true,
}

phpfpm::pool { 'main': }

file { '/etc/php5/conf.d/pdo.ini':
    ensure  => 'present',
    content => template('web/pdo.ini.erb'),
    notify  => Class['phpfpm::service'],
}

puppet-phpfpm's People

Contributors

amd1212 avatar aries1980 avatar arthurbarton avatar hekmon avatar igalic avatar insertjokehere avatar lukepeterson avatar pascalbourdier avatar prannonpendragas avatar pschichtel avatar rabie-zamane avatar roberthawdon avatar slashbunny avatar smerrill avatar smortex avatar theosotr avatar timmooney avatar tprobinson avatar trefzer avatar yazmatazz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

puppet-phpfpm's Issues

validate compatibility with Puppet 7 (and 8?)

I'm not familiar with the CI infrastructure so this may be an ignorant question, but are there plans to validate phpfpm module compatibility with Puppet 7 and potentially Puppet 8?

After a lot of step-wise upgrades of Forge modules, Slashbunny-phpfpm is the last module we use that doesn't claim support for Puppet 7 (or 8). I expect it will work just fine on at least Puppet 7. I haven't looked at what's changed with 8 so no idea there.

phpfpm::pool::service_name and ::pool_dir should use ::phpfpm::service_name and ::pool_dir for defaults

lf you are overriding service_name and pool_dir in ::phpfpm context, wouldn't it be nice to have that trickle down to the phpfpm::pool space as well. Seems redundant to have to specify it in to places.

As it is now, I have to do something like the following:

phpfpm::pool_dir: /etc/php-fpm-5.5.d
phpfpm::service_name: php-fpm-5.5
phpfpm::pools:
  test:
    pool_dir: /etc/php-fpm-5.5.d
    service_name: php-fpm-5.5

it would be nice to only have to do:

phpfpm::pool_dir: /etc/php-fpm-5.5.d
phpfpm::service_name: php-fpm-5.5
phpfpm::pools:
  test:

Att support for clear_env i pool template

Thanks for an excellent module.

I cannot add "clear_env no" to the pool configuration since it is missing in the pool template.
Would be nice if you can add support for it.

Parameter "require" is redefined when pool.d content is purged

Commit 1497074 seems to have introduced a bug:

Parameter 'require' is already set on File[/etc/php/7.0/fpm/pool.d] by #<Puppet::Resource::Type:0x6f247f81> at (file: /etc/puppetlabs/code/environments/production/modules/phpfpm/manifests/init.pp, line: 63); cannot redefine (file: /etc/puppetlabs/code/environments/production/modules/phpfpm/manifests/init.pp, line: 71)

I'm setting phpfpm::poold_purge to true via Hiera. The require property is set twice.

Support for Ubuntu Xenial

This module does not work as expected on Ubuntu Xenial (16.04), because Xenial ships packages for php7, not php5.

The package is now called php7.0-fpm, although there is a new virtual package called php-fpm that just installed the supported version, which might be a better choice.

The service is now php7.0-fpm. Some paths have also changed:

Trusty Xenial
/etc/php5/fpm/php-fpm.conf /etc/php/7.0/fpm/php-fpm.conf
/etc/php5/fpm/pool.d /etc/php/7.0/fpm/pool.d
/var/run/php5-fpm.pid ??
/var/log/php5-fpm.log ??

Amazon AMI Support

Small fix, I know ::operatingsystem is being deprecated which you could use 'amazon' on but for ::osfamily it's just 'linux'.

phpfpm/manifests/params.pm

Line 69:
-'redhat': {
+'redhat', 'linux': {

Purge too early

On Debian Jessie, when having poold_purge => true while doing a fresh installation of PHP-FPM, the installation via APT will fail because no pool definition is defined

Default $pool_dir for Redhat has extra slash

manifests/params.pp oversupplies an extra slash for $pool_dir in redhat-systems at line 143
$pool_dir = '/etc/php-fpm.d/'

This results in a wrong path in php-fpm.conf:
include=/etc/php-fpm.d//*.conf

Temoporary solution:
class { 'phpfpm': pool_dir => '/etc/php-fpm.d', }

phpfpm::pool ensure absent not working

phpfpm::pool { 'www':
ensure => 'absent',
...
}

give the following error:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid relationship: File[/etc/php-fpm.d/www.conf] { notify => Service[php-fpm] }, because Service[php-fpm] doesn't seem to be in the catalog

Support for Debian 11 (bullseye)

Debian 11 is shipped with php7.4-fpm.
Which should be just a another elsif in params.pp:

        elsif $facts['os']['name'] == 'Debian' and '11' in String($facts['os']['release']['major']) {
        $package_name                   = 'php7.4-fpm'                          
        $service_name                   = 'php7.4-fpm'                          
        $config_dir                     = '/etc/php/7.4/fpm'                    
        $pid_file                       = '/run/php/php7.4-fpm.pid'         
        $error_log                      = '/var/log/php7.4-fpm.log'
        }

Thanks for the great module

Greetings

parameter errors in pool.pp with the future parser

We've been using your phpfpm module for more than a year on RHEL 6 and RHEL 7, with good success. We're now on puppet 3.8.7 (both client and server) using the traditional, open source puppet stack. We're in the process of testing the modules we use to see if they'll work with puppet 4.x.

Two of the steps in that testing process are to set stringify_facts = false and to set parser = future, as described here:

https://docs.puppet.com/puppet/latest/reference/upgrade_major_pre.html

The future parser seems to object to the sanity checking for the pool min/max/spare settings:

Error: Evaluation Error: Error while evaluating a Function Call, pm_start_servers(5) must not be less than pm_min_spare_servers(5) and not greater than pm_max_spare_servers(35) at /etc/puppet/environments/production/forge-modules/phpfpm/manifests/pool.pp:63:5 on node somenode.ndsu.edu

This is phpfm::pool code in our module that's triggering that error:

  $pool_name    = 'www'
  $pool_port    = 9000
  $pool_status  = "/${pool_name}-status"
  $pool_ping    = "/${pool_name}-ping"
  $pool_timeout = '120'
  phpfpm::pool { $pool_name:
    ensure                 => present,
    listen                 => "127.0.0.1:${pool_port}",
    listen_allowed_clients => '127.0.0.1',
    pm_max_children        => 50,
    pm_start_servers       => 5,
    pm_min_spare_servers   => 5,
    pm_max_spare_servers   => 35,
    pm_status_path         => $pool_status,
    ping_path              => $pool_ping,
    chdir                  => false,
    slowlog                => '/var/log/php-fpm/www-slow.log',
    php_admin_value        => {
      'error_log'      => '/var/log/php-fpm/www-error.log',
      'include_path'   => '/var/local/php/include/apps:/var/local/php/include/global',
      'log_errors'     => 'on',
      'open_basedir'   => '/var/local/php/include/apps:/var/local/php/include/global:/var/www/html:/var/local/php/upload',
      'upload_tmp_dir' => '/var/local/php/upload',
    },
    php_value              => {
      'session.save_handler'  => 'files',
      'session.save_path'     => '/opt/rh/php54/root/var/lib/php/session',
    },
    service_name           => 'php54-php-fpm',
    pool_dir               => '/opt/rh/php54/root/etc/php-fpm.d',
    pool_template_file     => 'site/phpfpm/pool-redhat.conf.erb',
  }

It's only under parser = future that we see the error. It works fine using the traditional parser.

Anyone else run into issues when using phpfpm with the future parser?

phpfpm::pool does not generate file as expected

Hello,

I'm very new to puppet so I'm sure this is something that I didnt do correctly but I could not figure out the issue:

I use https://puphpet.com/ to generate the code base I need to setup my dev environment with Vagrant. However, I want to use this module to easily manage the fpm pool so I installed the module and made some small changes to the Nginx.pp node to try it out:

http://www.sourcepod.com/qgajpv94-64021

Not sure what I did wrong but it seems like the phpfpm file never got created?

Support for Ubuntu 20.04 LTS

Thanks for an excellent module.

PHP-FPM is at version 7.4 on Ubuntu 20.04 LTS and that means new directories.
Need to add support for 7.4 in the default paths.

A temporary solution (if found using web search) is to add a bunch of parameters.

The parameters are pid_file, package_name, service_name, config_dir, error_log and pool_dir.
I needed to add pool_dir on to the main class and on phpfpm::pool.

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.