view modules/website/manifests/php.pp @ 321:cd1bcc06f09c

Actually install extra PHP packages Previously we were passing them and doing NOTHING with them!
author IBBoard <dev@ibboard.co.uk>
date Sun, 01 Mar 2020 10:58:46 +0000
parents 99e3ca448d55
children 0d263bcbbfe9
line wrap: on
line source

class website::php(
    $suffix = '',
    $module = undef,
    $opcache = undef,
    $extras = [],
    ) {
  Package <| tag == 'php-package' |> -> File <| tag == 'php-file' |> ~> Service['httpd']

  if $module != undef {
    $php_core = 'php'
    package { $php_core:
      provider => 'dnfmodule',
      ensure => $module,
      tag => 'php-package',
    }
  } else {
    if $suffix =~ /^7[1-9]w$/ {
      $php_core = "mod_php${suffix}"
    } else {
      $php_core = "php${suffix}"
    }
    package { $php_core:
      ensure => installed,
      tag => 'php-package',
    }
  }

  $packages = [ "php${suffix}-mbstring", "php${suffix}-xml", "php${suffix}-gd" ]
  package { $packages:
    ensure => installed,
    tag => 'php-package',
  }
  website::php::extra { $extras: }

  file { '/etc/php.d/custom-lockdown.ini':
    ensure => present,
    content => 'allow_url_fopen = \'off\'
    expose_php = Off',
    tag => 'php-file',
  }
  file { '/etc/php.d/custom-php.ini':
    ensure => present,
    source => 'puppet:///modules/website/custom-php.ini',
    tag => 'php-file',
  }

  if $opcache {
    package { "php${suffix}-${opcache}":
      ensure => installed,
      require => Package[$php_core],
      tag => 'php-package',
    }
    # Use Remi's (and the OS's) naming convention
    file { '/etc/php.d/opcache.ini':
      ensure => absent,
    }
    file { '/etc/php.d/10-opcache.ini':
      ensure => present,
      source => 'puppet:///modules/website/opcache.ini',
      tag => 'php-file',
    }
  }
}