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.
- Loading branch information
Showing
7 changed files
with
325 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
class apache::mod::pagespeed ( | ||
$inherit_vhost_config = 'on', | ||
$filter_xhtml = false, | ||
$cache_path = '/var/cache/mod_pagespeed/', | ||
$log_dir = '/var/log/pagespeed', | ||
$memache_servers = [], | ||
$rewrite_level = 'CoreFilters', | ||
$disable_filters = [], | ||
$enable_filters = [], | ||
$forbid_filters = [], | ||
$rewrite_deadline_per_flush_ms = 10, | ||
$additional_domains = undef, | ||
$file_cache_size_kb = 102400, | ||
$file_cache_clean_interval_ms = 3600000, | ||
$lru_cache_per_process = 1024, | ||
$lru_cache_byte_limit = 16384, | ||
$css_flatten_max_bytes = 2048, | ||
$css_inline_max_bytes = 2048, | ||
$css_image_inline_max_bytes = 2048, | ||
$image_inline_max_bytes = 2048, | ||
$js_inline_max_bytes = 2048, | ||
$css_outline_min_bytes = 3000, | ||
$js_outline_min_bytes = 3000, | ||
$inode_limit = 500000, | ||
$image_max_rewrites_at_once = 8, | ||
$num_rewrite_threads = 4, | ||
$num_expensive_rewrite_threads = 4, | ||
$collect_statistics = 'on', | ||
$statistics_logging = 'on', | ||
$allow_view_stats = [], | ||
$allow_pagespeed_console = [], | ||
$allow_pagespeed_message = [], | ||
$message_buffer_size = 100000, | ||
$additional_configuration = {}, | ||
){ | ||
|
||
apache::mod { 'pagespeed': } | ||
|
||
file { 'pagespeed.conf': | ||
ensure => file, | ||
path => "${::apache::mod_dir}/pagespeed.conf", | ||
content => template('apache/mod/pagespeed.conf.erb'), | ||
require => Exec["mkdir ${::apache::mod_dir}"], | ||
before => File[$::apache::mod_dir], | ||
notify => Service['httpd'], | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'apache::mod::pagespeed class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do | ||
case fact('osfamily') | ||
when 'Debian' | ||
vhost_dir = '/etc/apache2/sites-enabled' | ||
mod_dir = '/etc/apache2/mods-available' | ||
service_name = 'apache2' | ||
when 'RedHat' | ||
vhost_dir = '/etc/httpd/conf.d' | ||
mod_dir = '/etc/httpd/conf.d' | ||
service_name = 'httpd' | ||
when 'FreeBSD' | ||
vhost_dir = '/usr/local/etc/apache22/Vhosts' | ||
mod_dir = '/usr/local/etc/apache22/Modules' | ||
service_name = 'apache22' | ||
end | ||
|
||
context "default pagespeed config" do | ||
it 'succeeds in puppeting pagespeed' do | ||
pp= <<-EOS | ||
if $::osfamily == 'Debian' { | ||
class { 'apt': } | ||
apt::source { 'mod-pagespeed': | ||
key => '7FAC5991', | ||
key_server => 'pgp.mit.edu', | ||
location => 'http://dl.google.com/linux/mod-pagespeed/deb/', | ||
release => 'stable', | ||
repos => 'main', | ||
include_src => false, | ||
before => Class['apache'], | ||
} | ||
} elsif $::osfamily == 'RedHat' { | ||
yumrepo { 'mod-pagespeed': | ||
baseurl => 'http://dl.google.com/linux/mod-pagespeed/rpm/stable/x86_64', | ||
enabled => 1, | ||
gpgcheck => 1, | ||
gpgkey => 'https://dl-ssl.google.com/linux/linux_signing_key.pub', | ||
before => Class['apache'], | ||
} | ||
} | ||
class { 'apache': | ||
mpm_module => 'prefork', | ||
} | ||
class { 'apache::mod::pagespeed': | ||
enable_filters => ['remove_comments'], | ||
disable_filters => ['extend_cache'], | ||
forbid_filters => ['rewrite_javascript'], | ||
} | ||
apache::vhost { 'pagespeed.example.com': | ||
port => '80', | ||
docroot => '/var/www/pagespeed', | ||
} | ||
host { 'pagespeed.example.com': ip => '127.0.0.1', } | ||
file { '/var/www/pagespeed/index.html': | ||
ensure => file, | ||
content => "<html>\n<!-- comment -->\n<body>\n<p>Hello World!</p>\n</body>\n</html>", | ||
} | ||
EOS | ||
apply_manifest(pp, :catch_failures => true) | ||
end | ||
|
||
describe service(service_name) do | ||
it { should be_enabled } | ||
it { should be_running } | ||
end | ||
|
||
describe file("#{mod_dir}/pagespeed.conf") do | ||
it { should contain "AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html" } | ||
it { should contain "ModPagespeedEnableFilters remove_comments" } | ||
it { should contain "ModPagespeedDisableFilters extend_cache" } | ||
it { should contain "ModPagespeedForbidFilters rewrite_javascript" } | ||
end | ||
|
||
it 'should answer to pagespeed.example.com and include <head/> and be stripped of comments by mod_pagespeed' do | ||
shell("/usr/bin/curl pagespeed.example.com:80") do |r| | ||
r.stdout.should =~ /<head\/>/ | ||
r.stdout.should_not =~ /<!-- comment -->/ | ||
r.exit_code.should == 0 | ||
end | ||
end | ||
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,32 @@ | ||
describe 'apache::mod::pagespeed', :type => :class do | ||
let :pre_condition do | ||
'include apache' | ||
end | ||
context "on a Debian OS" do | ||
let :facts do | ||
{ | ||
:osfamily => 'Debian', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
it { should contain_class("apache::params") } | ||
it { should contain_apache__mod('pagespeed') } | ||
it { should contain_package("mod-pagespeed-stable") } | ||
it { should contain_file('pagespeed.conf') } | ||
end | ||
|
||
context "on a RedHat OS" do | ||
let :facts do | ||
{ | ||
:osfamily => 'RedHat', | ||
:operatingsystemrelease => '6', | ||
:concat_basedir => '/dne', | ||
} | ||
end | ||
it { should contain_class("apache::params") } | ||
it { should contain_apache__mod('pagespeed') } | ||
it { should contain_package("mod-pagespeed-stable") } | ||
it { should contain_file('pagespeed.conf') } | ||
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
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,101 @@ | ||
ModPagespeed on | ||
|
||
ModPagespeedInheritVHostConfig <%= @inherit_vhost_config %> | ||
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html | ||
<% if @filter_xhtml -%> | ||
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER application/xhtml+xml | ||
<% end -%> | ||
ModPagespeedFileCachePath "<%= @cache_path %>" | ||
ModPagespeedLogDir "<%= @log_dir %>" | ||
|
||
<% @memache_servers.each do |server| -%> | ||
ModPagespeedMemcachedServers <%= server -%> | ||
<% end -%> | ||
|
||
ModPagespeedRewriteLevel <%= @rewrite_level -%> | ||
|
||
<% @disable_filters.each do |filter| -%> | ||
ModPagespeedDisableFilters <%= filter -%> | ||
<% end -%> | ||
|
||
<% @enable_filters.each do |filter| -%> | ||
ModPagespeedEnableFilters <%= filter -%> | ||
<% end -%> | ||
|
||
<% @forbid_filters.each do |filter| -%> | ||
ModPagespeedForbidFilters <%= filter -%> | ||
<% end -%> | ||
|
||
ModPagespeedRewriteDeadlinePerFlushMs <%= @rewrite_deadline_per_flush_ms %> | ||
|
||
<% if @additional_domains -%> | ||
ModPagespeedDomain <%= @additional_domains -%> | ||
<% end -%> | ||
|
||
ModPagespeedFileCacheSizeKb <%= @file_cache_size_kb %> | ||
ModPagespeedFileCacheCleanIntervalMs <%= @file_cache_clean_interval_ms %> | ||
ModPagespeedLRUCacheKbPerProcess <%= @lru_cache_per_process %> | ||
ModPagespeedLRUCacheByteLimit <%= @lru_cache_byte_limit %> | ||
ModPagespeedCssFlattenMaxBytes <%= @css_flatten_max_bytes %> | ||
ModPagespeedCssInlineMaxBytes <%= @css_inline_max_bytes %> | ||
ModPagespeedCssImageInlineMaxBytes <%= @css_image_inline_max_bytes %> | ||
ModPagespeedImageInlineMaxBytes <%= @image_inline_max_bytes %> | ||
ModPagespeedJsInlineMaxBytes <%= @js_inline_max_bytes %> | ||
ModPagespeedCssOutlineMinBytes <%= @css_outline_min_bytes %> | ||
ModPagespeedJsOutlineMinBytes <%= @js_outline_min_bytes %> | ||
|
||
|
||
ModPagespeedFileCacheInodeLimit <%= @inode_limit %> | ||
ModPagespeedImageMaxRewritesAtOnce <%= @image_max_rewrites_at_once %> | ||
|
||
ModPagespeedNumRewriteThreads <%= @num_rewrite_threads %> | ||
ModPagespeedNumExpensiveRewriteThreads <%= @num_expensive_rewrite_threads %> | ||
|
||
ModPagespeedStatistics <%= @collect_statistics %> | ||
|
||
<Location /mod_pagespeed_statistics> | ||
Order allow,deny | ||
# You may insert other "Allow from" lines to add hosts you want to | ||
# allow to look at generated statistics. Another possibility is | ||
# to comment out the "Order" and "Allow" options from the config | ||
# file, to allow any client that can reach your server to examine | ||
# statistics. This might be appropriate in an experimental setup or | ||
# if the Apache server is protected by a reverse proxy that will | ||
# filter URLs in some fashion. | ||
Allow from localhost | ||
Allow from 127.0.0.1 | ||
Allow from ::1 | ||
<% @allow_view_stats.each do |host| -%> | ||
Allow from <%= host %> | ||
<% end -%> | ||
SetHandler mod_pagespeed_statistics | ||
</Location> | ||
|
||
ModPagespeedStatisticsLogging <%= @statistics_logging %> | ||
<Location /pagespeed_console> | ||
Order allow,deny | ||
Allow from localhost | ||
Allow from 127.0.0.1 | ||
Allow from ::1 | ||
<% @allow_pagespeed_console.each do |host| -%> | ||
Allow from <%= host %> | ||
<% end -%> | ||
SetHandler pagespeed_console | ||
</Location> | ||
|
||
ModPagespeedMessageBufferSize <%= @message_buffer_size %> | ||
|
||
<Location /mod_pagespeed_message> | ||
Order allow,deny | ||
Allow from localhost | ||
Allow from 127.0.0.1 | ||
Allow from ::1 | ||
<% @allow_pagespeed_message.each do |host| -%> | ||
Allow from <%= host %> | ||
<% end -%> | ||
SetHandler mod_pagespeed_message | ||
</Location> | ||
|
||
<% @additional_configuration.each_pair do |key, value| -%> | ||
<%= key %> <%= value %> | ||
<% end -%> |