Skip to content

Commit

Permalink
add docroot_mode parameter to vhost
Browse files Browse the repository at this point in the history
  • Loading branch information
ckaenzig committed Apr 5, 2014
1 parent edcf4b0 commit 1fa0d70
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
2 changes: 2 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -262,6 +263,7 @@
ensure => directory,
owner => $docroot_owner,
group => $docroot_group,
mode => $docroot_mode,
require => Package['httpd'],
}
}
Expand Down
2 changes: 2 additions & 0 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
6 changes: 4 additions & 2 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion tests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1fa0d70

Please sign in to comment.