From d218cbbb843050fa3378b136384e75a530987003 Mon Sep 17 00:00:00 2001
From: Monty Taylor <mordred@inaugust.com>
Date: Tue, 21 Nov 2017 13:59:21 -0600
Subject: [PATCH] Only run whereto if htaccess file exists

Update the sphinx job to not attempt whereto if there is no htacess file
in the first place.

Change-Id: Ie6835a48ee62bd8f0ac2e5cd6f3684c328ac6b02
---
 roles/sphinx/tasks/main.yaml | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/roles/sphinx/tasks/main.yaml b/roles/sphinx/tasks/main.yaml
index b057231f7..769ae6142 100644
--- a/roles/sphinx/tasks/main.yaml
+++ b/roles/sphinx/tasks/main.yaml
@@ -12,9 +12,18 @@
     get_md5: false
   register: whereto
 
-# TODO(mordred) What happens with whereto if sphinx_source_dir is not doc/source?
+- name: Check for htaccess
+  stat:
+    path: "{{ zuul_work_dir }}/{{ sphinx_source_dir }}/_extra/.htaccess"
+    get_checksum: false
+    get_mime: false
+    get_md5: false
+  register: htaccess
+
 - name: Run whereto
   command:
     cmd: "{{ whereto.stat.path }} {{ sphinx_source_dir }}/_extra/.htaccess doc/test/redirect-tests.txt"
     chdir: "{{ zuul_work_dir }}"
-  when: whereto.stat.exists
+  when:
+    - whereto.stat.exists
+    - htaccess.stat.exists