From 2f8c9f83fa78b67879a7be6090bf319ac71ee659 Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Tue, 6 Mar 2018 13:25:16 +0000
Subject: [PATCH] Use www-data user for bifrost nginx log directory

Bifrost uses the www-data user for nginx on debian/ubuntu, and nginx on
other platforms. Kolla-ansible currently uses the nginx user for all
platforms when creating a log directory. This change uses the www-data
user on debian/ubuntu when setting ownership of the bifrost nginx log
directory.

Change-Id: I142a158b6f2e8f8a46b684267f6fbb2a6e22a259
Closes-Bug: #1753750
---
 ansible/roles/bifrost/tasks/bootstrap.yml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ansible/roles/bifrost/tasks/bootstrap.yml b/ansible/roles/bifrost/tasks/bootstrap.yml
index 3b051df143..ee0507d46c 100644
--- a/ansible/roles/bifrost/tasks/bootstrap.yml
+++ b/ansible/roles/bifrost/tasks/bootstrap.yml
@@ -1,5 +1,8 @@
 ---
 - name: Ensure log directories exist
+  vars:
+    nginx_user: "{{ 'www-data' if is_debian else 'nginx' }}"
+    is_debian: "{{ kolla_base_distro in ['debian', 'ubuntu'] }}"
   command: >
      docker exec bifrost_deploy
      bash -c 'mkdir -p /var/log/kolla/ironic &&
@@ -7,7 +10,7 @@
      mkdir -p /var/log/kolla/ironic-inspector &&
      chown ironic:ironic /var/log/kolla/ironic-inspector &&
      mkdir -p /var/log/kolla/nginx &&
-     chown nginx:nginx /var/log/kolla/nginx'
+     chown {{ nginx_user }}:{{ nginx_user }} /var/log/kolla/nginx'
 
 - name: Bootstrap bifrost (this may take several minutes)
   command: >