Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add paramter to set config file permissions #1333

Merged
merged 1 commit into from
Jan 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,10 @@ Controls how Apache handles `TRACE` requests (per [RFC 2616][]) via the [`TraceE

Controls whether the systemd module should be installed on Centos 7 servers, this is especially useful if using custom built rpms. This can either be 'true' or 'false, defaults to 'true'.

##### `file_mode`

The desired permissions mode for config files, in symbolic or numeric notation. This value must be a string. Defaults to '0644'.

##### `vhost_dir`

Changes your virtual host configuration files' location. Default: determined by your operating system.
Expand Down
2 changes: 1 addition & 1 deletion manifests/balancer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
concat { $target:
owner => '0',
group => '0',
mode => '0644',
mode => $::apache::file_mode,
notify => Class['Apache::Service'],
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/fastcgi/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
path => "${::apache::confd_dir}/fastcgi-pool-${name}.conf",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
content => template('apache/fastcgi/server.erb'),
require => Exec["mkdir ${::apache::confd_dir}"],
before => File[$::apache::confd_dir],
Expand Down
3 changes: 2 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
$use_optional_includes = $::apache::params::use_optional_includes,
$use_systemd = $::apache::params::use_systemd,
$mime_types_additional = $::apache::params::mime_types_additional,
$file_mode = $::apache::params::file_mode,
) inherits ::apache::params {
validate_bool($default_vhost)
validate_bool($default_ssl_vhost)
Expand Down Expand Up @@ -241,7 +242,7 @@
concat { $ports_file:
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
notify => Class['Apache::Service'],
require => Package['httpd'],
}
Expand Down
10 changes: 5 additions & 5 deletions manifests/mod.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
path => "${mod_dir}/${_loadfile_name}",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
content => template('apache/mod/load.erb'),
require => [
Package['httpd'],
Expand All @@ -99,7 +99,7 @@
target => "${mod_dir}/${_loadfile_name}",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
require => [
File[$_loadfile_name],
Exec["mkdir ${enable_dir}"],
Expand All @@ -117,7 +117,7 @@
target => "${mod_dir}/${mod}.conf",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
require => [
File["${mod}.conf"],
Exec["mkdir ${enable_dir}"],
Expand All @@ -134,7 +134,7 @@
target => "${mod_dir}/${_loadfile_name}",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
require => [
File[$_loadfile_name],
Exec["mkdir ${enable_dir}"],
Expand All @@ -152,7 +152,7 @@
target => "${mod_dir}/${mod}.conf",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
require => [
File["${mod}.conf"],
Exec["mkdir ${enable_dir}"],
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/event.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
File {
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
}

# Template uses:
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/itk.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
File {
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
}

# Template uses:
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/peruser.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
File {
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
}

$mod_dir = $::apache::mod_dir
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/php.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
path => "${::apache::mod_dir}/php5.conf",
owner => 'root',
group => $root_group,
mode => '0644',
mode => $::apache::file_mode,
content => $manage_content,
source => $source,
require => [
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/prefork.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
File {
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
}

# Template uses:
Expand Down
2 changes: 1 addition & 1 deletion manifests/mod/worker.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
File {
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
}

# Template uses:
Expand Down
3 changes: 3 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
# should we use systemd module?
$use_systemd = true

# Default mode for files
$file_mode = '0644'

$vhost_include_pattern = '*'

if $::operatingsystem == 'Ubuntu' and $::lsbdistrelease == '10.04' {
Expand Down
4 changes: 2 additions & 2 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@
path => "${::apache::vhost_dir}/${priority_real}${filename}.conf",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
order => 'numeric',
require => Package['httpd'],
notify => Class['apache::service'],
Expand All @@ -523,7 +523,7 @@
target => "${::apache::vhost_dir}/${priority_real}${filename}.conf",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
require => Concat["${priority_real}${filename}.conf"],
notify => Class['apache::service'],
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/vhost/custom.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
target => "${::apache::vhost_dir}/${priority}-${filename}.conf",
owner => 'root',
group => $::apache::params::root_group,
mode => '0644',
mode => $::apache::file_mode,
require => Apache::Custom_config[$filename],
}
}
Expand Down
10 changes: 10 additions & 0 deletions spec/classes/apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,16 @@
)
}
end
context 'with a custom file_mode parameter' do
let :params do {
:file_mode => '0640'
}
end
it { is_expected.to contain_concat("/etc/httpd/conf/ports.conf").with(
'mode' => '0640',
)
}
end
context 'default vhost defaults' do
it { is_expected.to contain_apache__vhost('default').with_ensure('present') }
it { is_expected.to contain_apache__vhost('default-ssl').with_ensure('absent') }
Expand Down
14 changes: 14 additions & 0 deletions spec/defines/mod_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@
end
end

describe "with file_mode set" do
let :pre_condition do
"class {'::apache': file_mode => '0640'}"
end
let :title do
'spec_m'
end
it "should manage the module load file" do
is_expected.to contain_file('spec_m.load').with({
:mode => '0640',
} )
end
end

describe "with shibboleth module and package param passed" do
# name/title for the apache::mod define
let :title do
Expand Down