From 0177b406182dd0c8c932b37f13943ce990311223 Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Mon, 14 Sep 2020 11:14:28 +1000
Subject: [PATCH] zuul-web: move LogFormat combined-cache into config

These two values overwrite each other, move into common configuration.

The "cache-status" is a verbose string, so quote it.

Change-Id: I3cc4627de3d6a0de1adcfed6b424fc3ed0099245
---
 playbooks/roles/zuul-web/files/log-combined-cache.conf |  2 ++
 playbooks/roles/zuul-web/tasks/main.yaml               | 10 ++++++++++
 playbooks/roles/zuul-web/templates/openstack.vhost.j2  |  4 ----
 playbooks/roles/zuul-web/templates/zuul.vhost.j2       |  4 ----
 4 files changed, 12 insertions(+), 8 deletions(-)
 create mode 100644 playbooks/roles/zuul-web/files/log-combined-cache.conf

diff --git a/playbooks/roles/zuul-web/files/log-combined-cache.conf b/playbooks/roles/zuul-web/files/log-combined-cache.conf
new file mode 100644
index 0000000000..4168842cad
--- /dev/null
+++ b/playbooks/roles/zuul-web/files/log-combined-cache.conf
@@ -0,0 +1,2 @@
+LogFormat "%h %l %u [%{%F %T}t.%{msec_frac}t] \"%r\" %>s %b \"%{cache-status}e\" \"%{Referer}i\" \"%{User-agent}i\"" combined-cache
+
diff --git a/playbooks/roles/zuul-web/tasks/main.yaml b/playbooks/roles/zuul-web/tasks/main.yaml
index a1b57de660..4c3a714807 100644
--- a/playbooks/roles/zuul-web/tasks/main.yaml
+++ b/playbooks/roles/zuul-web/tasks/main.yaml
@@ -29,6 +29,16 @@
     - 50-zuul.openstack.org.conf
     - 50-zuul.openstack.org-http.conf
 
+- name: Copy common log configuration
+  copy:
+    src: log-combined-cache.conf
+    dest: /etc/apache2/conf-available
+  register: _log_combined_cache
+
+- name: Enable combined cache log config
+  command: a2enconf log-combined-cache
+  when: _log_combined_cache.changed
+
 - name: Copy apache config
   template:
     src: zuul.vhost.j2
diff --git a/playbooks/roles/zuul-web/templates/openstack.vhost.j2 b/playbooks/roles/zuul-web/templates/openstack.vhost.j2
index 0e99a5aacf..00545d400e 100644
--- a/playbooks/roles/zuul-web/templates/openstack.vhost.j2
+++ b/playbooks/roles/zuul-web/templates/openstack.vhost.j2
@@ -1,7 +1,3 @@
-{% raw %}
-LogFormat "%h %l %u [%{%F %T}t.%{msec_frac}t] \"%r\" %>s %b %{cache-status}e \"%{Referer}i\" \"%{User-agent}i\"" combined-cache
-{% endraw %}
-
 <VirtualHost *:80>
   ServerName zuul.openstack.org
   ServerAdmin webmaster@openstack.org
diff --git a/playbooks/roles/zuul-web/templates/zuul.vhost.j2 b/playbooks/roles/zuul-web/templates/zuul.vhost.j2
index 8f45aaf746..17a486d6b6 100644
--- a/playbooks/roles/zuul-web/templates/zuul.vhost.j2
+++ b/playbooks/roles/zuul-web/templates/zuul.vhost.j2
@@ -1,7 +1,3 @@
-{% raw %}
-LogFormat "%h %l %u [%{%F %T}t.%{msec_frac}t] \"%r\" %>s %b %{cache-status}e \"%{Referer}i\" \"%{User-agent}i\"" combined-cache
-{% endraw %}
-
 <VirtualHost *:80>
   ServerName zuul.opendev.org
   ServerAdmin webmaster@openstack.org