From 8ed7cf4c525c0356098c8e25fb2958eff00143b2 Mon Sep 17 00:00:00 2001
From: Tristan Cacqueray <tdecacqu@redhat.com>
Date: Sun, 24 Jun 2018 23:42:02 +0000
Subject: [PATCH] log-inventory: add missing zuul_info_dir prep

The role can't be used as-is without zuul_info_dir fact.

Change-Id: Id785f1b10e60dd09342edcebcbe7923b161add3c
---
 roles/log-inventory/README.rst         | 7 +++++++
 roles/log-inventory/defaults/main.yaml | 2 ++
 roles/log-inventory/tasks/main.yaml    | 7 +++++++
 3 files changed, 16 insertions(+)
 create mode 100644 roles/log-inventory/defaults/main.yaml

diff --git a/roles/log-inventory/README.rst b/roles/log-inventory/README.rst
index ea7b523f9..ffc7244ce 100644
--- a/roles/log-inventory/README.rst
+++ b/roles/log-inventory/README.rst
@@ -1,3 +1,10 @@
 Log the inventory used to run the job to the job's log dir.
 
 This will result in the log collection roles logging the job inventory.
+
+**Role Variables**
+
+.. zuul:rolevar:: zuul_info_dir
+   :default: {{ zuul.executor.log_root }}/zuul-info
+
+   The directory path to store the inventory file.
diff --git a/roles/log-inventory/defaults/main.yaml b/roles/log-inventory/defaults/main.yaml
new file mode 100644
index 000000000..bbfd07069
--- /dev/null
+++ b/roles/log-inventory/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+zuul_info_dir: "{{ zuul.executor.log_root }}/zuul-info"
diff --git a/roles/log-inventory/tasks/main.yaml b/roles/log-inventory/tasks/main.yaml
index e3dad5544..3f8572c55 100644
--- a/roles/log-inventory/tasks/main.yaml
+++ b/roles/log-inventory/tasks/main.yaml
@@ -1,3 +1,10 @@
+- name: Ensure Zuul Ansible directory exists
+  delegate_to: localhost
+  run_once: true
+  file:
+    path: "{{ zuul_info_dir }}"
+    state: directory
+
 - name: Copy ansible inventory to logs dir
   delegate_to: localhost
   copy: