voxpupuli/puppet-php

Issue with PHP Common and PHP Cli

OAuthority opened this issue · 2 comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.26.0
  • Distribution: Ubuntu 22.04
  • Module version: 10.0

How to reproduce (e.g Puppet code you use)

class mediawiki::php {
  $php_version = '7.4'
  $package_prefix = "php${php_version}-"

  # First, include the php::globals class and set global defaults
  class { 'php::globals':
    php_version => $php_version,
    config_root => "/etc/php/${php_version}",
  }

  # Ensure the PHP packages are installed before managing the PHP-FPM pool
  class { 'php::packages':
    ensure => present,
    manage_repos => true,
  }

  # Include and configure the PHP-FPM service
  class { 'php::fpm':
    user                        => 'www-data',
    group                       => 'www-data',
    service_ensure              => 'running',
    service_enable              => true,
    service_name                => "php${php_version}-fpm",
    package                     => "php${php_version}-fpm",
    inifile                     => "/etc/php/${php_version}/fpm/php.ini",
    pools                       => { 'www' => { 'listen' => "/var/run/php/php${php_version}-fpm.sock" } },
    log_owner                   => 'www-data',
    global_pool_settings        => {},
    log_group                   => 'www-data',
    pool_purge                  => false,
    reload_fpm_on_config_changes => true,
    settings                    => {
      'PHP/max_execution_time'  => '90',
      'PHP/max_input_time'      => '300',
      'PHP/memory_limit'        => '128M',
      'PHP/post_max_size'       => '32M',
      'PHP/upload_max_filesize' => '32M',
      'Date/date.timezone'      => 'UTC',
    },
    require => Class['php::packages'], # Ensure php::fpm is applied after php::packages
  }

  # Manage the PHP-FPM pool for MediaWiki
  php::fpm::pool { 'mediawiki':
    listen                  => "/var/run/php/php${php_version}-fpm-mediawiki.sock",
    pm                      => 'dynamic',
    pm_max_children         => 5,
    pm_start_servers        => 2,
    pm_min_spare_servers    => 2,
    pm_max_spare_servers    => 6,
    pm_max_requests         => 100,
  }

  # Install required PHP extensions for MediaWiki
  $extensions = [
    'gd',
    'curl',
    'intl',
    'mbstring',
    'mysqli',
    'xml',
    'zip',
  ]

  # Ensure each PHP extension is installed
  $extensions.each |String $extension| {
    package { "${package_prefix}${extension}":
      ensure => present,
    }
  }
}

What are you seeing

When running the agent, it installs the majority of the extensions defined, but fails at PHP Common and PHP Cli; no php.ini is generated.

What behaviour did you expect instead

PPH Common and PHP Cli should install, version 7.4, I believe.

Output log

Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install cli' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package cli
Error: /Stage[main]/Php::Packages/Package[cli]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install cli' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package cli
Debug: Executing: '/usr/bin/dpkg-query -W --showformat '${Status} ${Package} ${Version}\n' common'
Debug: Executing: '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install common'
Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install common' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package common
Error: /Stage[main]/Php::Packages/Package[common]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install common' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package common

Any additional information you'd like to impart

This is potentially me misconfiguring something, but I'm not sure. Also, I had to manually add the repository for php7.4, ppa:ondrej/php, which is what manage_repos should do, if I'm correct?

Perhaps I'm doing something wrong, here, but if I add:

class { '::php':
  ensure       => latest,
  manage_repos => true,
  fpm          => true,
  dev          => true,
  composer     => true,
  pear         => true,
  phpunit      => false,
}

I get an error that the php class isn't found; which I thought was weird, so I checked in /modules/php/manifests and It does not match the GitHub repo, the init.pp was missing? I manually created this, but this is obviously not ideal.

kenyon commented

Your module installation is broken if init.pp is missing.

You shouldn't be declaring the php::fpm and php::packages classes, they are private.