diff --git a/manifests/apache_vhost.pp b/manifests/apache_vhost.pp index db635acb..3a5d70e1 100644 --- a/manifests/apache_vhost.pp +++ b/manifests/apache_vhost.pp @@ -18,11 +18,11 @@ # address of the fastcgi socket # define php::apache_vhost ( - $vhost = 'example.com', - $docroot = '/var/www', - $port = 80, - $default_vhost = true, - $fastcgi_socket = 'fcgi://127.0.0.1:9000/$1' + String[1] $vhost = 'example.com', + Stdlib::Absolutepath $docroot = '/var/www', + Integer[1] $port = 80, + Boolean $default_vhost = true, + String[1] $fastcgi_socket = 'fcgi://127.0.0.1:9000/$1' ) { ::apache::vhost { $vhost: docroot => $docroot, diff --git a/manifests/composer.pp b/manifests/composer.pp index c60beaf6..4177ee22 100644 --- a/manifests/composer.pp +++ b/manifests/composer.pp @@ -29,8 +29,8 @@ class php::composer ( String $source = $php::params::composer_source, Stdlib::Absolutepath $path = $php::params::composer_path, - $proxy_type = undef, - $proxy_server = undef, + Optional[String[1]] $proxy_type = undef, + Optional[String[1]] $proxy_server = undef, Php::ComposerChannel $channel = 'stable', Boolean $auto_update = true, Integer $max_age = $php::params::composer_max_age, diff --git a/manifests/composer/auto_update.pp b/manifests/composer/auto_update.pp index 2a58c6af..fe7a4f69 100644 --- a/manifests/composer/auto_update.pp +++ b/manifests/composer/auto_update.pp @@ -29,12 +29,12 @@ # } # class php::composer::auto_update ( - $max_age, - $source, - $path, + Integer[1] $max_age, + String[1] $source, + Stdlib::Absolutepath $path, Php::ComposerChannel $channel = 'stable', - $proxy_type = undef, - $proxy_server = undef, + Optional[String[1]] $proxy_type = undef, + Optional[String[1]] $proxy_server = undef, ) { assert_private() diff --git a/manifests/config/setting.pp b/manifests/config/setting.pp index 150b05b6..f65c19e2 100644 --- a/manifests/config/setting.pp +++ b/manifests/config/setting.pp @@ -19,8 +19,8 @@ # } # define php::config::setting ( - $key, - $value, + String[1] $key, + Variant[Integer, String[1]] $value, Stdlib::Absolutepath $file, ) { assert_private() diff --git a/manifests/fpm.pp b/manifests/fpm.pp index 821f9bea..370202e4 100644 --- a/manifests/fpm.pp +++ b/manifests/fpm.pp @@ -60,20 +60,20 @@ # This default will be changed in a future release. # class php::fpm ( - String $ensure = $php::ensure, - $user = $php::fpm_user, - $group = $php::fpm_group, - $service_ensure = $php::fpm_service_ensure, - $service_enable = $php::fpm_service_enable, - $service_name = $php::fpm_service_name, - $service_provider = $php::fpm_service_provider, + Optional[String] $ensure = $php::ensure, + String[1] $user = $php::fpm_user, + String[1] $group = $php::fpm_group, + Enum['running', 'stopped'] $service_ensure = $php::fpm_service_ensure, + Boolean $service_enable = $php::fpm_service_enable, + String[1] $service_name = $php::fpm_service_name, + Optional[String[1]] $service_provider = $php::fpm_service_provider, String $package = $php::real_fpm_package, Stdlib::Absolutepath $inifile = $php::fpm_inifile, Hash $settings = $php::real_settings, - $global_pool_settings = $php::real_fpm_global_pool_settings, + Hash $global_pool_settings = $php::real_fpm_global_pool_settings, Hash $pools = $php::real_fpm_pools, - $log_owner = $php::log_owner, - $log_group = $php::log_group, + String[1] $log_owner = $php::log_owner, + String[1] $log_group = $php::log_group, Boolean $pool_purge = $php::pool_purge, Boolean $reload_fpm_on_config_changes = $php::reload_fpm_on_config_changes, ) { diff --git a/manifests/fpm/config.pp b/manifests/fpm/config.pp index 140692d0..60fa953d 100644 --- a/manifests/fpm/config.pp +++ b/manifests/fpm/config.pp @@ -71,26 +71,26 @@ # Path to fpm pid file # class php::fpm::config ( - $config_file = $php::params::fpm_config_file, + Stdlib::Absolutepath $config_file = $php::params::fpm_config_file, String $user = $php::params::fpm_user, String $group = $php::params::fpm_group, String $inifile = $php::params::fpm_inifile, - $pid_file = $php::params::fpm_pid_file, + Stdlib::Absolutepath $pid_file = $php::params::fpm_pid_file, Hash $settings = {}, Stdlib::Absolutepath $pool_base_dir = $php::params::fpm_pool_dir, - $pool_purge = false, + Boolean $pool_purge = false, String $error_log = $php::params::fpm_error_log, String $log_level = 'notice', Integer $emergency_restart_threshold = 0, - Variant[Integer, Pattern[/^\d+[smhd]?$/]] $emergency_restart_interval = 0, - Variant[Integer, Pattern[/^\d+[smhd]?$/]] $process_control_timeout = 0, + Php::Duration $emergency_restart_interval = 0, + Php::Duration $process_control_timeout = 0, Integer $process_max = 0, - $rlimit_files = undef, - Optional[Variant[Integer,Pattern[/^\d+[smhd]?$/]]] $systemd_interval = undef, + Optional[Integer[1]] $rlimit_files = undef, + Optional[Php::Duration] $systemd_interval = undef, String $log_owner = $php::params::fpm_user, String $log_group = $php::params::fpm_group, Pattern[/^\d+$/] $log_dir_mode = '0770', - $root_group = $php::params::root_group, + String[1] $root_group = $php::params::root_group, String $syslog_facility = 'daemon', String $syslog_ident = 'php-fpm', ) inherits php::params { diff --git a/manifests/fpm/pool.pp b/manifests/fpm/pool.pp index 67ac5751..385e2a70 100644 --- a/manifests/fpm/pool.pp +++ b/manifests/fpm/pool.pp @@ -121,49 +121,49 @@ # '/etc/php5/fpm/pool.d' or '/etc/php-fpm.d' # define php::fpm::pool ( - $ensure = 'present', - $listen = '127.0.0.1:9000', - $listen_backlog = '-1', - $listen_allowed_clients = undef, - $listen_owner = undef, - $listen_group = undef, - $listen_mode = undef, - $user = $php::fpm::config::user, - $group = $php::fpm::config::group, + Enum['present', 'absent'] $ensure = 'present', + String[1] $listen = '127.0.0.1:9000', + Integer[-1] $listen_backlog = -1, + Optional[String[1]] $listen_allowed_clients = undef, + Optional[String[1]] $listen_owner = undef, + Optional[String[1]] $listen_group = undef, + Optional[Stdlib::Filemode] $listen_mode = undef, + String[1] $user = $php::fpm::config::user, + String[1] $group = $php::fpm::config::group, Optional[String[1]] $apparmor_hat = undef, - $pm = 'dynamic', - $pm_max_children = '50', - $pm_start_servers = '5', - $pm_min_spare_servers = '5', - $pm_max_spare_servers = '35', - $pm_max_requests = '0', - $pm_process_idle_timeout = '10s', - $pm_status_path = undef, - $ping_path = undef, - $ping_response = 'pong', - $access_log = undef, - $access_log_format = '"%R - %u %t \"%m %r\" %s"', - $request_terminate_timeout = '0', - $request_slowlog_timeout = '0', - $security_limit_extensions = undef, - $slowlog = "/var/log/php-fpm/${name}-slow.log", - $template = 'php/fpm/pool.conf.erb', - $rlimit_files = undef, - $rlimit_core = undef, - $chroot = undef, - $chdir = undef, - $catch_workers_output = 'no', - $include = undef, - $env = [], - $env_value = {}, - $clear_env = true, - $options = {}, - $php_value = {}, - $php_flag = {}, - $php_admin_value = {}, - $php_admin_flag = {}, - $php_directives = [], - $root_group = $php::params::root_group, + String[1] $pm = 'dynamic', + Integer[1] $pm_max_children = 50, + Integer[1] $pm_start_servers = 5, + Integer[0] $pm_min_spare_servers = 5, + Integer[0] $pm_max_spare_servers = 35, + Integer[0] $pm_max_requests = 0, + Php::Duration $pm_process_idle_timeout = '10s', + Optional[Stdlib::Absolutepath] $pm_status_path = undef, + Optional[Stdlib::Absolutepath] $ping_path = undef, + String[1] $ping_response = 'pong', + Optional[Stdlib::Absolutepath] $access_log = undef, + String[1] $access_log_format = '"%R - %u %t \"%m %r\" %s"', + Php::Duration $request_terminate_timeout = 0, + Php::Duration $request_slowlog_timeout = 0, + Array[String[1]] $security_limit_extensions = [], + Stdlib::Absolutepath $slowlog = "/var/log/php-fpm/${name}-slow.log", + String[1] $template = 'php/fpm/pool.conf.erb', + Optional[Integer] $rlimit_files = undef, + Optional[Integer] $rlimit_core = undef, + Optional[Stdlib::Absolutepath] $chroot = undef, + Optional[Stdlib::Absolutepath] $chdir = undef, + Enum['yes', 'no'] $catch_workers_output = 'no', + Optional[String[1]] $include = undef, + Array[String[1]] $env = [], + Hash $env_value = {}, + Boolean $clear_env = true, + Hash $options = {}, + Hash $php_value = {}, + Hash $php_flag = {}, + Hash $php_admin_value = {}, + Hash $php_admin_flag = {}, + Array[String[1]] $php_directives = [], + String[1] $root_group = $php::params::root_group, Optional[Stdlib::Absolutepath] $base_dir = undef, ) { # The base class must be included first because it is used by parameter defaults diff --git a/manifests/fpm/service.pp b/manifests/fpm/service.pp index 5ef8f3e3..6551c718 100644 --- a/manifests/fpm/service.pp +++ b/manifests/fpm/service.pp @@ -21,10 +21,10 @@ # This default will be changed in a future release. # class php::fpm::service ( - $service_name = $php::fpm::service_name, - $ensure = $php::fpm::service_ensure, - $enable = $php::fpm::service_enable, - $provider = $php::fpm::service_provider, + String[1] $service_name = $php::fpm::service_name, + Enum['running', 'stopped'] $ensure = $php::fpm::service_ensure, + Boolean $enable = $php::fpm::service_enable, + Optional[String[1]] $provider = $php::fpm::service_provider, Boolean $reload_fpm_on_config_changes = $php::fpm::reload_fpm_on_config_changes, ) { if ! defined(Class['php::fpm']) { diff --git a/manifests/globals.pp b/manifests/globals.pp index 04ce1c6f..d1bda944 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -15,15 +15,13 @@ # The mode specifies the specifics in paths for the various RedHat SCL environments so that the module is configured # correctly on their pathnames. # -# Valid modes are: 'rhscl', 'remi' -# class php::globals ( Optional[Pattern[/^(rh-)?(php)?[57](\.)?[0-9]/]] $php_version = undef, Optional[Stdlib::Absolutepath] $config_root = undef, Optional[Stdlib::Absolutepath] $fpm_pid_file = undef, - $rhscl_mode = undef, + Optional[Enum['rhscl', 'remi']] $rhscl_mode = undef, ) { $default_php_version = $facts['os']['name'] ? { 'Debian' => $facts['os']['release']['major'] ? { diff --git a/manifests/init.pp b/manifests/init.pp index 7d2fc82d..3ec00ed4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -137,16 +137,16 @@ String $ensure = $php::params::ensure, Boolean $manage_repos = $php::params::manage_repos, Boolean $fpm = true, - $fpm_service_enable = $php::params::fpm_service_enable, - $fpm_service_ensure = $php::params::fpm_service_ensure, - $fpm_service_name = $php::params::fpm_service_name, - $fpm_service_provider = undef, + Boolean $fpm_service_enable = $php::params::fpm_service_enable, + Enum['running', 'stopped'] $fpm_service_ensure = $php::params::fpm_service_ensure, + String[1] $fpm_service_name = $php::params::fpm_service_name, + Optional[String[1]] $fpm_service_provider = undef, Hash $fpm_pools = $php::params::fpm_pools, Hash $fpm_global_pool_settings = {}, - $fpm_inifile = $php::params::fpm_inifile, - $fpm_package = undef, - $fpm_user = $php::params::fpm_user, - $fpm_group = $php::params::fpm_group, + Stdlib::Absolutepath $fpm_inifile = $php::params::fpm_inifile, + Optional[String[1]] $fpm_package = undef, + String[1] $fpm_user = $php::params::fpm_user, + String[1] $fpm_group = $php::params::fpm_group, Boolean $embedded = false, Boolean $dev = true, Boolean $composer = true, @@ -154,12 +154,12 @@ String $pear_ensure = $php::params::pear_ensure, Boolean $phpunit = false, Boolean $apache_config = false, - $proxy_type = undef, - $proxy_server = undef, + Optional[String[1]] $proxy_type = undef, + Optional[String[1]] $proxy_server = undef, Hash $extensions = {}, Hash $settings = {}, Hash $cli_settings = {}, - $package_prefix = $php::params::package_prefix, + Optional[String[1]] $package_prefix = $php::params::package_prefix, Stdlib::Absolutepath $config_root_ini = $php::params::config_root_ini, Stdlib::Absolutepath $config_root_inifile = $php::params::config_root_inifile, Optional[Stdlib::Absolutepath] $ext_tool_enable = $php::params::ext_tool_enable, diff --git a/manifests/params.pp b/manifests/params.pp index ec28c517..9d7d975f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -18,7 +18,7 @@ 'www' => { 'catch_workers_output' => 'no', 'listen' => '127.0.0.1:9000', - 'listen_backlog' => '-1', + 'listen_backlog' => -1, 'pm' => 'dynamic', 'pm_max_children' => 50, 'pm_max_requests' => 0, diff --git a/manifests/phpunit/auto_update.pp b/manifests/phpunit/auto_update.pp index 985c4777..6e7b228c 100644 --- a/manifests/phpunit/auto_update.pp +++ b/manifests/phpunit/auto_update.pp @@ -12,9 +12,9 @@ # Holds path to the phpunit executable # class php::phpunit::auto_update ( - $max_age, - $source, - $path, + Integer[1] $max_age, + String[1] $source, + Stdlib::Absolutepath $path, ) { assert_private() diff --git a/manifests/repo/debian.pp b/manifests/repo/debian.pp index 5dd4d507..20808e77 100644 --- a/manifests/repo/debian.pp +++ b/manifests/repo/debian.pp @@ -24,16 +24,16 @@ # Enable special sury handling # class php::repo::debian ( - $location = 'https://packages.dotdeb.org', - $release = 'wheezy-php56', - $repos = 'all', - $include_src = false, - $key = { + String[1] $location = 'https://packages.dotdeb.org', + String[1] $release = 'wheezy-php56', + String[1] $repos = 'all', + Boolean $include_src = false, + Hash $key = { 'id' => '6572BBEF1B5FF28B28B706837E3F070089DF5277', 'source' => 'http://www.dotdeb.org/dotdeb.gpg', }, - $dotdeb = true, - $sury = true, + Boolean $dotdeb = true, + Boolean $sury = true, ) { assert_private() diff --git a/manifests/repo/redhat.pp b/manifests/repo/redhat.pp index 16cad240..33688f4e 100644 --- a/manifests/repo/redhat.pp +++ b/manifests/repo/redhat.pp @@ -7,7 +7,7 @@ # class php::repo::redhat ( - $yum_repo = 'remi_php56', + String[1] $yum_repo = 'remi_php56', ) { $releasever = $facts['os']['name'] ? { /(?i:Amazon)/ => '6', diff --git a/manifests/repo/suse.pp b/manifests/repo/suse.pp index 9c02f5bb..d2ee7199 100644 --- a/manifests/repo/suse.pp +++ b/manifests/repo/suse.pp @@ -9,8 +9,8 @@ # Base URL of the Zypper repository # class php::repo::suse ( - $reponame = 'mayflower-php56', - $baseurl = 'http://download.opensuse.org/repositories/home:/mayflower:/php5.6_based/SLE_11_SP3/', + String[1] $reponame = 'mayflower-php56', + String[1] $baseurl = 'http://download.opensuse.org/repositories/home:/mayflower:/php5.6_based/SLE_11_SP3/', ) { zypprepo { $reponame: baseurl => $baseurl, diff --git a/manifests/repo/ubuntu.pp b/manifests/repo/ubuntu.pp index a8546f7b..9be7ea0f 100644 --- a/manifests/repo/ubuntu.pp +++ b/manifests/repo/ubuntu.pp @@ -6,25 +6,18 @@ # PHP version to manage (e.g. 5.6) # class php::repo::ubuntu ( - $version = undef, + Pattern[/^\d\.\d/] $version = '5.6', ) { if $facts['os']['name'] != 'Ubuntu' { fail("class php::repo::ubuntu does not work on OS ${facts['os']['name']}") } include 'apt' - if($version == undef) { - $version_real = '5.6' - } else { - $version_real = $version - } - - if ($version_real == '5.5') { + if ($version == '5.5') { fail('PHP 5.5 is no longer available for download') } - assert_type(Pattern[/^\d\.\d/], $version_real) - $version_repo = $version_real ? { + $version_repo = $version ? { '5.4' => 'ondrej/php5-oldstable', default => 'ondrej/php' } diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index d3247f59..3dd6ba68 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -53,9 +53,6 @@ 'gd' => {}, 'net-url' => { package_prefix => 'php-', - settings => { - extension => undef - }, }, 'simplexml' => { package_name => '#{simplexmlpackagename}', diff --git a/templates/fpm/pool.conf.erb b/templates/fpm/pool.conf.erb index 99981d19..8c07fac4 100644 --- a/templates/fpm/pool.conf.erb +++ b/templates/fpm/pool.conf.erb @@ -378,6 +378,6 @@ php_admin_flag[<%= key %>] = <%= flag %> <%= line.gsub "{", "%{" %> <% end -%> -<% if @security_limit_extensions -%> +<% unless @security_limit_extensions.empty? -%> security.limit_extensions = <%= @security_limit_extensions.join(" ") %> <% end -%> diff --git a/types/duration.pp b/types/duration.pp new file mode 100644 index 00000000..ad645b26 --- /dev/null +++ b/types/duration.pp @@ -0,0 +1,6 @@ +# A duration in seconds are with an unit +type Php::Duration = Variant[ + Integer[0], + Pattern[/^\d+[smhd]?$/] +] +