From e3915ee6cd940b340b8d0311bfe3d84355c8b526 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Thu, 31 Mar 2016 11:03:57 +0200 Subject: [PATCH 1/3] Solaris support bump version from 2.1.12 to 2.2.0 --- manifests/htpasswd.pp | 4 +-- manifests/module.pp | 1 + manifests/params.pp | 34 +++++++++++++++++++++++++ manifests/ssl.pp | 17 +++++++++++++ metadata.json | 9 ++++++- spec/defines/apache_virtualhost_spec.rb | 20 +++++++++++++++ 6 files changed, 82 insertions(+), 3 deletions(-) diff --git a/manifests/htpasswd.pp b/manifests/htpasswd.pp index 1a5ae88..3d153b4 100644 --- a/manifests/htpasswd.pp +++ b/manifests/htpasswd.pp @@ -80,14 +80,14 @@ if $crypt_password { exec { "test -f ${real_htpasswd_file} || OPT='-c'; htpasswd -b \${OPT} ${real_htpasswd_file} ${username} '${crypt_password}'": unless => "grep -q '${username}:${crypt_password}' ${real_htpasswd_file}", - path => '/bin:/sbin:/usr/bin:/usr/sbin', + path => '/bin:/sbin:/usr/bin:/usr/sbin:/opt/csw/bin', } } if $clear_password { exec { "test -f ${real_htpasswd_file} || OPT='-c'; htpasswd -bp \$OPT ${real_htpasswd_file} ${username} ${clear_password}": unless => "egrep '^${username}:' ${real_htpasswd_file} && grep ${username}:\$(mkpasswd -S \$(egrep '^${username}:' ${real_htpasswd_file} |cut -d : -f 2 |cut -c-2) ${clear_password}) ${real_htpasswd_file}", - path => '/bin:/sbin:/usr/bin:/usr/sbin', + path => '/bin:/sbin:/usr/bin:/usr/sbin:/opt/csw/bin', } } } diff --git a/manifests/module.pp b/manifests/module.pp index 8c60352..fd8428e 100644 --- a/manifests/module.pp +++ b/manifests/module.pp @@ -64,6 +64,7 @@ $modpackage_basename = $::operatingsystem ? { /(?i:Ubuntu|Debian|Mint)/ => 'libapache2-mod-', /(?i:SLES|OpenSuSE)/ => 'apache2-mod_', + /(?i:Solaris)/ => 'apache-', default => 'mod_', } diff --git a/manifests/params.pp b/manifests/params.pp index e749694..2133925 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -18,6 +18,9 @@ $package_modssl = $::operatingsystem ? { /(?i:Ubuntu|Debian|Mint)/ => 'libapache-mod-ssl', /(?i:SLES|OpenSuSE)/ => undef, + /(?i:Solaris)/ => $::operatingsystemmajrelease ? { + '11' => 'web/server/apache-24/module/apache-ssl', + }, default => 'mod_ssl', } @@ -26,12 +29,20 @@ $package = $::operatingsystem ? { /(?i:Ubuntu|Debian|Mint)/ => 'apache2', /(?i:SLES|OpenSuSE)/ => 'apache2', + /(?i:Solaris)/ => $::operatingsystemmajrelease ? { + '10' => 'apache24', + '11' => 'web/server/apache-24', + }, default => 'httpd', } $service = $::operatingsystem ? { /(?i:Ubuntu|Debian|Mint)/ => 'apache2', /(?i:SLES|OpenSuSE)/ => 'apache2', + /(?i:Solaris)/ => $::operatingsystemmajrelease ? { + '10' => 'svc:/network/cswapache24:default', + '11' => 'svc:/network/http:apache24', + }, default => 'httpd', } @@ -52,12 +63,17 @@ $process_user = $::operatingsystem ? { /(?i:Ubuntu|Debian|Mint)/ => 'www-data', /(?i:SLES|OpenSuSE)/ => 'wwwrun', + /(?i:Solaris)/ => 'webservd', default => 'apache', } $config_dir = $::operatingsystem ? { /(?i:Ubuntu|Debian|Mint)/ => '/etc/apache2', /(?i:SLES|OpenSuSE)/ => '/etc/apache2', + /(?i:Solaris)/ => $::operatingsystemmajrelease ? { + '10' => '/etc/apache2', + '11' => '/etc/apache2/2.4', + }, freebsd => '/usr/local/etc/apache20', default => '/etc/httpd', } @@ -65,6 +81,7 @@ $config_file = $::operatingsystem ? { /(?i:Ubuntu|Debian|Mint)/ => '/etc/apache2/apache2.conf', /(?i:SLES|OpenSuSE)/ => '/etc/apache2/httpd.conf', + /(?i:Solaris)/ => "${config_dir}/httpd.conf", freebsd => '/usr/local/etc/apache20/httpd.conf', default => '/etc/httpd/conf/httpd.conf', } @@ -85,30 +102,47 @@ $config_file_init = $::operatingsystem ? { /(?i:Debian|Ubuntu|Mint)/ => '/etc/default/apache2', /(?i:SLES|OpenSuSE)/ => '/etc/sysconfig/apache2', + /(?i:Solaris)/ => undef, default => '/etc/sysconfig/httpd', } $pid_file = $::operatingsystem ? { /(?i:Debian|Ubuntu|Mint)/ => '/var/run/apache2.pid', /(?i:SLES|OpenSuSE)/ => '/var/run/httpd2.pid', + /(?i:Solaris)/ => $::operatingsystemmajrelease ? { + '10' => '/var/run/apache2/httpd.pid', + '11' => '/usr/apache2/2.4/httpd.pid', + }, default => '/var/run/httpd.pid', } $log_dir = $::operatingsystem ? { /(?i:Debian|Ubuntu|Mint)/ => '/var/log/apache2', /(?i:SLES|OpenSuSE)/ => '/var/log/apache2', + /(?i:Solaris)/ => $::operatingsystemmajrelease ? { + '10' => '/var/apache2/logs', + '11' => '/var/apache2/2.4/logs', + }, default => '/var/log/httpd', } $log_file = $::operatingsystem ? { /(?i:Debian|Ubuntu|Mint)/ => ['/var/log/apache2/access.log','/var/log/apache2/error.log'], /(?i:SLES|OpenSuSE)/ => ['/var/log/apache2/access.log','/var/log/apache2/error.log'], + /(?i:Solaris)/ => $::operatingsystemmajrelease ? { + '10' => ['/var/apache2/logs/access.log','/var/apache2/logs/error.log'], + '11' => ['/var/apache2/2.4/logs/access.log', '/var/apache2/2.4/logs/error.log'], + }, default => ['/var/log/httpd/access.log','/var/log/httpd/error.log'], } $data_dir = $::operatingsystem ? { /(?i:Debian|Ubuntu|Mint)/ => '/var/www', /(?i:Suse|OpenSuse)/ => '/srv/www/htdocs', + /(?i:Solaris)/ => $::operatingsystemmajrelease ? { + '10' => '/var/apache2/htdocs', + '11' => '/var/apache2/2.4/htdocs', + }, default => '/var/www/html', } diff --git a/manifests/ssl.pp b/manifests/ssl.pp index 6d0f6d7..a970997 100644 --- a/manifests/ssl.pp +++ b/manifests/ssl.pp @@ -16,6 +16,23 @@ } } + solaris: { + case $::operatingsystemmajrelease { + '11': { + package { 'apache-ssl': + ensure => present, + require => Package['apache'], + notify => Service['apache'], + } + file { "${apache::dotconf_dir}/ssl.conf": + mode => '0644', + owner => 'root', + group => 'root', + notify => Service['apache'], + } + } + } + } default: { package { 'mod_ssl': ensure => present, diff --git a/metadata.json b/metadata.json index 6c20e07..1dd4d8d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "example42-apache", - "version": "2.1.12", + "version": "2.2.0", "summary": "Puppet module for apache", "license": "Apache-2.0", "author": "Alessandro Franceschi, Martin Alfke", @@ -33,6 +33,13 @@ "operatingsystemrelease": [ "14.04" ] + }, + { + "operatingsystem": "Solaris", + "operatingsystemrelease": [ + "10", + "11" + ] } ], "requirements": [ diff --git a/spec/defines/apache_virtualhost_spec.rb b/spec/defines/apache_virtualhost_spec.rb index 920c577..a46b65d 100644 --- a/spec/defines/apache_virtualhost_spec.rb +++ b/spec/defines/apache_virtualhost_spec.rb @@ -51,6 +51,26 @@ end + describe 'Test apache::virtualhost on solaris' do + let(:facts) { { :arch => 'i386' , :operatingsystem => 'Solaris', :operatingsystemmajrelease => '11' } } + let(:params) { + { 'enable' => 'true', + 'name' => 'www.example42.com', + } + } + + it 'should populate correctly the apache::virtualhost file DocumentRoot' do + should contain_file('ApacheVirtualHost_www.example42.com').with_content(/ DocumentRoot \/var\/apache2\/2.4\/htdocs\/www.example42.com/) + end + it 'should populate correctly the apache::virtualhost file ErrorLog' do + should contain_file('ApacheVirtualHost_www.example42.com').with_content(/ ErrorLog \/var\/apache2\/2.4\/logs\/www.example42.com-error_log/) + end + it 'should create the docroot directory' do + should contain_file('/var/apache2/2.4/htdocs/www.example42.com').with_ensure("directory") + end + + end + describe 'Test apache::virtualhost decommissioning' do let(:params) { { 'enable' => 'false', From 5ab20df21a92fd712dbbdb4e584062bd51826c6c Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Sat, 2 Apr 2016 14:51:29 +0200 Subject: [PATCH 2/3] use older version of rake on ruby 1.8 --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index f8ddad5..be1c34c 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ is_ruby18 = RUBY_VERSION.start_with? '1.8' if is_ruby18 gem 'rspec', "~> 3.1.0", :require => false + gem 'rake', '~> 10.5.0', :require => false end gem 'puppet', puppetversion, :require => false gem 'puppet-lint' From 5f04ad2c30decb7592acbea6912a412758a3f6da Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Sat, 2 Apr 2016 14:56:16 +0200 Subject: [PATCH 3/3] lint cleanup --- manifests/ssl.pp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/manifests/ssl.pp b/manifests/ssl.pp index a970997..6afb629 100644 --- a/manifests/ssl.pp +++ b/manifests/ssl.pp @@ -17,19 +17,17 @@ } solaris: { - case $::operatingsystemmajrelease { - '11': { - package { 'apache-ssl': - ensure => present, - require => Package['apache'], - notify => Service['apache'], - } - file { "${apache::dotconf_dir}/ssl.conf": - mode => '0644', - owner => 'root', - group => 'root', - notify => Service['apache'], - } + if $::operatingsystemmajrelease == '11' { + package { 'apache-ssl': + ensure => present, + require => Package['apache'], + notify => Service['apache'], + } + file { "${apache::dotconf_dir}/ssl.conf": + mode => '0644', + owner => 'root', + group => 'root', + notify => Service['apache'], } } }