From 1176ccb5e407f1048f469b6826c9218a366c7a49 Mon Sep 17 00:00:00 2001
From: Paul Belanger <pabelanger@redhat.com>
Date: Tue, 8 Dec 2015 17:17:40 -0500
Subject: [PATCH] Create default directories

Signed-off-by: Paul Belanger <pabelanger@redhat.com>
---
 defaults/main.yaml        | 6 +++++-
 tasks/config.yaml         | 9 +++++++++
 tasks/install/redhat.yaml | 2 +-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/defaults/main.yaml b/defaults/main.yaml
index 59e36c7..55c2a3c 100644
--- a/defaults/main.yaml
+++ b/defaults/main.yaml
@@ -12,6 +12,10 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 ---
+jenkins_user_name: jenkins
+jenkins_user_group: "{{ jenkins_user_name }}"
+jenkins_user_home: "/var/lib/{{ jenkins_user_name }}"
+
 jenkins_config_ajp_listen_address: 127.0.0.1
 jenkins_config_ajp_port: -1
 jenkins_config_args: ''
@@ -19,7 +23,7 @@ jenkins_config_debug_level: 5
 jenkins_config_enable_access_log: no
 jenkins_config_handler_idle: 20
 jenkins_config_handler_max: 100
-jenkins_config_home: /var/lib/jenkins
+jenkins_config_home: "{{ jenkins_user_home }}"
 jenkins_config_https_keystore: ''
 jenkins_config_https_keystore_password: ''
 jenkins_config_https_listen_address: 127.0.0.1
diff --git a/tasks/config.yaml b/tasks/config.yaml
index 319c10f..67f6fcc 100644
--- a/tasks/config.yaml
+++ b/tasks/config.yaml
@@ -12,6 +12,15 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 ---
+- name: Create required directories.
+  file:
+    group: "{{ jenkins_user_group }}"
+    owner: "{{ jenkins_user_name }}"
+    path: "{{ item }}"
+    state: directory
+  with_items:
+    - "{{ jenkins_user_home }}/plugins"
+
 - name: Template clouds yaml file.
   template:
     dest: "{{ jenkins_template_config_dest }}"
diff --git a/tasks/install/redhat.yaml b/tasks/install/redhat.yaml
index 86e37e3..7731609 100644
--- a/tasks/install/redhat.yaml
+++ b/tasks/install/redhat.yaml
@@ -13,7 +13,7 @@
 # under the License.
 ---
 - name: Ensure build dependencies are installed.
-  yum: 
+  yum:
     pkg: "{{ item }}"
     state: installed
   with_items: jenkins_build_depends