From b4deb45870fe9ae8bcbbe9278cdf09cf9579ee69 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 8 Dec 2020 16:56:44 +0100 Subject: add role for graphite carbon-cache --- roles/monitoring/graphite/carbon/defaults/main.yml | 24 ++++++++++ roles/monitoring/graphite/carbon/handlers/main.yml | 5 +++ roles/monitoring/graphite/carbon/tasks/main.yml | 51 ++++++++++++++++++++++ .../carbon/templates/storage-schemas.conf.j2 | 11 +++++ 4 files changed, 91 insertions(+) create mode 100644 roles/monitoring/graphite/carbon/defaults/main.yml create mode 100644 roles/monitoring/graphite/carbon/handlers/main.yml create mode 100644 roles/monitoring/graphite/carbon/tasks/main.yml create mode 100644 roles/monitoring/graphite/carbon/templates/storage-schemas.conf.j2 (limited to 'roles/monitoring/graphite') diff --git a/roles/monitoring/graphite/carbon/defaults/main.yml b/roles/monitoring/graphite/carbon/defaults/main.yml new file mode 100644 index 00000000..46734aac --- /dev/null +++ b/roles/monitoring/graphite/carbon/defaults/main.yml @@ -0,0 +1,24 @@ +--- +# graphite_carbon_zfs: + +graphite_carbon_cache_receivers: + line: + interface: 127.0.0.1 + port: 2003 + pickle: + interface: 0.0.0.0 + port: 0 + +graphite_carbon_cache: + interface: 127.0.0.1 + port: 7002 + +graphtie_carbon_storage_schemas: + - name: carbon + options: + pattern: '^carbon\.' + retentions: '60:90d' + - name: default_1min_for_1day + options: + pattern: '.*' + retentions: '60s:1d' diff --git a/roles/monitoring/graphite/carbon/handlers/main.yml b/roles/monitoring/graphite/carbon/handlers/main.yml new file mode 100644 index 00000000..ecbeef5f --- /dev/null +++ b/roles/monitoring/graphite/carbon/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: restart carbon-cache + service: + name: carbon-cache + state: restarted diff --git a/roles/monitoring/graphite/carbon/tasks/main.yml b/roles/monitoring/graphite/carbon/tasks/main.yml new file mode 100644 index 00000000..52ee20c9 --- /dev/null +++ b/roles/monitoring/graphite/carbon/tasks/main.yml @@ -0,0 +1,51 @@ +--- +## TODO: create zfs volume depending on being graphite_carbon_zfs defined + +- name: instsall apt packages + apt: + name: graphite-carbon + state: present + +- name: configure carbon-cache receiver interfaces + loop: "{{ graphite_carbon_cache_receivers | dict2items }}" + loop_control: + label: "{{ item.key }} = {{ item.value.interface }}" + ini_file: + path: /etc/carbon/carbon.conf + section: cache + option: "{{ item.key | upper }}_RECEIVER_INTERFACE" + value: "{{ item.value.interface }}" + notify: restart carbon-cache + +- name: configure carbon-cache receiver ports + loop: "{{ graphite_carbon_cache_receivers | dict2items }}" + loop_control: + label: "{{ item.key }} = {{ item.value.port }}" + ini_file: + path: /etc/carbon/carbon.conf + section: cache + option: "{{ item.key | upper }}_RECEIVER_PORT" + value: "{{ item.value.port }}" + notify: restart carbon-cache + +- name: set carbon-cache query interface + ini_file: + path: /etc/carbon/carbon.conf + section: cache + option: CACHE_QUERY_INTERFACE + value: "{{ graphite_carbon_cache.interface }}" + notify: restart carbon-cache + +- name: set carbon-cache query port + ini_file: + path: /etc/carbon/carbon.conf + section: cache + option: CACHE_QUERY_PORT + value: "{{ graphite_carbon_cache.port }}" + notify: restart carbon-cache + +- name: configure storage schemas + template: + src: storage-schemas.conf.j2 + dest: /etc/carbon/storage-schemas.conf + notify: restart carbon-cache diff --git a/roles/monitoring/graphite/carbon/templates/storage-schemas.conf.j2 b/roles/monitoring/graphite/carbon/templates/storage-schemas.conf.j2 new file mode 100644 index 00000000..afa0f5eb --- /dev/null +++ b/roles/monitoring/graphite/carbon/templates/storage-schemas.conf.j2 @@ -0,0 +1,11 @@ +# {{ ansible_managed }} +# +# Schema definitions for Whisper files. Entries are scanned in order, +# and first match wins. This file is scanned for changes every 60 seconds. +{% for schema in graphtie_carbon_storage_schemas %} + +[{{ schema.name }}] +{% for name,value in schema.options.items() | sort(attribute='0') %} +{{ name }} = {{ value }} +{% endfor %} +{% endfor %} -- cgit v1.2.3