Add fetch-log-file role
Change-Id: Ibbcbc395e1aedde3f61e41abdaa43c65f8e30742
diff --git a/roles/fetch-log-file/README.md b/roles/fetch-log-file/README.md
new file mode 100644
index 0000000..6f847d1
--- /dev/null
+++ b/roles/fetch-log-file/README.md
@@ -0,0 +1 @@
+Fetch a log file and store it in the executor.
diff --git a/roles/fetch-log-file/tasks/main.yaml b/roles/fetch-log-file/tasks/main.yaml
new file mode 100644
index 0000000..310ba87
--- /dev/null
+++ b/roles/fetch-log-file/tasks/main.yaml
@@ -0,0 +1,19 @@
+- name: Check sourceFile and logFileName are set
+ when: sourceFile is not defined or logFileName is not defined
+ fail:
+ msg: "sourceFile and logFileName must be set"
+
+- name: Does the file exist
+ register: stat_log
+ stat:
+ path: "{{ sourceFile }}"
+
+- name: Store on executor
+ when: stat_log.stat.exists
+ synchronize:
+ mode: pull
+ src: "{{ sourceFile }}"
+ dest: "{{ zuul.executor.log_root }}/{{ logFileName }}"
+ verify_host: true
+ owner: no
+ group: no