From a7c1b0e1914b34815c7989a5741b48e5b994c405 Mon Sep 17 00:00:00 2001
From: Andreas Jaeger <aj@suse.com>
Date: Fri, 27 Oct 2017 19:34:24 +0200
Subject: [PATCH] Fix prepare-docs-for-afs

To support arbitrary doc directories like we need for install-guide and
deploy-guide, we need to name that. The previous change had an error
where we used a complete wrong path, fix this.

This needs changes for install-guide and deploy-guide publishing.

Needed-By: I708dab3119bb4b167b4ae68eb7fa575fa96e7984
Change-Id: Ib9c28eeea6c369f4ccad50c0672eee4f91b4370a
---
 roles/prepare-docs-for-afs/README.rst         | 8 +++++---
 roles/prepare-docs-for-afs/defaults/main.yaml | 2 +-
 roles/prepare-docs-for-afs/tasks/main.yaml    | 6 +++++-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/roles/prepare-docs-for-afs/README.rst b/roles/prepare-docs-for-afs/README.rst
index 60e1eb91..92823ef5 100644
--- a/roles/prepare-docs-for-afs/README.rst
+++ b/roles/prepare-docs-for-afs/README.rst
@@ -5,7 +5,9 @@ Prepare built OpenStack docs to be published to the OpenStack AFS cell.
 
    Directory to build documentation in.
 
-.. zuul:rolevar:: doc_build_dir
-   :default: {{ zuul_work_dir }}/doc/build
+.. zuul:rolevar:: doc_toplevel_dir
+   :default: doc
+
+   Directory where the documentation lives, the build documentation is
+   in a sub directory called build, by default doc/build.
 
-   Directory that contains the built documentation.
diff --git a/roles/prepare-docs-for-afs/defaults/main.yaml b/roles/prepare-docs-for-afs/defaults/main.yaml
index 775dccc4..26e706af 100644
--- a/roles/prepare-docs-for-afs/defaults/main.yaml
+++ b/roles/prepare-docs-for-afs/defaults/main.yaml
@@ -1,2 +1,2 @@
 zuul_work_dir: "src/{{ zuul.project.canonical_name }}"
-doc_build_dir: "{{ zuul_work_dir }}/doc/build"
+doc_toplevel_dir: "doc"
diff --git a/roles/prepare-docs-for-afs/tasks/main.yaml b/roles/prepare-docs-for-afs/tasks/main.yaml
index b7346b41..87de0329 100644
--- a/roles/prepare-docs-for-afs/tasks/main.yaml
+++ b/roles/prepare-docs-for-afs/tasks/main.yaml
@@ -1,3 +1,7 @@
+- name: Set build directory
+  set_fact:
+    doc_build_dir: "{{ zuul_work_dir }}/{{doc_toplevel_dir}}/build"
+
 - name: Write marker text
   copy:
     dest: "{{ doc_build_dir }}/html/.root-marker"
@@ -21,7 +25,7 @@
     executable: /bin/bash
   shell: |
     set -xe
-    DOCBUILD="{{ doc_build_dir }}"
+    DOCBUILD="{{ doc_toplevel_dir }}/build"
     if [[ {{ zuul.ref }} =~ ^refs/tags/ ]]; then
         # This job should not be configured to run for
         # pre-releases, so if we have a tag we want to use it as