From 1fa0d705fde87e86ffe2e7608c872976c9802d80 Mon Sep 17 00:00:00 2001 From: Christian Kaenzig Date: Sat, 5 Apr 2014 15:37:30 +0200 Subject: [PATCH] add docroot_mode parameter to vhost --- README.md | 4 ++++ manifests/vhost.pp | 2 ++ spec/acceptance/vhost_spec.rb | 2 ++ spec/defines/vhost_spec.rb | 6 ++++-- tests/vhost.pp | 3 ++- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 53e68e164..50ca5ea00 100644 --- a/README.md +++ b/README.md @@ -674,6 +674,10 @@ Sets group access to the docroot directory. Defaults to 'root'. Sets individual user access to the docroot directory. Defaults to 'root'. +#####`docroot_mode` + +Sets access permissions of the docroot directory. Defaults to 'undef'. + #####`error_log` Specifies whether `*_error.log` directives should be configured. Defaults to 'true'. diff --git a/manifests/vhost.pp b/manifests/vhost.pp index b6c75dc51..7cfe11ab4 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -94,6 +94,7 @@ $add_listen = true, $docroot_owner = 'root', $docroot_group = $::apache::params::root_group, + $docroot_mode = undef, $serveradmin = undef, $ssl = false, $ssl_cert = $::apache::default_ssl_cert, @@ -262,6 +263,7 @@ ensure => directory, owner => $docroot_owner, group => $docroot_group, + mode => $docroot_mode, require => Package['httpd'], } } diff --git a/spec/acceptance/vhost_spec.rb b/spec/acceptance/vhost_spec.rb index a2fa41940..0353f58c0 100644 --- a/spec/acceptance/vhost_spec.rb +++ b/spec/acceptance/vhost_spec.rb @@ -427,6 +427,7 @@ class { 'apache': } docroot => '/tmp/test', docroot_owner => 'test_owner', docroot_group => 'test_group', + docroot_mode => '0750', } EOS apply_manifest(pp, :catch_failures => true) @@ -436,6 +437,7 @@ class { 'apache': } it { should be_directory } it { should be_owned_by 'test_owner' } it { should be_grouped_into 'test_group' } + it { should be_mode '0750' } end end diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index b16ce8840..efba89dd9 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -1096,16 +1096,18 @@ expect { subject }.to raise_error(Puppet::Error, /'error_log_file' and 'error_log_pipe' cannot be defined at the same time/) end end - describe 'when docroot owner is specified' do + describe 'when docroot owner and mode is specified' do let :params do default_params.merge({ :docroot_owner => 'testuser', :docroot_group => 'testgroup', + :docroot_mode => '0750', }) end - it 'should set vhost ownership' do + it 'should set vhost ownership and permissions' do should contain_file(params[:docroot]).with({ :ensure => :directory, :owner => 'testuser', :group => 'testgroup', + :mode => '0750', }) end end diff --git a/tests/vhost.pp b/tests/vhost.pp index f0d3f58e4..a6c61360a 100644 --- a/tests/vhost.pp +++ b/tests/vhost.pp @@ -13,12 +13,13 @@ docroot => '/var/www/first', } -# Vhost with different docroot owner/group +# Vhost with different docroot owner/group/mode apache::vhost { 'second.example.com': port => '80', docroot => '/var/www/second', docroot_owner => 'third', docroot_group => 'third', + docroot_mode => '0770', } # Vhost with serveradmin