From: Grant Slater Date: Sat, 4 Aug 2018 22:55:59 +0000 (+0100) Subject: Teach otrs about site aliases X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/0515f31b3462cc9720580a6b60d57914b241bfa2 Teach otrs about site aliases --- diff --git a/cookbooks/otrs/recipes/default.rb b/cookbooks/otrs/recipes/default.rb index c71c920c6..ab7093ea9 100644 --- a/cookbooks/otrs/recipes/default.rb +++ b/cookbooks/otrs/recipes/default.rb @@ -47,6 +47,7 @@ database_name = node[:otrs][:database_name] database_user = node[:otrs][:database_user] database_password = passwords[node[:otrs][:database_password]] site = node[:otrs][:site] +site_aliases = node[:otrs][:site_aliases] || [] postgresql_user database_user do cluster database_cluster @@ -130,12 +131,13 @@ Dir.glob("/opt/otrs/var/cron/*.dist") do |distname| end ssl_certificate site do - domains site + domains [site] + site_aliases notifies :reload, "service[apache2]" end apache_site site do template "apache.erb" + variables :aliases => site_aliases end template "/etc/sudoers.d/otrs" do diff --git a/cookbooks/otrs/templates/default/apache.erb b/cookbooks/otrs/templates/default/apache.erb index e392d8765..4018c36a1 100644 --- a/cookbooks/otrs/templates/default/apache.erb +++ b/cookbooks/otrs/templates/default/apache.erb @@ -1,72 +1,94 @@ # DO NOT EDIT - This file is being maintained by Chef - ServerName <%= @name %> - ServerAdmin webmaster@openstreetmap.org + ServerName <%= @name %> +<% @aliases.each do |alias_name| -%> + ServerAlias <%= alias_name %> +<% end -%> + ServerAdmin webmaster@openstreetmap.org - CustomLog /var/log/apache2/<%= @name %>-access.log combined - ErrorLog /var/log/apache2/<%= @name %>-error.log + CustomLog /var/log/apache2/<%= @name %>-access.log combined + ErrorLog /var/log/apache2/<%= @name %>-error.log - RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/ - RedirectPermanent / https://otrs.openstreetmap.org/ + RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/ + RedirectPermanent / https://otrs.openstreetmap.org/ +<% unless @aliases.empty? -%> - ServerName <%= @name %> - ServerAdmin webmaster@openstreetmap.org - - CustomLog /var/log/apache2/<%= @name %>-access.log combined - ErrorLog /var/log/apache2/<%= @name %>-error.log - - SSLEngine on - SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem - SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key - - ScriptAlias /otrs/ /opt/otrs/bin/cgi-bin/ - Alias /otrs-web/ /opt/otrs/var/httpd/htdocs/ - RedirectMatch ^/$ /otrs/index.pl - - PerlRequire /opt/otrs/scripts/apache2-perl-startup.pl - - PerlModule Apache2::Reload - PerlInitHandler Apache2::Reload - PerlModule Apache2::RequestRec - - - ErrorDocument 403 /otrs/index.pl - ErrorDocument 404 /otrs/index.pl - SetHandler perl-script - PerlResponseHandler ModPerl::Registry - Options +ExecCGI - PerlOptions +ParseHeaders - PerlOptions +SetupEnv - Require all granted - - - - PerlOptions -ParseHeaders - + ServerName <%= @aliases.first %> +<% @aliases.drop(1).each do |alias_name| -%> + ServerAlias <%= alias_name %> +<% end -%> + ServerAdmin webmaster@openstreetmap.org + + SSLEngine on + SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem + SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key + + CustomLog /var/log/apache2/<%= @name %>-access.log combined + ErrorLog /var/log/apache2/<%= @name %>-error.log + + RedirectPermanent / https://<%= @name %>/ +<% end -%> - - AllowOverride None - Options +ExecCGI -Includes - Require all granted - + + ServerName <%= @name %> + ServerAdmin webmaster@openstreetmap.org - - AllowOverride None - Require all granted - + CustomLog /var/log/apache2/<%= @name %>-access.log combined + ErrorLog /var/log/apache2/<%= @name %>-error.log - - - Header set Cache-Control "max-age=2592000 must-revalidate" - - + SSLEngine on + SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem + SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key + + ScriptAlias /otrs/ /opt/otrs/bin/cgi-bin/ + Alias /otrs-web/ /opt/otrs/var/httpd/htdocs/ + RedirectMatch ^/$ /otrs/index.pl + + PerlRequire /opt/otrs/scripts/apache2-perl-startup.pl + + PerlModule Apache2::Reload + PerlInitHandler Apache2::Reload + PerlModule Apache2::RequestRec + + + ErrorDocument 403 /otrs/index.pl + ErrorDocument 404 /otrs/index.pl + SetHandler perl-script + PerlResponseHandler ModPerl::Registry + Options +ExecCGI + PerlOptions +ParseHeaders + PerlOptions +SetupEnv + Require all granted + + + + PerlOptions -ParseHeaders + + + + + AllowOverride None + Options +ExecCGI -Includes + Require all granted + + + + AllowOverride None + Require all granted + + + + + Header set Cache-Control "max-age=2592000 must-revalidate" + + - - - Header set Cache-Control "max-age=2592000 must-revalidate" - + + + Header set Cache-Control "max-age=2592000 must-revalidate" + diff --git a/roles/otrs.rb b/roles/otrs.rb index 19d630771..c44a42e7c 100644 --- a/roles/otrs.rb +++ b/roles/otrs.rb @@ -46,6 +46,7 @@ default_attributes( }, :otrs => { :site => "otrs.openstreetmap.org", + :site_aliases => ["otrs.osm.org"], :database_cluster => "10/main", :database_name => "otrs", :database_user => "otrs",