From 863b4d1089ab505523388beaa09b6d3f346b59a9 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Thu, 3 Nov 2016 10:15:42 +0100
Subject: [PATCH] #4 Restructure installation

---
 handlers/main.yml |  5 -----
 tasks/install.yml | 18 ++++++++++++++++++
 tasks/main.yml    | 10 +---------
 3 files changed, 19 insertions(+), 14 deletions(-)
 create mode 100644 tasks/install.yml

diff --git a/handlers/main.yml b/handlers/main.yml
index 5963d66..7b79d5b 100644
--- a/handlers/main.yml
+++ b/handlers/main.yml
@@ -1,11 +1,6 @@
 ---
 # file: roles/netdata/handlers/main.yml
 
-- name: "Install and configure NetData"
-  shell: ./netdata-installer.sh --dont-wait
-  args:
-    chdir: /opt/netdata
-
 - name: "Include NetData to Boot-List"
   command: update-rc.d netdata defaults
 
diff --git a/tasks/install.yml b/tasks/install.yml
new file mode 100644
index 0000000..9322356
--- /dev/null
+++ b/tasks/install.yml
@@ -0,0 +1,18 @@
+---
+# file: roles/netdata/tasks/install.yml
+
+- name: "Clone NetData"
+  git:
+    accept_hostkey: true
+    repo: "https://github.com/firehol/netdata.git"
+    dest: "/opt/netdata"
+    force: yes
+  register: netdata_clone
+  notify:
+    - "Re-start NetData"
+
+- name: "Install and configure NetData"
+  shell: ./netdata-installer.sh --dont-wait
+  args:
+    chdir: /opt/netdata
+  when: netdata_clone.changed
diff --git a/tasks/main.yml b/tasks/main.yml
index d1a364f..201449f 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -32,15 +32,7 @@
       path='/etc/netdata/python.d'
       state='directory'
 
-  - name: "Clone NetData"
-    git:
-      accept_hostkey: true
-      repo: "https://github.com/firehol/netdata.git"
-      dest: "/opt/netdata"
-      force: yes
-    notify:
-      - "Install and configure NetData"
-      - "Re-start NetData"
+  - include: install.yml
 
   - name: "Install startup script"
     template:
-- 
GitLab