diff --git a/tasks/collectd_agent.yml b/tasks/collectd_agent.yml index 4de14b8a96689bda30f27ba8259733f63306058b..31eb7fa7fec5cc81e56ca8b3a5dbfe4f5c1afe5d 100644 --- a/tasks/collectd_agent.yml +++ b/tasks/collectd_agent.yml @@ -23,16 +23,37 @@ file: path: /etc/collectd/collectd.conf.d/ owner: root - group: root + group: '{{ root_group[ansible_os_family] }}' mode: '0755' state: directory -- name: Base configuration +- name: Gather Collectd facts + collectd_facts: + +- name: Base Collectd configuration copy: src: collectd.conf dest: /etc/collectd/collectd.conf owner: root - group: root + group: '{{ root_group[ansible_os_family] }}' + mode: '0644' + notify: + - Restart Collectd + +- name: Default Collectd configuration + with_fileglob: + - template/collectd/*.j2 + template: + src: '{{ item }}' + dest: /etc/collectd/collectd.conf.d/ + owner: root + group: '{{ root_group[ansible_os_family] }}' mode: '0644' notify: - Restart Collectd + +- name: Enabled Collectd service + service: + name: collectd + state: started + enabled: yes diff --git a/templates/collectd/write.conf.j2 b/templates/collectd/write.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..a232ac8f54b447ac9c92676ca65449aef528b587 --- /dev/null +++ b/templates/collectd/write.conf.j2 @@ -0,0 +1,9 @@ +{% if collectd_collectd_server is defined %} + +{% elif collectd_riemann_server is defined and (collectd['major'] > 5 or +(collectd['major'] == 5 and collectd['minor'] >= 3)) %} + +{% elif collectd_graphite_server is defined and (collectd['major'] > 5 or +(collectd['major'] == 5 and collectd['minor'] >= 1)) %} + +{% endif %}