Puppet Class: uhosting::profiles::php

Defined in:
manifests/profiles/php.pp

Overview

Class: uhosting::profiles::php

Installs and manages PHP, including uWSGI plugin installation

Authors

Tobias Brunner <tobias.brunner@vshn.ch>

Copyright 2015 Tobias Brunner, VSHN AG

Parameters:

  • php_version (Any) (defaults to: '5.5')


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'manifests/profiles/php.pp', line 13

class uhosting::profiles::php (
  $php_version = '5.5',
) {

  if defined(Class['uhosting::profiles::uwsgi']) {
    package {
      'uwsgi-plugin-php':
        ensure  => installed,
        require => Package['uwsgi-core'];
    }
  }

  $_version_repo = $php_version ? {
    '5.4' => 'ondrej/php5-oldstable',
    '5.5' => 'ondrej/php5',
    '5.6' => 'ondrej/php5-5.6',
    '7.0' => 'ondrej/php-7.0',
  }

  if $php_version == '7.0' {
    $config_root_ini = '/etc/php/7.0'
    $ext_tool_enable = '/usr/sbin/phpenmod'
    $ext_tool_query = '/usr/sbin/phpquery'
    $package_prefix = 'php7.0-'
    $fpm_service_name = 'php7.0-fpm'
    $cfg_root = '/etc/php/7.0'
  } else {
    $config_root_ini = undef
    $ext_tool_enable = undef
    $ext_tool_query = undef
    $package_prefix = undef
    $fpm_service_name = undef
    $cfg_root = undef
  }

  apt::source { 'sury_php_ppa':
    comment  => 'PHP PPA of Ondrej Sury',
    location => "http://ppa.launchpad.net/${_version_repo}/ubuntu",
    release  => $::lsbdistcodename,
    repos    => 'main',
    key      => {
      'id'     => '14AA40EC0831756756D7F66C4F4EA0AAE5267A6C',
      'server' => 'keyserver.ubuntu.com',
    },
    include  => {
      'src' => true,
      'deb' => true,
    },
  } ->
  class { '::php::params':
    cfg_root => $cfg_root,
  } ->
  class { '::php':
    manage_repos    => false,
    fpm             => true,
    dev             => true,
    composer        => true,
    pear            => true,
    phpunit         => false,
    config_root_ini => $config_root_ini,
    ext_tool_enable => $ext_tool_enable,
    ext_tool_query  => $ext_tool_query,
    package_prefix  => $package_prefix,
    extensions      => {
      #'imagick'     => { 'provider' => 'apt' },
      #'gmp'         => { 'provider' => 'apt' },
      #'mcrypt'      => { 'provider' => 'apt' },
      #'json'        => { 'provider' => 'apt' },
      #'mysqlnd'     => { 'provider' => 'apt' },
    },
    require         => Exec['apt_update'],
  }
  Service <| tag == 'php5-fpm' |> {
    name   => $fpm_service_name,
    enable => false,
    ensure => stopped,
  }

}