forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1063 from igalic/expires
add parameters to configure expires globally
- Loading branch information
Showing
4 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
class apache::mod::expires { | ||
class apache::mod::expires ( | ||
$expires_active = true, | ||
$expires_default = undef, | ||
$expires_by_type = undef, | ||
) { | ||
::apache::mod { 'expires': } | ||
|
||
# Template uses | ||
# $expries_active | ||
# $expries_default | ||
# $expries_by_type | ||
file { 'expires.conf': | ||
ensure => file, | ||
path => "${::apache::mod_dir}/expires.conf", | ||
content => template('apache/mod/expires.conf.erb'), | ||
require => Exec["mkdir ${::apache::mod_dir}"], | ||
before => File[$::apache::mod_dir], | ||
notify => Class['apache::service'], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
require 'spec_helper' | ||
|
||
describe 'apache::mod::expires', :type => :class do | ||
let :pre_condition do | ||
'include apache' | ||
end | ||
context "with expires active", :compile do | ||
let :facts do | ||
{ | ||
:id => 'root', | ||
:kernel => 'Linux', | ||
:lsbdistcodename => 'squeeze', | ||
:osfamily => 'Debian', | ||
:operatingsystem => 'Debian', | ||
:operatingsystemrelease => '6', | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
:concat_basedir => '/dne', | ||
:is_pe => false, | ||
} | ||
end | ||
it { is_expected.to contain_apache__mod("expires") } | ||
it { is_expected.to contain_file("expires.conf").with(:content => /ExpiresActive On\n/) } | ||
end | ||
context "with expires default", :compile do | ||
let :pre_condition do | ||
'class { apache: default_mods => false }' | ||
end | ||
let :facts do | ||
{ | ||
:id => 'root', | ||
:kernel => 'Linux', | ||
:osfamily => 'RedHat', | ||
:operatingsystem => 'RedHat', | ||
:operatingsystemrelease => '7', | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
:concat_basedir => '/dne', | ||
:is_pe => false, | ||
} | ||
end | ||
let :params do | ||
{ | ||
'expires_default' => 'access plus 1 month' | ||
} | ||
end | ||
it { is_expected.to contain_apache__mod("expires") } | ||
it { is_expected.to contain_file("expires.conf").with_content( | ||
"ExpiresActive On\n" \ | ||
"ExpiresDefault \"access plus 1 month\"\n" | ||
) | ||
} | ||
end | ||
context "with expires by type", :compile do | ||
let :pre_condition do | ||
'class { apache: default_mods => false }' | ||
end | ||
let :facts do | ||
{ | ||
:id => 'root', | ||
:kernel => 'Linux', | ||
:osfamily => 'RedHat', | ||
:operatingsystem => 'RedHat', | ||
:operatingsystemrelease => '7', | ||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', | ||
:concat_basedir => '/dne', | ||
:is_pe => false, | ||
} | ||
end | ||
let :params do | ||
{ | ||
'expires_by_type' => [ | ||
{ 'text/json' => 'mod plus 1 day' }, | ||
{ 'text/html' => 'access plus 1 year' }, | ||
] | ||
} | ||
end | ||
it { is_expected.to contain_apache__mod("expires") } | ||
it { is_expected.to contain_file("expires.conf").with_content( | ||
"ExpiresActive On\n" \ | ||
"ExpiresByType text/json \"mod plus 1 day\"\n" \ | ||
"ExpiresByType text/html \"access plus 1 year\"\n" | ||
) | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
ExpiresActive <%= scope.function_bool2httpd([@expires_active]) %> | ||
<%- if ! @expires_default.nil? and ! @expires_default.empty? -%> | ||
ExpiresDefault "<%= @expires_default %>" | ||
<%- end -%> | ||
<%- if ! @expires_by_type.nil? and ! @expires_by_type.empty? -%> | ||
<%- [@expires_by_type].flatten.each do |line| -%> | ||
<%- line.map do |type, seconds| -%> | ||
ExpiresByType <%= type %> "<%= seconds -%>" | ||
<%- end -%> | ||
<%- end -%> | ||
<%- end -%> |