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' 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..6afb629 100644 --- a/manifests/ssl.pp +++ b/manifests/ssl.pp @@ -16,6 +16,21 @@ } } + solaris: { + 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'], + } + } + } 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',