diff --git a/tasks/apache.yml b/tasks/apache.yml
new file mode 100644
index 0000000000000000000000000000000000000000..d3a18da990a9de58a537b02d82f9b7ab7fbdec4c
--- /dev/null
+++ b/tasks/apache.yml
@@ -0,0 +1,21 @@
+---
+# file: roles/netdata/tasks/apache.yml
+
+- name: "Enable Apache Status Module"
+  apache2_module:
+    name: 'status'
+    state: 'present'
+  notify: "Restart Apache"
+
+- name: "Apache Status Site"
+  template:
+    src: 'apache.conf'
+    dest: '/etc/apache2/sites-available/status{{ apache_conf_ext|default('.conf') }}'
+    owner: 'root'
+    group: 'root'
+    mode: 644
+  notify: "Restart Apache"
+
+- name: "Enable Apache Status Site"
+  command: a2ensite status creates=/etc/apache2/sites-enabled/status{{ apache_conf_ext|default('.conf') }}
+  notify: "Restart Apache"
diff --git a/tasks/configure.yml b/tasks/configure.yml
new file mode 100644
index 0000000000000000000000000000000000000000..30a8d8528ead608905f5cc3d4754b2fbfa2884fe
--- /dev/null
+++ b/tasks/configure.yml
@@ -0,0 +1,60 @@
+---
+# file: roles/netdata/tasks/configure.yml
+
+- name: "Add User to Admins"
+  user:
+    name: 'netdata'
+    groups: 'adm'
+    append: yes
+
+- name: "Configure Registry"
+  ini_file:
+    dest: '/etc/netdata/netdata.conf'
+    create: yes
+    section: 'registry'
+    option: '{{ item.option }}'
+    value: '{{ item.value }}'
+  with_items:
+    - option: 'enabled'
+      value: '{{ (netdata_registry|default("pmon1") == inventory_hostname)|ternary("yes", "no") }}'
+    - option: 'registry to announce'
+      value: 'http://{{ netdata_registry|default("pmon1") }}:19999'
+  notify:
+    - "Restart NetData"
+
+- name: "Configure NetData"
+  template:
+    src: '{{ item }}'
+    dest: '/etc/netdata/{{ item }}'
+    owner: 'root'
+    group: 'root'
+    mode: 644
+    backup: yes
+  with_items:
+    - 'health_alarm_notify.conf'
+  notify:
+    - "Restart NetData"
+
+- name: "Patch Startup Script"
+  lineinfile:
+    dest: '/etc/init.d/netdata'
+    regexp: 'killproc -p \$\{PIDFILE\} \$DAEMON_PATH/\$DAEMON'
+    line: '        killproc -p ${PIDFILE} $DAEMON_PATH/$DAEMON && sleep 1'
+  when: ansible_lsb.major_release == '12'
+
+- name: "Check if KSM is available"
+  stat: path='/sys/kernel/mm/ksm'
+  register: ksm
+
+# Note: copy module doesn't work here because parent directory /sys
+# is not writable, not even by root
+- name: "Configure KSM"
+  shell: echo {{ item.value }} >/sys/kernel/mm/ksm/{{ item.file }}
+  with_items:
+    - file: 'run'
+      value: '1'
+    - file: 'sleep_millisecs'
+      value: '1000'
+  when: ksm.stat.exists
+  notify:
+    - "Restart NetData"
diff --git a/tasks/haproxy.yml b/tasks/haproxy.yml
new file mode 100644
index 0000000000000000000000000000000000000000..fd68345c33b52c08297bec867539b28a97f36d03
--- /dev/null
+++ b/tasks/haproxy.yml
@@ -0,0 +1,16 @@
+---
+# file: roles/netdata/tasks/haproxy.yml
+
+- name: "Add NetData User to HaProxy Group"
+  user:
+    name: 'netdata'
+    groups: 'haproxy'
+    append: yes
+
+- name: "Configure HaProxy Plugin"
+  copy:
+    src: 'haproxy.conf'
+    dest: '/etc/netdata/python.d/haproxy.conf'
+    owner: 'netdata'
+    group: 'netdata'
+    mode: '660'
diff --git a/tasks/main.yml b/tasks/main.yml
index 97fc332a1c20e4409f7ada62ac2b357e5fd770b5..96b543f24664366233c96e36369cfb2cc0087d6c 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -7,168 +7,24 @@
 
 - block:
 
