Add InfluxDB role

This commit is contained in:
Ryan Cavicchioni 2019-12-01 20:40:40 -06:00
parent c13ce7cb4d
commit ccdf6fab93
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
6 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,20 @@
---
influxdb_package_name: influxdb
influxdb_package_state: present
influxdb_service_name: influxdb.service
influxdb_service_state: started
influxdb_service_enabled: yes
influxdb_config:
reporting-disabled: yes
meta:
dir: /var/lib/influxdb/meta
data:
dir: /var/lib/influxdb/data
wal-dir: /var/lib/influxdb/wal
series-id-set-cache-size: 100
index-version: tsi1
query-log-enabled: no
http:
log-enabled: no

View File

@ -0,0 +1,14 @@
---
- name: reload influxdb
service:
name: "{{ influxdb_service_name }}"
state: restarted
when: influxdb_service_enabled
- name: influxdb daemon-reload
systemd:
name: "{{ influxdb_service_name }}"
daemon_reload: yes
state: restarted
# vim:ft=yaml.ansible:

View File

@ -0,0 +1,12 @@
---
- name: add influx apt key
apt_key:
url: https://repos.influxdata.com/influxdb.key
state: present
- name: configure apt repository
apt_repository:
repo: "deb https://repos.influxdata.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
filename: influxdb
update_cache: yes
state: present

View File

@ -0,0 +1,44 @@
---
- name: gather os specific variables
include_vars: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- vars
- name: include os specific tasks
include_tasks: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- tasks
- name: install package
package:
name: "{{ influxdb_package_name }}"
state: "{{ influxdb_package_state }}"
- name: configure
template:
src: influxdb.conf.j2
dest: /etc/influxdb/influxdb.conf
owner: root
group: root
mode: 0644
notify: reload influxdb
- name: manage service
service:
name: "{{ influxdb_service_name }}"
state: "{{ influxdb_service_state }}"
enabled: "{{ influxdb_service_enabled }}"

View File

@ -0,0 +1,38 @@
{%- macro toml_scalar(v, seq=False) -%}
{% if v is string %}
"{{ v | quote }}"{% if seq %},{% endif %}
{% elif v is sameas True or v is sameas False %}
{{ v | bool | lower }}{% if seq %},{% endif %}
{% elif v is sameas None %}
""{% if seq %},{% endif %}
{% elif v is number %}
{{ v }}{% if seq %},{% endif %}
{% endif %}
{%- endmacro -%}
{%- macro render_section(config = {}) -%}
{% for k, v in config.items() | default({}) %}
{% if v is mapping %}
[{{ k }}]
{{ render_section(v) }}
{% elif v is string %}
{{ k }} = "{{ v | quote }}"
{% elif v is sameas True or v is sameas False %}
{{ k }} = {{ v | bool | lower }}
{% elif v is sameas None %}
{{ k }} = ""
{% elif v is number %}
{{ k }} = {{ v }}
{% elif v is sequence %}
{{ k }} = [
{% for i in v | default([]) %}
{{ toml_scalar(i, seq=True) }}
{% endfor %}
]
{% endif %}
{% endfor %}
{%- endmacro -%}
# {{ ansible_managed }}
{{ render_section(influxdb_config) }}

View File

@ -0,0 +1 @@
---