From 5bd8505ac9936f701c9fa98e07009c593bffd0ce Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Fri, 1 Jul 2016 13:05:18 +0200
Subject: [PATCH] Configure pythin plugins

---
 tasks/main.yml          | 24 ++++++++++++++++++++++++
 templates/mysql.conf    |  6 ++++++
 templates/python.d.conf |  8 ++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 templates/mysql.conf
 create mode 100644 templates/python.d.conf

diff --git a/tasks/main.yml b/tasks/main.yml
index e2f3e22..d4703f4 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -22,6 +22,8 @@
       - automake
       - pkg-config
       - uuid-dev
+      - python-dev
+      - python-yaml
       #FireQOS available from 15.04
       #- firehol
 
@@ -65,6 +67,28 @@
     notify:
       - "Re-start NetData"
 
+  - name: "Configure Python Plugin"
+    template:
+      src='python.d.conf'
+      dest='/etc/netdata/python.d.conf'
+      owner='netdata'
+      group='netdata'
+      mode=644
+    notify:
+      - "Re-start NetData"
+
+  - name: "Configure Plugins"
+    template:
+      src='{{ item }}.conf'
+      dest='/etc/netdata/python.d/{{ item }}.conf'
+      owner='netdata'
+      group='netdata'
+      mode=644
+    with_items:
+      - 'mysql'
+    notify:
+      - "Re-start NetData"
+
   - name: "Check if KSM is available"
     stat: path='/sys/kernel/mm/ksm'
     register: ksm
diff --git a/templates/mysql.conf b/templates/mysql.conf
new file mode 100644
index 0000000..645e287
--- /dev/null
+++ b/templates/mysql.conf
@@ -0,0 +1,6 @@
+update_every: 5
+local:
+  user: 'root'
+  password: '{{ mysql_root_password|default("root") }}'
+  host: '127.0.0.1'
+  port: '3306'
diff --git a/templates/python.d.conf b/templates/python.d.conf
new file mode 100644
index 0000000..1123436
--- /dev/null
+++ b/templates/python.d.conf
@@ -0,0 +1,8 @@
+# This is the configuration for python.d.plugin
+enabled: yes
+
+example: no
+mysql: {{ (groups['dbserver-mysql'] is defined and inventory_hostname in groups['dbserver-mysql'])|ternary("yes", "no") }}
+phpfpm: no
+apache: {{ (groups['webserver'] is defined and inventory_hostname in groups['webserver'])|ternary("yes", "no") }}
+nginx: no
-- 
GitLab