-  - name: "Install required packages"
-    apt:
-      pkg={{ item }}
-      state=installed
-      update_cache=yes
-    with_items:
-      - zlib1g-dev
-      - gcc
-      - make
-      - git
-      - autoconf
-      - autogen
-      - automake
-      - pkg-config
-      - uuid-dev
-      - python-dev
-      - python-yaml
-      #FireQOS available from 15.04
-      #- firehol
-
-  - name: "Remove existing components"
-    file:
-      path: '{{ item }}'
-      state: 'absent'
-    with_items:
-      - '/opt/netdata'
-      - '/etc/netdata'
-      - '/etc/init.d/netdata'
-      - '/etc/logrotate.d/netdata'
-    when: netdata_force_reset
-
-  - name: "Ensure Directory"
-    file:
-      path='/etc/netdata/python.d'
-      state='directory'
+  - include: prepare.yml
 
   - include: install.yml
 
-  - name: "Add User to Admins"
-    user:
-      name: 'netdata'
-      groups: 'adm'
-      append: yes
-
-  - name: "Configure Registry"
-    ini_file:
-      dest='/etc/netdata/netdata.conf'
-      create=yes
-      section='registry'
-      option='{{ item.option }}'
-      value='{{ item.value }}'
-    with_items:
-      - option: 'enabled'
-        value: '{{ (netdata_registry|default("pmon1") == inventory_hostname)|ternary("yes", "no") }}'
-      - option: 'registry to announce'
-        value: 'http://{{ netdata_registry|default("pmon1") }}:19999'
-    notify:
-      - "Restart NetData"
-
-  - name: "Configure NetData"
-    template:
-      src='{{ item }}'
-      dest='/etc/netdata/{{ item }}'
-      owner='root'
-      group='root'
-      mode=644
-      backup=yes
-    with_items:
-      - 'health_alarm_notify.conf'
-    notify:
-      - "Restart NetData"
-
-  - name: "Patch Startup Script"
-    lineinfile:
-      dest: '/etc/init.d/netdata'
-      regexp: 'killproc -p \$\{PIDFILE\} \$DAEMON_PATH/\$DAEMON'
-      line: '        killproc -p ${PIDFILE} $DAEMON_PATH/$DAEMON && sleep 1'
-    when: ansible_lsb.major_release == '12'
-
-
-  - block:
-
-    - name: "Add NetData User to Varnish Group"
-      user:
-        name: 'netdata'
-        groups: 'varnish'
-        append: yes
-
-    when: groups['varnishserver'] is defined and inventory_hostname in groups['varnishserver']
-
-  - block:
-
-    - name: "Add NetData User to HaProxy Group"
-      user:
-        name: 'netdata'
-        groups: 'haproxy'
-        append: yes
-
-    - name: "Configure HaProxy Plugin"
-      copy:
-        src: 'haproxy.conf'
-        dest: '/etc/netdata/python.d/haproxy.conf'
-        owner: 'netdata'
-        group: 'netdata'
-        mode: '660'
-
-    when: groups['proxyserver'] is defined and inventory_hostname in groups['proxyserver']
-
-  - block:
-
-    - name: "Enable Apache Status Module"
-      apache2_module:
-        name=status
-        state=present
-      notify: "Restart Apache"
-
-    - name: "Apache Status Site"
-      template:
-        src=apache.conf
-        dest=/etc/apache2/sites-available/status{{ apache_conf_ext|default('.conf') }}
-        owner=root
-        group=root
-        mode=0644
-      notify: "Restart Apache"
-
-    - name: "Enable Apache Status Site"
-      command: a2ensite status creates=/etc/apache2/sites-enabled/status{{ apache_conf_ext|default('.conf') }}
-      notify: "Restart Apache"
+  - include: configure.yml
 
+  - include: apache.yml
     when: groups['webserver'] is defined and inventory_hostname in groups['webserver']
 
-  - name: "Configure Plugin: MySQL"
-    replace:
-      dest: '/etc/netdata/python.d/mysql.conf'
-      regexp: '#[\s]*pass[\s]*:[\s]*'''''
-      replace: 'pass     : ''{{ mysql_root_password|default("root") }}'''
-    notify:
-      - "Restart NetData"
+  - include: haproxy.yml
+    when: groups['proxyserver'] is defined and inventory_hostname in groups['proxyserver']
 
