From 0c29fdfc8f0736eb506c74eacdf6c43554ae51fd Mon Sep 17 00:00:00 2001 From: Kuo-tung Kao Date: Fri, 23 Dec 2016 16:39:43 +0800 Subject: [PATCH] provide a universal collectd template The default config for collectd is very different between OS distro. For example, in ubuntu, collectd read config from "/etc/collect/collect.conf.d". But in centos, collectd read config from "/etc/collect.d" We need to provide a universal collectd template to make it convenient for different distros. Change-Id: Ib82fcbb923cb32dbafce04e1e639a400d59a4365 Closes-Bug: #1652246 --- ansible/roles/collectd/tasks/config.yml | 10 ++++++++++ ansible/roles/collectd/tasks/start.yml | 1 - .../roles/collectd/templates/collectd.conf.j2 | 6 ++++++ .../roles/collectd/templates/collectd.json.j2 | 19 ++++++++++++++++++- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 ansible/roles/collectd/templates/collectd.conf.j2 diff --git a/ansible/roles/collectd/tasks/config.yml b/ansible/roles/collectd/tasks/config.yml index af9417b7e0..2470cd3a5b 100644 --- a/ansible/roles/collectd/tasks/config.yml +++ b/ansible/roles/collectd/tasks/config.yml @@ -21,3 +21,13 @@ dest: "{{ node_config_directory }}/{{ item }}/config.json" with_items: - "collectd" + +- name: Copying over collectd.conf for services + template: + src: "{{ item }}" + dest: "{{ node_config_directory }}/collectd/collectd.conf" + with_first_found: + - "{{ node_custom_config }}/collectd/{{ inventory_hostname }}/collectd.conf" + - "{{ node_custom_config }}/collectd/collectd.conf" + - "{{ node_custom_config }}/collectd.conf" + - "collectd.conf.j2" diff --git a/ansible/roles/collectd/tasks/start.yml b/ansible/roles/collectd/tasks/start.yml index 8675c00eb8..f73067fe03 100644 --- a/ansible/roles/collectd/tasks/start.yml +++ b/ansible/roles/collectd/tasks/start.yml @@ -8,7 +8,6 @@ privileged: True volumes: - "{{ node_config_directory }}/collectd/:{{ container_config_directory }}/:ro" - - "{{node_config_directory }}/collectd/collectd.conf.d/:/etc/collectd/collectd.conf.d/" - "/etc/localtime:/etc/localtime:ro" - "kolla_logs:/var/log/kolla/" - "/sys/:/sys/:ro" diff --git a/ansible/roles/collectd/templates/collectd.conf.j2 b/ansible/roles/collectd/templates/collectd.conf.j2 new file mode 100644 index 0000000000..6fdc5a333b --- /dev/null +++ b/ansible/roles/collectd/templates/collectd.conf.j2 @@ -0,0 +1,6 @@ +FQDNLookup false +LoadPlugin syslog +LoadPlugin cpu +LoadPlugin interface +LoadPlugin load +LoadPlugin memory diff --git a/ansible/roles/collectd/templates/collectd.json.j2 b/ansible/roles/collectd/templates/collectd.json.j2 index 7d70179270..2599ca6db7 100644 --- a/ansible/roles/collectd/templates/collectd.json.j2 +++ b/ansible/roles/collectd/templates/collectd.json.j2 @@ -1,3 +1,20 @@ +{% set collectd_config = '/etc/collectd/collectd.conf' if kolla_base_distro in ['ubuntu', 'debian'] else '/etc/collectd.conf' %} + { - "command": "/usr/sbin/collectd -f" + "command": "/usr/sbin/collectd -f -C {{ collectd_config }}", + "config_files": [ + { + "source": "{{ container_config_directory }}/collectd.conf", + "dest": "{{ collectd_config }}", + "owner": "collectd", + "perm": "0600" + } + ], + "permissions": [ + { + "path": "/var/log/kolla/collectd", + "owner": "collectd:collectd", + "recurse": true + } + ] }