From abcae98b8eca8d751ee87d5ae5f4d003aee7091f Mon Sep 17 00:00:00 2001
From: Jeremy Stanley <fungi@yuggoth.org>
Date: Fri, 7 Feb 2020 15:37:37 +0000
Subject: [PATCH] Add a new docs.airshipit.org vhost on static01

The Airship project is continuously publishing documentation to AFS,
so serve that volume with a corresponding vhost on the static01
server. Also add it to the list of volumes for periodic vos release.

Change-Id: I718963533d9e8596d44d451b5e930314d699fa28
Depends-On: https://review.opendev.org/706599
---
 .../afs-release/files/release-volumes.py      |  1 +
 .../static/files/50-docs.airshipit.org.conf   | 41 +++++++++++++++++++
 playbooks/roles/static/tasks/main.yaml        |  1 +
 testinfra/test_static.py                      |  6 +++
 4 files changed, 49 insertions(+)
 create mode 100755 playbooks/roles/static/files/50-docs.airshipit.org.conf

diff --git a/playbooks/roles/afs-release/files/release-volumes.py b/playbooks/roles/afs-release/files/release-volumes.py
index 2becb0c5b8..7559a6771a 100644
--- a/playbooks/roles/afs-release/files/release-volumes.py
+++ b/playbooks/roles/afs-release/files/release-volumes.py
@@ -32,6 +32,7 @@ from datetime import datetime
 
 VOLUMES = ['docs',
            'docs.dev',
+           'project.airship',
            'project.governance',
            'project.opendev',
            'project.releases',
diff --git a/playbooks/roles/static/files/50-docs.airshipit.org.conf b/playbooks/roles/static/files/50-docs.airshipit.org.conf
new file mode 100755
index 0000000000..db1d04b4df
--- /dev/null
+++ b/playbooks/roles/static/files/50-docs.airshipit.org.conf
@@ -0,0 +1,41 @@
+Define AFS_ROOT /afs/openstack.org/project/airshipit.org
+
+<VirtualHost *:80>
+  ServerName docs.airshipit.org
+  RewriteEngine On
+  RewriteRule ^/(.*) https://docs.airshipit.org/$1 [last,redirect=permanent]
+  LogLevel warn
+  ErrorLog /var/log/apache2/docs.airshipit.org_error.log
+  CustomLog /var/log/apache2/docs.airshipit.org_access.log combined
+  ServerSignature Off
+</VirtualHost>
+
+<IfModule mod_ssl.c>
+<VirtualHost *:443>
+
+  ServerName docs.airshipit.org
+
+  DocumentRoot ${AFS_ROOT}/docs
+
+  SSLCertificateFile      /etc/letsencrypt-certs/docs.airshipit.org/docs.airshipit.org.cer
+  SSLCertificateKeyFile   /etc/letsencrypt-certs/docs.airshipit.org/docs.airshipit.org.key
+  SSLCertificateChainFile /etc/letsencrypt-certs/docs.airshipit.org/ca.cer
+  SSLProtocol All -SSLv2 -SSLv3
+  # Note: this list should ensure ciphers that provide forward secrecy
+  SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:!AES256:!aNULL:!eNULL:!MD5:!DSS:!PSK:!SRP
+  SSLHonorCipherOrder on
+
+  <Directory ${AFS_ROOT}/docs>
+    Options Indexes FollowSymLinks MultiViews
+    AllowOverrideList Redirect RedirectMatch
+    Satisfy Any
+    Require all granted
+  </Directory>
+
+  LogLevel warn
+  ErrorLog /var/log/apache2/docs.airshipit.org_error.log
+  CustomLog /var/log/apache2/docs.airshipit.org_access.log combined
+  ServerSignature Off
+
+</VirtualHost>
+</IfModule>
diff --git a/playbooks/roles/static/tasks/main.yaml b/playbooks/roles/static/tasks/main.yaml
index 2dfa82c5c2..f687fe778f 100644
--- a/playbooks/roles/static/tasks/main.yaml
+++ b/playbooks/roles/static/tasks/main.yaml
@@ -74,6 +74,7 @@
     - 50-cinder.openstack.org
     - 50-developer.openstack.org
     - 50-devstack.org
+    - 50-docs.airshipit.org
     - 50-docs.opendev.org
     - 50-docs.openstack.org
     - 50-docs.starlingx.io
diff --git a/testinfra/test_static.py b/testinfra/test_static.py
index 194c36fa52..9527c7243b 100644
--- a/testinfra/test_static.py
+++ b/testinfra/test_static.py
@@ -42,6 +42,12 @@ def test_static_opendev_org(host, name):
                    (name, name))
     assert 'Index of /' in cmd.stdout
 
+def test_docs_airshipit_org(host):
+    cmd = host.run('curl --insecure '
+                   '--resolve docs.airshipit.org:443:127.0.0.1 '
+                   'https://docs.airshipit.org/')
+    assert 'Airship Treasuremap' in cmd.stdout
+
 def test_governance_openstack_org(host):
     cmd = host.run('curl --insecure '
                    '--resolve governance.openstack.org:443:127.0.0.1 '