From: Grant Slater Date: Sat, 4 Aug 2018 14:23:45 +0000 (+0100) Subject: Teach serverinfo about site aliases X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/26eeab924cfb9f5f9289b5dcc1860d9bc9afe6ff Teach serverinfo about site aliases --- diff --git a/cookbooks/cgiirc/templates/default/apache.erb b/cookbooks/cgiirc/templates/default/apache.erb index 21e673308..1afb107ba 100644 --- a/cookbooks/cgiirc/templates/default/apache.erb +++ b/cookbooks/cgiirc/templates/default/apache.erb @@ -1,56 +1,56 @@ # DO NOT EDIT - This file is being maintained by Chef - ServerName <%= @name %> - ServerAdmin webmaster@openstreetmap.org + ServerName <%= @name %> + ServerAdmin webmaster@openstreetmap.org - SSLEngine on - SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem - SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key + 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 + CustomLog /var/log/apache2/<%= @name %>-access.log combined + ErrorLog /var/log/apache2/<%= @name %>-error.log - DocumentRoot /usr/lib/cgi-bin/cgiirc - DirectoryIndex irc.cgi - Alias /images /usr/share/images/cgiirc + DocumentRoot /usr/lib/cgi-bin/cgiirc + DirectoryIndex irc.cgi + Alias /images /usr/share/images/cgiirc - - AddHandler cgi-script .cgi - Require all granted - + + AddHandler cgi-script .cgi + Require all granted + - - Require all granted - + + Require all granted + - - RemoveOutputFilter DEFLATE - SetEnv no-gzip - + + RemoveOutputFilter DEFLATE + SetEnv no-gzip + <% unless @aliases.empty? -%> - ServerName <%= @aliases.first %> + ServerName <%= @aliases.first %> <% @aliases.drop(1).each do |alias_name| -%> - ServerAlias <%= alias_name %> + ServerAlias <%= alias_name %> <% end -%> - ServerAdmin webmaster@openstreetmap.org + ServerAdmin webmaster@openstreetmap.org - SSLEngine on - SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem - SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key + 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 + CustomLog /var/log/apache2/<%= @name %>-access.log combined + ErrorLog /var/log/apache2/<%= @name %>-error.log - RedirectPermanent / https://<%= @name %>/ + RedirectPermanent / https://<%= @name %>/ <% end -%> - ServerName <%= @name %> + ServerName <%= @name %> <% @aliases.each do |alias_name| -%> ServerAlias <%= alias_name %> <% end -%> diff --git a/cookbooks/osqa/templates/default/apache.erb b/cookbooks/osqa/templates/default/apache.erb index 546067b56..975547471 100644 --- a/cookbooks/osqa/templates/default/apache.erb +++ b/cookbooks/osqa/templates/default/apache.erb @@ -3,56 +3,56 @@ WSGIDaemonProcess <%= @name %> user=<%= @user %> group=<%= @group %> processes=4 threads=4 - ServerName <%= @name %> - <% @aliases.each do |alias_name| -%> - ServerAlias <%= alias_name %> - <% end -%> - 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://<%= @name %>/ + RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/ + RedirectPermanent / https://<%= @name %>/ <% unless @aliases.empty? -%> - ServerName <%= @aliases.first %> + ServerName <%= @aliases.first %> <% @aliases.drop(1).each do |alias_name| -%> - ServerAlias <%= alias_name %> + ServerAlias <%= alias_name %> <% end -%> - ServerAdmin webmaster@openstreetmap.org + ServerAdmin webmaster@openstreetmap.org - SSLEngine on - SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem - SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key + 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 + CustomLog /var/log/apache2/<%= @name %>-access.log combined + ErrorLog /var/log/apache2/<%= @name %>-error.log - RedirectPermanent / https://<%= @name %>/ + RedirectPermanent / https://<%= @name %>/ <% end -%> - ServerName <%= @name %> - ServerAdmin webmaster@openstreetmap.org + ServerName <%= @name %> + ServerAdmin webmaster@openstreetmap.org - SSLEngine on - SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem - SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key + 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 + CustomLog /var/log/apache2/<%= @name %>-access.log combined + ErrorLog /var/log/apache2/<%= @name %>-error.log - DocumentRoot <%= @directory %>/osqa - Alias /m/ <%= @directory %>/osqa/forum/skins/ - Alias /upfiles/ <%= @directory %>/upfiles/ - Alias /admin_media/ /usr/share/pyshared/django/contrib/admin/media/ - WSGIScriptAlias / <%= @directory %>/osqa/osqa.wsgi + DocumentRoot <%= @directory %>/osqa + Alias /m/ <%= @directory %>/osqa/forum/skins/ + Alias /upfiles/ <%= @directory %>/upfiles/ + Alias /admin_media/ /usr/share/pyshared/django/contrib/admin/media/ + WSGIScriptAlias / <%= @directory %>/osqa/osqa.wsgi - WSGIProcessGroup <%= @name %> + WSGIProcessGroup <%= @name %> /osqa> diff --git a/cookbooks/serverinfo/recipes/default.rb b/cookbooks/serverinfo/recipes/default.rb index 2278082c9..4c46db5a0 100644 --- a/cookbooks/serverinfo/recipes/default.rb +++ b/cookbooks/serverinfo/recipes/default.rb @@ -67,11 +67,12 @@ execute "/srv/hardware.openstreetmap.org" do end ssl_certificate "hardware.openstreetmap.org" do - domains "hardware.openstreetmap.org" + domains ["hardware.openstreetmap.org", "hardware.osm.org"] notifies :reload, "service[apache2]" end apache_site "hardware.openstreetmap.org" do template "apache.erb" directory "/srv/hardware.openstreetmap.org/_site" + variables :aliases => ["hardware.osm.org"] end diff --git a/cookbooks/serverinfo/templates/default/apache.erb b/cookbooks/serverinfo/templates/default/apache.erb index 04e4a6797..309f59550 100644 --- a/cookbooks/serverinfo/templates/default/apache.erb +++ b/cookbooks/serverinfo/templates/default/apache.erb @@ -1,30 +1,52 @@ # 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/ - Redirect permanent / https://<%= @name %>/ + RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/ + Redirect permanent / https://<%= @name %>/ +<% unless @aliases.empty? -%> - ServerName <%= @name %> - ServerAdmin webmaster@openstreetmap.org + ServerName <%= @aliases.first %> +<% @aliases.drop(1).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 + SSLEngine on + SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem + SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key - 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 - DocumentRoot <%= @directory %> + RedirectPermanent / https://<%= @name %>/ + +<% end -%> + + + 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 + + DocumentRoot <%= @directory %> > - Require all granted + Require all granted