diff --git a/metadata.json b/metadata.json index 29255598..03588694 100644 --- a/metadata.json +++ b/metadata.json @@ -1,91 +1,97 @@ { "name": "puppetlabs-apache", "version": "7.0.0", "author": "puppetlabs", "summary": "Installs, configures, and manages Apache virtual hosts, web services, and modules.", "license": "Apache-2.0", "source": "https://github.com/puppetlabs/puppetlabs-apache", "project_page": "https://github.com/puppetlabs/puppetlabs-apache", "issues_url": "https://tickets.puppetlabs.com/browse/MODULES", "dependencies": [ { "name": "puppetlabs/stdlib", "version_requirement": ">= 4.13.1 < 9.0.0" }, { "name": "puppetlabs/concat", "version_requirement": ">= 2.2.1 < 8.0.0" } ], "operatingsystem_support": [ { "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", "7", "8" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "6", "7", "8" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Scientific", "operatingsystemrelease": [ "6", "7" ] }, { "operatingsystem": "Debian", "operatingsystemrelease": [ "9", "10", "11" ] }, { "operatingsystem": "SLES", "operatingsystemrelease": [ "12", "15" ] }, { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "16.04", "18.04", "20.04" ] }, { "operatingsystem": "Rocky", "operatingsystemrelease": [ "8" ] + }, + { + "operatingsystem": "AlmaLinux", + "operatingsystemrelease": [ + "8" + ] } ], "requirements": [ { "name": "puppet", "version_requirement": ">= 6.0.0 < 8.0.0" } ], "description": "Module for Apache configuration", "pdk-version": "2.1.0", "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", "template-ref": "heads/main-0-g03daa92" } diff --git a/spec/classes/mod/fastcgi_spec.rb b/spec/classes/mod/fastcgi_spec.rb index 05cba06d..4cd6c9c4 100644 --- a/spec/classes/mod/fastcgi_spec.rb +++ b/spec/classes/mod/fastcgi_spec.rb @@ -1,42 +1,42 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::fastcgi', type: :class do on_supported_os.each do |os, facts| context "on #{os} " do let :facts do facts end context 'with all defaults' do case facts[:os]['name'] when 'Debian' it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('fastcgi') } it { is_expected.to contain_package('libapache2-mod-fastcgi') } it { is_expected.to contain_file('fastcgi.conf') } - when 'RedHat', 'CentOS', 'OracleLinux', 'Scientific', 'Rocky' + when 'RedHat', 'CentOS', 'OracleLinux', 'Scientific', 'Rocky', 'AlmaLinux' if facts[:os]['release']['major'].to_i < 7 it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('fastcgi') } it { is_expected.to contain_package('mod_fastcgi') } it { is_expected.not_to contain_file('fastcgi.conf') } else it { is_expected.not_to compile } end when 'Ubuntu' if facts[:os]['release']['major'].to_i < 18 it { is_expected.to compile.with_all_deps } else it { is_expected.not_to compile } end else it { is_expected.to compile.with_all_deps } end end end end end diff --git a/spec/classes/mod/php_spec.rb b/spec/classes/mod/php_spec.rb index 9956e524..b0c4b6d8 100644 --- a/spec/classes/mod/php_spec.rb +++ b/spec/classes/mod/php_spec.rb @@ -1,328 +1,328 @@ # frozen_string_literal: true require 'spec_helper' describe 'apache::mod::php', type: :class do on_supported_os.each do |os, facts| context "on #{os} " do let :facts do facts end let :pre_condition do 'class { "apache": mpm_module => prefork, }' end case facts[:os]['family'] when 'Debian' describe 'on a Debian OS' do context 'with mpm_module => prefork' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::prefork') } end case facts[:os]['release']['major'] when '9' context 'on stretch' do it { is_expected.to contain_apache__mod('php7.0') } it { is_expected.to contain_package('libapache2-mod-php7.0') } it { is_expected.to contain_file('php7.0.load').with( content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.0.so\n", ) } end when '10' context 'on buster' do it { is_expected.to contain_apache__mod('php7.3') } it { is_expected.to contain_package('libapache2-mod-php7.3') } it { is_expected.to contain_file('php7.3.load').with( content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.3.so\n", ) } context 'with experimental php8.0' do let :params do { php_version: '8.0' } end it { is_expected.to contain_apache__mod('php') } it { is_expected.to contain_package('libapache2-mod-php8.0') } it { is_expected.to contain_file('php.load').with( content: "LoadModule php_module /usr/lib/apache2/modules/libphp.so\n", ) } end end when '11' context 'on bullseye' do it { is_expected.to contain_apache__mod('php7.4') } it { is_expected.to contain_package('libapache2-mod-php7.4') } it { is_expected.to contain_file('php7.4.load').with( content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.4.so\n", ) } context 'with experimental php8.0' do let :params do { php_version: '8.0' } end it { is_expected.to contain_apache__mod('php') } it { is_expected.to contain_package('libapache2-mod-php8.0') } it { is_expected.to contain_file('php.load').with( content: "LoadModule php_module /usr/lib/apache2/modules/libphp.so\n", ) } end end when '16.04' context 'on xenial' do let :params do { content: 'somecontent' } end it { is_expected.to contain_file('php7.0.conf').with( content: 'somecontent', ) } end when '18.04' context 'on bionic' do let :params do { content: 'somecontent' } end it { is_expected.to contain_file('php7.2.conf').with( content: 'somecontent', ) } end end end when 'RedHat' describe 'on a RedHat OS' do context 'with default params' do let :pre_condition do 'class { "apache": }' end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('php5') } if facts[:os]['release']['major'].to_i < 8 it { is_expected.to contain_package('php') } if facts[:os]['release']['major'].to_i > 5 it { is_expected.to contain_file('php5.load').with(content: "LoadModule php5_module modules/libphp5.so\n") } if facts[:os]['release']['major'].to_i < 8 it { is_expected.to contain_file('php7.load').with(content: "LoadModule php7_module modules/libphp7.so\n") } if facts[:os]['release']['major'].to_i >= 8 end context 'with alternative package name' do let :pre_condition do 'class { "apache": }' end let :params do { package_name: 'php54' } end it { is_expected.to contain_package('php54') } end context 'with alternative path' do let :pre_condition do 'class { "apache": }' end let :params do { path: 'alternative-path' } end it { is_expected.to contain_file('php5.load').with(content: "LoadModule php5_module alternative-path\n") } if facts[:os]['release']['major'].to_i < 8 it { is_expected.to contain_file('php7.load').with(content: "LoadModule php7_module alternative-path\n") } if facts[:os]['release']['major'].to_i >= 8 end context 'with alternative extensions' do let :pre_condition do 'class { "apache": }' end let :params do { extensions: ['.php', '.php5'], } end it { is_expected.to contain_file('php5.conf').with_content(Regexp.new(Regexp.escape(''))) } if facts[:os]['release']['major'].to_i < 8 end if facts[:os]['release']['major'].to_i > 5 context 'with specific version' do let :pre_condition do 'class { "apache": }' end let :params do { package_ensure: '5.3.13' } end it { is_expected.to contain_package('php').with( ensure: '5.3.13', ) } end end context 'with mpm_module => prefork' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::prefork') } it { is_expected.to contain_apache__mod('php5') } if facts[:os]['release']['major'].to_i < 8 it { is_expected.to contain_package('php') } if facts[:os]['release']['major'].to_i > 5 it { is_expected.to contain_file('php5.load').with(content: "LoadModule php5_module modules/libphp5.so\n") } if facts[:os]['release']['major'].to_i < 8 it { is_expected.to contain_file('php7.load').with(content: "LoadModule php7_module modules/libphp7.so\n") } if facts[:os]['release']['major'].to_i >= 8 end context 'with mpm_module => itk' do let :pre_condition do 'class { "apache": mpm_module => itk, }' end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::itk') } it { is_expected.to contain_apache__mod('php5') } if facts[:os]['release']['major'].to_i < 8 it { is_expected.to contain_package('php') } if facts[:os]['release']['major'].to_i > 5 it { is_expected.to contain_file('php5.load').with(content: "LoadModule php5_module modules/libphp5.so\n") } if facts[:os]['release']['major'].to_i < 8 it { is_expected.to contain_file('php7.load').with(content: "LoadModule php7_module modules/libphp7.so\n") } if facts[:os]['release']['major'].to_i >= 8 end end when 'FreeBSD' describe 'on a FreeBSD OS' do context 'with mpm_module => prefork' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('php5') } it { is_expected.to contain_package('www/mod_php5') } it { is_expected.to contain_file('php5.load') } end context 'with mpm_module => itk' do let :pre_condition do 'class { "apache": mpm_module => itk, }' end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::itk') } it { is_expected.to contain_apache__mod('php5') } it { is_expected.to contain_package('www/mod_php5') } it { is_expected.to contain_file('php5.load') } end end when 'Gentoo' describe 'on a Gentoo OS' do context 'with mpm_module => prefork' do it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_apache__mod('php5') } it { is_expected.to contain_package('dev-lang/php') } it { is_expected.to contain_file('php5.load') } end context 'with mpm_module => itk' do let :pre_condition do 'class { "apache": mpm_module => itk, }' end it { is_expected.to contain_class('apache::params') } it { is_expected.to contain_class('apache::mod::itk') } it { is_expected.to contain_apache__mod('php5') } it { is_expected.to contain_package('dev-lang/php') } it { is_expected.to contain_file('php5.load') } end end end # all the following tests are for legacy php/apache versions. They don't work on modern ubuntu and redhat 8 next if (facts[:os]['release']['major'].to_i > 15 && facts[:os]['name'] == 'Ubuntu') || (facts[:os]['release']['major'].to_i >= 15 && facts[:os]['name'] == 'SLES') || (facts[:os]['release']['major'].to_i >= 9 && facts[:os]['name'] == 'Debian') || (facts[:os]['release']['major'].to_i >= 8 && (facts[:os]['name'] == 'RedHat' || facts[:os]['name'] == 'CentOS' || - facts[:os]['name'] == 'Rocky')) + facts[:os]['name'] == 'Rocky' || facts[:os]['name'] == 'AlmaLinux')) describe 'OS independent tests' do context 'with content param' do let :params do { content: 'somecontent' } end it { is_expected.to contain_file('php5.conf').with( content: 'somecontent', ) } end context 'with template param' do let :params do { template: 'apache/mod/php.conf.erb' } end it { is_expected.to contain_file('php5.conf').with( content: %r{^# PHP is an HTML-embedded scripting language which attempts to make it}, ) } end context 'with source param' do let :params do { source: 'some-path' } end it { is_expected.to contain_file('php5.conf').with( source: 'some-path', ) } end context 'content has priority over template' do let :params do { template: 'apache/mod/php5.conf.erb', content: 'somecontent', } end it { is_expected.to contain_file('php5.conf').with( content: 'somecontent', ) } end context 'source has priority over template' do let :params do { template: 'apache/mod/php5.conf.erb', source: 'some-path', } end it { is_expected.to contain_file('php5.conf').with( source: 'some-path', ) } end context 'source has priority over content' do let :params do { content: 'somecontent', source: 'some-path', } end it { is_expected.to contain_file('php5.conf').with( source: 'some-path', ) } end context 'with mpm_module => worker' do let :pre_condition do 'class { "apache": mpm_module => worker, }' end it 'raises an error' do is_expected.to compile.and_raise_error(%r{mpm_module => 'prefork' or mpm_module => 'itk'}) end end end end end end diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index f8995a21..8854b746 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -1,196 +1,200 @@ # frozen_string_literal: true require 'singleton' require_relative '../util/apache_mod_platform_support' class LitmusHelper include Singleton include PuppetLitmus end class ApacheModTestFilterHelper include Singleton def initialize_ampc(os) @ampc = ApacheModPlatformCompatibility.new @ampc.generate_supported_platforms_versions @ampc.register_running_platform(os) @ampc.generate_mod_platform_exclusions end def mod_supported_on_platform?(mod) @ampc.mod_supported_on_platform?(mod) end def print_parsing_errors @ampc.print_parsing_errors end end RSpec.configure do |c| # IPv6 is not enabled by default in the new travis-ci Trusty environment (see https://github.com/travis-ci/travis-ci/issues/8891 ) if ENV['CI'] == 'true' c.filter_run_excluding ipv6: true end c.before :suite do # Make sure selinux is disabled so the tests work. LitmusHelper.instance.run_shell('setenforce 0', expect_failures: true) if %r{redhat|oracle}.match?(os[:family]) LitmusHelper.instance.run_shell('puppet module install stahnma/epel') pp = <<-PUPPETCODE # needed by tests package { 'curl': ensure => 'latest', } # needed for netstat, for serverspec checks if $::osfamily == 'SLES' or $::osfamily == 'SUSE' { package { 'net-tools-deprecated': ensure => 'latest', } } # needed for ss, for serverspec checks if $::operatingsystem == 'Ubuntu' and $::operatingsystemmajrelease !~ /14.04|16.04/ { package { 'iproute2': ensure => 'latest', } } if $::osfamily == 'RedHat' { if $::operatingsystemmajrelease == '5' or $::operatingsystemmajrelease == '6'{ class { 'epel': epel_baseurl => "http://osmirror.delivery.puppetlabs.net/epel${::operatingsystemmajrelease}-\\$basearch/RPMS.all", epel_mirrorlist => "http://osmirror.delivery.puppetlabs.net/epel${::operatingsystemmajrelease}-\\$basearch/RPMS.all", } } elsif $::operatingsystemmajrelease == '8' { class { 'epel': os_maj_release => "7", epel_baseurl => "http://osmirror.delivery.puppetlabs.net/epel7-\\$basearch/RPMS.all", epel_mirrorlist => "http://osmirror.delivery.puppetlabs.net/epel7-\\$basearch/RPMS.all", } } else { class { 'epel': } } } PUPPETCODE LitmusHelper.instance.apply_manifest(pp) # Ensure ipv6 is enabled on our Debian 11 Docker boxes LitmusHelper.instance.run_shell('sysctl -w net.ipv6.conf.all.disable_ipv6=0') if %r{debian}.match?(os[:family]) && os[:release].to_f == 11 + + # Install iproute on AlmaLinux + # Package is used to check if ports are listening + LitmusHelper.instance.run_shell('sudo dnf install iproute -y') if %r{redhat}.match?(os[:family]) && os[:release].to_f >= 8 end c.after :suite do ApacheModTestFilterHelper.instance.print_parsing_errors end end def apache_settings_hash osfamily = os[:family] operatingsystemrelease = os[:release].to_f apache = {} case osfamily when 'redhat', 'oracle' apache['httpd_dir'] = '/etc/httpd' apache['confd_dir'] = '/etc/httpd/conf.d' apache['conf_file'] = '/etc/httpd/conf/httpd.conf' apache['ports_file'] = '/etc/httpd/conf/ports.conf' apache['vhost_dir'] = '/etc/httpd/conf.d' apache['vhost'] = '/etc/httpd/conf.d/15-default-80.conf' apache['run_dir'] = '/var/run/httpd' apache['doc_root'] = '/var/www' apache['service_name'] = 'httpd' apache['package_name'] = 'httpd' apache['error_log'] = 'error_log' apache['suphp_handler'] = 'php5-script' apache['suphp_configpath'] = 'undef' if operatingsystemrelease >= 8 && osfamily == 'redhat' apache['version'] = '2.4' apache['mod_dir'] = '/etc/httpd/conf.modules.d' apache['mod_ssl_dir'] = apache['mod_dir'] elsif operatingsystemrelease >= 7 && osfamily == 'redhat' apache['version'] = '2.4' apache['mod_dir'] = '/etc/httpd/conf.modules.d' apache['mod_ssl_dir'] = apache['confd_dir'] elsif operatingsystemrelease >= 7 && osfamily == 'oracle' apache['version'] = '2.4' apache['mod_dir'] = '/etc/httpd/conf.modules.d' apache['mod_ssl_dir'] = apache['confd_dir'] else apache['version'] = '2.2' apache['mod_dir'] = '/etc/httpd/conf.d' apache['mod_ssl_dir'] = apache['mod_dir'] end when 'debian', 'ubuntu' apache['httpd_dir'] = '/etc/apache2' apache['confd_dir'] = '/etc/apache2/conf.d' apache['mod_dir'] = '/etc/apache2/mods-available' apache['conf_file'] = '/etc/apache2/apache2.conf' apache['ports_file'] = '/etc/apache2/ports.conf' apache['vhost'] = '/etc/apache2/sites-available/15-default-80.conf' apache['vhost_dir'] = '/etc/apache2/sites-enabled' apache['run_dir'] = '/var/run/apache2' apache['doc_root'] = '/var/www' apache['service_name'] = 'apache2' apache['package_name'] = 'apache2' apache['error_log'] = 'error.log' apache['suphp_handler'] = 'x-httpd-php' apache['suphp_configpath'] = '/etc/php5/apache2' apache['version'] = '2.4' apache['mod_ssl_dir'] = apache['mod_dir'] when 'freebsd' apache['httpd_dir'] = '/usr/local/etc/apache24' apache['confd_dir'] = '/usr/local/etc/apache24/Includes' apache['mod_dir'] = '/usr/local/etc/apache24/Modules' apache['conf_file'] = '/usr/local/etc/apache24/httpd.conf' apache['ports_file'] = '/usr/local/etc/apache24/Includes/ports.conf' apache['vhost'] = '/usr/local/etc/apache24/Vhosts/15-default-80.conf' apache['vhost_dir'] = '/usr/local/etc/apache24/Vhosts' apache['run_dir'] = '/var/run/apache24' apache['doc_root'] = '/var/www' apache['service_name'] = 'apache24' apache['package_name'] = 'apache24' apache['error_log'] = 'http-error.log' apache['version'] = '2.2' apache['mod_ssl_dir'] = apache['mod_dir'] when 'gentoo' apache['httpd_dir'] = '/etc/apache2' apache['confd_dir'] = '/etc/apache2/conf.d' apache['mod_dir'] = '/etc/apache2/modules.d' apache['conf_file'] = '/etc/apache2/httpd.conf' apache['ports_file'] = '/etc/apache2/ports.conf' apache['vhost'] = '/etc/apache2/vhosts.d/15-default-80.conf' apache['vhost_dir'] = '/etc/apache2/vhosts.d' apache['run_dir'] = '/var/run/apache2' apache['doc_root'] = '/var/www' apache['service_name'] = 'apache2' apache['package_name'] = 'www-servers/apache' apache['error_log'] = 'http-error.log' apache['version'] = '2.4' apache['mod_ssl_dir'] = apache['mod_dir'] when 'suse', 'sles' apache['httpd_dir'] = '/etc/apache2' apache['confd_dir'] = '/etc/apache2/conf.d' apache['mod_dir'] = '/etc/apache2/mods-available' apache['conf_file'] = '/etc/apache2/httpd.conf' apache['ports_file'] = '/etc/apache2/ports.conf' apache['vhost'] = '/etc/apache2/sites-available/15-default-80.conf' apache['vhost_dir'] = '/etc/apache2/sites-available' apache['run_dir'] = '/var/run/apache2' apache['doc_root'] = '/srv/www' apache['service_name'] = 'apache2' apache['package_name'] = 'apache2' apache['error_log'] = 'error.log' apache['version'] = if operatingsystemrelease < 12 '2.2' else '2.4' end apache['mod_ssl_dir'] = apache['mod_dir'] else raise 'unable to figure out what apache version' end apache end def mod_supported_on_platform?(mod) return false if ENV['DISABLE_MOD_TEST_EXCLUSION'] ApacheModTestFilterHelper.instance.mod_supported_on_platform?(mod) end