]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
ceph-collectd: Support Ubuntu
authorZack Cerza <zack@redhat.com>
Wed, 12 Jul 2017 16:14:50 +0000 (10:14 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 12 Jul 2017 22:53:56 +0000 (16:53 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
ansible/roles/ceph-collectd/defaults/main.yml
ansible/roles/ceph-collectd/tasks/configure_collectd.yml
ansible/roles/ceph-collectd/tasks/install_collectd_plugins.yml
ansible/roles/ceph-collectd/tasks/install_packages.yml
ansible/roles/ceph-collectd/tasks/main.yml
ansible/roles/ceph-collectd/tasks/setup_repos.yml
ansible/roles/ceph-collectd/templates/collectd.list [new file with mode: 0644]

index 55bc515a54ccebb49a6bf3e9b4f586a6236b8d35..b3652a89a0d2527d26e5591e83c5fdba183ccab6 100644 (file)
@@ -3,3 +3,23 @@ containerized_deployment: false
 cluster: ceph
 use_epel: false
 devel_mode: true
+collector_dependencies:
+  yum:
+    # For the json python module
+    - python-libs
+    # For the rados python module
+    - python-rados
+    # For the ceph_daemon python module
+    - ceph-common
+    # For semodule
+    - make
+    - libsemanage-python
+    - policycoreutils-python
+    - selinux-policy-devel
+  apt:
+    # For the json module, via libpython2.7-stdlib
+    - python2.7
+    # For the rados python module
+    - python-rados
+    # For the ceph_daemon python module
+    - ceph-common
index 711e502d662b5f269b3df3d946a13531cfb0e929..d4df13263be9af6677a069b28982228e6200b7c4 100644 (file)
@@ -1,26 +1,55 @@
 ---
+- name: Set collectd_conf
+  set_fact:
+    collectd_conf: "/etc/{{ 'collectd/' if ansible_pkg_mgr == 'apt' else '' }}collectd.conf"
+
+- name: Set collectd_conf_d
+  set_fact:
+    collectd_conf_d: "/etc/collectd{{ '/collectd.conf' if ansible_pkg_mgr == 'apt' else '' }}.d"
+
 - name: Ship collectd.conf
   copy:
     src: files/etc/collectd.conf
-    dest: /etc/
+    dest: "{{ collectd_conf }}"
+  notify: Restart collectd
+
+- name: Set PluginDir in collectd.conf
+  replace:
+    dest: "{{ collectd_conf }}"
+    regexp: 'PluginDir ".*"'
+    replace: 'PluginDir "{{ collectd_dir }}"'
   notify: Restart collectd
 
-- name: Ship /etc/collectd.d
+- name: Set Include path in collectd.conf
+  replace:
+    dest: "{{ collectd_conf }}"
+    regexp: 'Include ".*"'
+    replace: 'Include "{{ collectd_conf_d }}/*.conf"'
+  notify: Restart collectd
+
+- name: Ship /etc/collectd.d or /etc/collectd/collectd.conf.d
   copy:
-    src: files/etc/collectd.d
-    dest: /etc/
+    src: files/etc/collectd.d/
+    dest: "{{ collectd_conf_d }}"
   notify: Restart collectd
 
 - name: Set hostname in write_graphite.conf
   replace:
-    dest: "/etc/collectd.d/write_graphite.conf"
+    dest: "{{ collectd_conf_d }}/write_graphite.conf"
     regexp: 'Host ".*"'
     replace: "Host \"{{ groups['ceph-grafana'][0] }}\""
   notify: Restart collectd
 
 - name: Set cluster name in cephmetrics.conf
   replace:
-    dest: /etc/collectd.d/cephmetrics.conf
+    dest: "{{ collectd_conf_d }}/cephmetrics.conf"
     regexp: 'ClusterName ".*"'
     replace: 'ClusterName "{{ cluster }}"'
   notify: Restart collectd
+
+- name: Set ModulePath in cephmetrics.conf
+  replace:
+    dest: "{{ collectd_conf_d }}/cephmetrics.conf"
+    regexp: 'ModulePath ".*"'
+    replace: 'ModulePath "{{ collectd_cephmetrics_dir }}"'
+  notify: Restart collectd
index 34f74895a00441d0e973748b4268f686ba81da13..5af7367e51e62df089679f49dfe7b8234865cdec 100644 (file)
@@ -1,21 +1,25 @@
 ---
 - name: Set collectd_dir
   set_fact:
-    collectd_dir: /usr/lib64/collectd/cephmetrics
+    collectd_dir: "/usr/lib{{ '64' if ansible_pkg_mgr == 'yum' else '' }}/collectd"
+
+- name: Set collectd_cephmetrics_dir
+  set_fact:
+    collectd_cephmetrics_dir: "{{ collectd_dir }}/cephmetrics"
 
 - name: Create collectors directory
   file:
-    name: "{{ collectd_dir }}/collectors"
+    name: "{{ collectd_cephmetrics_dir }}/collectors"
     state: directory
 
 - name: Ship collector plugins
   copy:
     src: files/collectors/
-    dest: "{{ collectd_dir }}/collectors"
+    dest: "{{ collectd_cephmetrics_dir }}/collectors"
   notify: Restart collectd
 
 - name: Ship cephmetrics.py
   copy:
     src: files/cephmetrics.py
-    dest: "{{ collectd_dir }}"
+    dest: "{{ collectd_cephmetrics_dir }}"
   notify: Restart collectd
index f3cacf25f22cdb13286a5147c8c40eb759c819c1..b290ac3b8e552534afd20ad84e9a80c6402d9377 100644 (file)
   package:
     name: "{{ item }}"
     state: latest
-  with_items:
-    # For the json python module
-    - python-libs
-    # For the rados python module
-    - python-rados
-    # For the ceph_daemon python module
-    - ceph-common
-    # For semodule
-    - make
-    - libsemanage-python
-    - policycoreutils-python
-    - selinux-policy-devel
+  with_items: "{{ collector_dependencies[ansible_pkg_mgr] }}"
   when:
-    - ansible_pkg_mgr == "yum"
     - devel_mode
   notify: Restart collectd
index 91741ed2711bd21d6ffab8321e5bba5397cdf32e..4ccf3df7c50d5f500d79547de977826e2eada787 100644 (file)
@@ -26,6 +26,7 @@
 - include: selinux.yml
   when:
    - not containerized_deployment
+   - ansible_pkg_mgr == "yum"
    - ansible_selinux.status is defined
    - ansible_selinux.status == 'enabled'
   tags:
index 48f9ce03eeb00650d4b0badf2e5ae20c47cb67fa..226d391fab4d1dd519e29e2b4f86aceceb239616 100644 (file)
@@ -7,6 +7,30 @@
     - ansible_pkg_mgr == "yum"
     - devel_mode
 
+- name: Add collectd repo
+  template:
+    src: collectd.list
+    dest: /etc/apt/sources.list.d/collectd.list
+  when:
+    - ansible_pkg_mgr == 'apt'
+    - devel_mode
+
+- name: Add collectd.org GPG key to apt
+  apt_key:
+    id: 3994D24FB8543576
+    state: present
+    keyserver: ha.pool.sks-keyservers.net
+  when:
+    - ansible_pkg_mgr == 'apt'
+    - devel_mode
+
+- name: Update apt cache
+  apt:
+    update_cache: true
+  when:
+    - ansible_pkg_mgr == 'apt'
+    - devel_mode
+
 - name: Install cephmetrics development repo
   copy:
     src: cephmetrics-devel.repo
diff --git a/ansible/roles/ceph-collectd/templates/collectd.list b/ansible/roles/ceph-collectd/templates/collectd.list
new file mode 100644 (file)
index 0000000..5a12f86
--- /dev/null
@@ -0,0 +1 @@
+deb http://pkg.ci.collectd.org/deb {{ ansible_distribution_release }} collectd-5.7