-  - name: "Configure Alert: Softnet"
-    replace:
-      dest: '/etc/netdata/health.d/softnet.conf'
-      regexp: 'warn: \$this > \(\(\$status >= \$WARNING\)  \? \(0\) : \(10\)\)'
-      replace: 'warn: $this > (($status >= $WARNING)  ? (0) : (50))'
-    notify:
-      - "Restart NetData"
+  - include: mysql.yml
+    when: groups['dbserver-mysql'] is defined and inventory_hostname in groups['dbserver-mysql']
 
-  - name: "Check if KSM is available"
-    stat: path='/sys/kernel/mm/ksm'
-    register: ksm
+  - include: softnet.yml
 
-  # Note: copy module doesn't work here because parent directory /sys
-  # is not writable, not even by root
-  - name: "Configure KSM"
-    shell: echo {{ item.value }} >/sys/kernel/mm/ksm/{{ item.file }}
-    with_items:
-      - file: 'run'
-        value: '1'
-      - file: 'sleep_millisecs'
-        value: '1000'
-    when: ksm.stat.exists
-    notify:
-      - "Restart NetData"
+  - include: varnish.yml
+    when: groups['varnishserver'] is defined and inventory_hostname in groups['varnishserver']
 
   when: '"netdata" not in excluded_roles'
diff --git a/tasks/mysql.yml b/tasks/mysql.yml
new file mode 100644
index 0000000000000000000000000000000000000000..fd40d73db3b88cf8851bb1641f8184584e74f006
--- /dev/null
+++ b/tasks/mysql.yml
@@ -0,0 +1,10 @@
+---
+# file: roles/netdata/tasks/mysql.yml
+
+- name: "Configure Plugin: MySQL"
+  replace:
+    dest: '/etc/netdata/python.d/mysql.conf'
+    regexp: '#[\s]*pass[\s]*:[\s]*'''''
+    replace: 'pass     : ''{{ mysql_root_password|default("root") }}'''
+  notify:
+    - "Restart NetData"
diff --git a/tasks/prepare.yml b/tasks/prepare.yml
new file mode 100644
index 0000000000000000000000000000000000000000..607f3f5070113241c46ca03327cc0831c47a61b4
--- /dev/null
+++ b/tasks/prepare.yml
@@ -0,0 +1,36 @@
+---
+# file: roles/netdata/tasks/prepare.yml
+
+- name: "Install required packages"
+  apt:
+    pkg: '{{ item }}'
+    state: 'installed'
+    update_cache: yes
+  with_items:
+    - 'zlib1g-dev'
+    - 'gcc'
+    - 'make'
+    - 'git'
+    - 'autoconf'
+    - 'autogen'
+    - 'automake'
+    - 'pkg-config'
+    - 'uuid-dev'
+    - 'python-dev'
+    - 'python-yaml'
+
+- name: "Remove existing components"
+  file:
+    path: '{{ item }}'
+    state: 'absent'
+  with_items:
+    - '/opt/netdata'
+    - '/etc/netdata'
+    - '/etc/init.d/netdata'
+    - '/etc/logrotate.d/netdata'
+  when: netdata_force_reset
+
+- name: "Ensure Directory"
+  file:
+    path: '/etc/netdata/python.d'
+    state: 'directory'
diff --git a/tasks/softnet.yml b/tasks/softnet.yml
new file mode 100644
index 0000000000000000000000000000000000000000..3fe4f6a62845e183ab12e7f59034282843d80f6d
--- /dev/null
+++ b/tasks/softnet.yml
@@ -0,0 +1,10 @@
+---
+# file: roles/netdata/tasks/softnet.yml
+
+- name: "Configure Alert: Softnet"
+  replace:
+    dest: '/etc/netdata/health.d/softnet.conf'
+    regexp: 'warn: \$this > \(\(\$status >= \$WARNING\)  \? \(0\) : \(10\)\)'
+    replace: 'warn: $this > (($status >= $WARNING)  ? (0) : (50))'
+  notify:
+    - "Restart NetData"
diff --git a/tasks/varnish.yml b/tasks/varnish.yml
new file mode 100644
index 0000000000000000000000000000000000000000..e8ed255d894fdfcbd20028f40f88d11183c5e95c
--- /dev/null
+++ b/tasks/varnish.yml
@@ -0,0 +1,8 @@
+---
+# file: roles/netdata/tasks/varnish.yml
+
+- name: "Add NetData User to Varnish Group"
+  user:
+    name: 'netdata'
+    groups: 'varnish'
+    append: yes