Commit fa40478a authored by Ross McDonald's avatar Ross McDonald
Browse files

First commit. Tested base configuration on Ubuntu 14.04.

parents
*#
*~
venv/
.vagrant/
\ No newline at end of file
InfluxDB
========
An Ansible role to install, configure, and manage [InfluxDB](https://github.com/influxdb/influxdb) (a time-series database).
Requirements
------------
Prior knowledge/experience with InfluxDB is highly recommended. Full documentation is available [here](https://influxdb.com/docs/v0.9/introduction/overview.html).
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
No other dependencies are required.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
MIT
Author Information
------------------
Created by [Ross McDonald](https://github.com/rossmcdonald).
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
# config.vm.box = "ubuntu/vivid64"
# config.vm.box = "relativkreativ/centos-7-minimal"
# config.vm.box = "box-cutter/fedora22"
# config.vm.box = "puppetlabs/centos-6.6-64-nocm"
# config.vm.box = "hansode/centos-6.5-x86_64"
BOX_COUNT = 1
(1..BOX_COUNT).each do |machine_id|
config.vm.define "influx#{machine_id}" do |machine|
machine.vm.hostname = "influx#{machine_id}"
# machine.vm.network "private_network", ip: "10.0.3.#{1+machine_id}", virtualbox__intnet: true
machine.vm.network "public_network"
machine.vm.provider "virtualbox" do |v|
v.memory = 512
v.cpus = 1
end
if machine_id == BOX_COUNT
machine.vm.provision "ansible" do |ansible|
# ansible.verbose = 'vvvv'
ansible.limit = 'all'
ansible.playbook = "test.yml"
ansible.sudo = true
ansible.host_key_checking = false
end
end
end
end
end
---
# Channel of InfluxDB to install (stable, unstable, nightly)
install_version: stable
# If multiple servers are specified, whether to create a clustered configuration
# NOTE:
# - Do not attempt to cluster previously-unclustered servers. This can lead to data loss.
# - This will overwrite your /etc/default/influxdb file (though it makes a backup)
# - This will overwrite your /etc/hosts file (though, again, it makes a backup)
cluster_servers: no
# Whether to load sample data (randomly generated integers) into a test database
# NOTE: sample data cannot be loaded if authentication is enabled
load_sample_data: no
sample_database_name: sample_database
sample_measurement_name: random_ints
sample_num_points: 20
---
- name: purge metaid
file: path=/var/opt/influxdb/meta/id state=absent
- name: purge raftdb
file: path=/var/opt/influxdb/meta/raft.db state=absent
- name: purge peers
file: path=/var/opt/influxdb/meta/peers.json state=absent
- name: restart influxdb
service: name=influxdb state=restarted
- name: pause
pause: seconds=3
\ No newline at end of file
---
galaxy_info:
author: Ross McDonald
description: Install and configure InfluxDB, a time-series database
company: InfluxData
license: MIT
min_ansible_version: 1.2
platforms:
- name: EL
versions:
- 6
- 7
- name: Ubuntu
versions:
- trusty
- utopic
- vivid
- name: Debian
versions:
- jessie
- wheezy
categories:
- cloud
- clustering
- database:nosql
- monitoring
dependencies: []
---
- name: Configure hosts file
template: src=etc/hosts.j2 dest=/etc/hosts owner=root group=root mode=0644 backup=yes
- name: Cluster servers
template: src=etc/default/influxdb.j2 dest=/etc/default/influxdb force=yes backup=yes owner=root group=root mode=0644
notify:
- purge metaid
- purge raftdb
- purge peers
- restart influxdb
---
- name: Set templatized InfluxDB configuration
template: src=influxdb.conf.j2 dest=/etc/opt/influxdb/influxdb.conf force=yes backup=yes owner=influxdb group=influxdb mode=0744
- name: Start the InfluxDB service
service: name=influxdb state=started enabled=yes
notify:
- pause
---
- name: Check to see which databases already exist
command: /opt/influxdb/influx -execute 'show databases'
register: db_listing
- name: Create demo database
command: /opt/influxdb/influx -execute 'CREATE DATABASE {{ sample_database_name }}'
when: db_listing.stdout.find("my_sample_db") == -1
- name: Load demo data
uri:
url: http://localhost:8086/write?db={{ sample_database_name }}
method: POST
body: "{{ sample_measurement_name }},host=server_{{ 10 | random }},az=US{{ 5 | random }} value={{ 100 | random }}"
status_code: 204
with_sequence: start=1 end={{ sample_num_points }}
---
- name: Install any necessary dependencies [Debian/Ubuntu]
apt: name={{ item }} state=present update_cache=yes cache_valid_time=3600
with_items:
- python-httplib2
- python-apt
- curl
when: ansible_os_family == "Debian"
- name: Install any necessary dependencies [Debian/Ubuntu]
yum: name={{ item }} state=present
with_items:
- curl
- python-httplib2
when: ansible_os_family == "RedHat"
- name: Import InfluxDB GPG signing key [Debian/Ubuntu]
apt_key: url=https://repos.influxdata.com/influxdb.key state=present
when: ansible_os_family == "Debian"
- name: Add InfluxDB repository [Debian/Ubuntu]
apt_repository: repo='deb https://repos.influxdata.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} {{ install_version }}' state=present
when: ansible_os_family == "Debian"
- name: Add InfluxDB repository file [RHEL/CentOS]
template: src=etc/yum.repos.d/influxdb.repo.j2 dest=/etc/yum.repos.d/influxdb.repo force=yes backup=yes
when: ansible_os_family == "RedHat"
- name: Install InfluxDB packages [Debian/Ubuntu]
apt: name=influxdb state=present
when: ansible_os_family == "Debian"
- name: Install InfluxDB packages [RHEL/CentOS]
yum: name=influxdb state=present
when: ansible_os_family == "RedHat"
---
- include: install.yml
tags: [influxdb, install]
- include: configure.yml
tags: [influxdb, configure]
- include: cluster.yml
tags: [influxdb, cluster]
when: cluster_servers
- include: demo.yml
tags: [influxdb, demo]
when: load_sample_data and http_auth_enabled == "false"
INFLUXD_OPTS="-hostname {{ ansible_hostname }}{% if ansible_hostname[-1:]|int != 1 %} -join {% for host in groups['all']|sort %}{% if hostvars[host]['ansible_hostname'][-1:]|int < ansible_hostname[-1:]|int %}{{ hostvars[host]['ansible_hostname'] }}:{{ meta_port }}{% if not loop.last %},{% endif %}{% endif %}{% endfor %}{% endif %}"
[influxdb]
name = InfluxDB Repository - {{ ansible_distribution }} $releasever
baseurl = https://repos.influxdata.com/{{ ansible_distribution|lower }}/$releasever/$basearch/{{ influxdb_channel }}
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
sslverify = 1
\ No newline at end of file
### Welcome to the InfluxDB configuration file.
# Once every 24 hours InfluxDB will report anonymous data to m.influxdb.com
# The data includes raft id (random 8 bytes), os, arch, version, and metadata.
# We don't track ip addresses of servers reporting. This is only used
# to track the number of instances running and the versions, which
# is very helpful for us.
# Change this option to true to disable reporting.
reporting-disabled = {{ disable_reporting }}
###
### [meta]
###
### Controls the parameters for the Raft consensus group that stores metadata
### about the InfluxDB cluster.
###
[meta]
dir = "{{ meta_dir }}"
hostname = "{{ ansible_hostname }}"
bind-address = ":{{ meta_port }}"
retention-autocreate = {{ meta_retention_autocreate }}
election-timeout = "{{ meta_election_timeout }}"
heartbeat-timeout = "{{ meta_heartbeat_timeout }}"
leader-lease-timeout = "{{ meta_leader_lease_timeout }}"
commit-timeout = "{{ meta_commit_timeout }}"
cluster-tracing = {{ meta_cluster_tracing }}
###
### [data]
###
### Controls where the actual shard data for InfluxDB lives.
###
[data]
dir = "{{ data_dir }}"
# engine = "{{ data_engine }}"
# The following WAL settings are for the b1 storage engine used in 0.9.2. They won't
# apply to any new shards created after upgrading to a version > 0.9.3.
max-wal-size = {{ data_max_wal_size }}
wal-flush-interval = "{{ data_wal_flush_interval }}"
wal-partition-flush-delay = "{{ data_wal_partition_flush_delay }}"
# These are the WAL settings for the storage engine >= 0.9.3
wal-dir = "{{ data_wal_dir }}"
wal-logging-enabled = {{ data_wal_logging_enabled }}
# When a series in the WAL in-memory cache reaches this size in bytes it is marked as ready to
# flush to the index
# wal-ready-series-size = {{ data_wal_ready_series_size }}
# Flush and compact a partition once this ratio of series are over the ready size
# wal-compaction-threshold = {{ data_wal_compaction_threshold }}
# Force a flush and compaction if any series in a partition gets above this size in bytes
# wal-max-series-size = {{ data_wal_max_series_size }}
# Force a flush of all series and full compaction if there have been no writes in this
# amount of time. This is useful for ensuring that shards that are cold for writes don't
# keep a bunch of data cached in memory and in the WAL.
# wal-flush-cold-interval = "{{ data_wal_flush_cold_interval }}"
# Force a partition to flush its largest series if it reaches this approximate size in
# bytes. Remember there are 5 partitions so you'll need at least 5x this amount of memory.
# The more memory you have, the bigger this can be.
# wal-partition-size-threshold = {{ data_wal_partition_size_threshold }}
###
### [cluster]
###
### Controls non-Raft cluster behavior, which generally includes how data is
### shared across shards.
###
[cluster]
shard-writer-timeout = "{{ cluster_shard_writer_timeout }}"
force-remote-mapping = {{ cluster_force_remote_mapping }}
write-timeout = "{{ cluster_write_timeout }}"
shard-mapper-timeout = "{{ cluster_shard_mapper_timeout }}"
###
### [retention]
###
### Controls the enforcement of retention policies for evicting old data.
###
[retention]
enabled = {{ retention_enabled }}
check-interval = "{{ retention_check_interval }}"
[shard-precreation]
enabled = {{ shard_pre_enabled }}
check-interval = "{{ shard_pre_check_interval }}"
advance-period = "{{ shard_pre_advance_period }}"
###
### [admin]
###
### Controls the availability of the built-in, web-based admin interface.
###
[admin]
enabled = {{ admin_enabled }}
bind-address = ":{{ admin_port }}"
https-enabled = {{ admin_https_enabled }}
https-certificate = "{{ admin_https_certificate }}"
[monitor]
store-enabled = {{ monitor_store_enabled }}
store-database = "{{ monitor_store_database }}"
store-interval = "{{ monitor_store_interval }}"
###
### [http]
###
### Controls how the HTTP endpoints are configured. These are the primary
### mechanism for getting data into and out of InfluxDB.
###
[http]
enabled = {{ http_enabled }}
bind-address = ":{{ http_port }}"
auth-enabled = {{ http_auth_enabled }}
log-enabled = {{ http_log_enabled }}
write-tracing = {{ http_write_tracing }}
pprof-enabled = {{ http_pprof_enabled }}
https-enabled = {{ http_https_enabled }}
https-certificate = "{{ http_https_certificate }}"
###
### [[graphite]]
###
### Controls one or many listeners for Graphite data.
###
[[graphite]]
enabled = false
# bind-address = ":2003"
# protocol = "tcp"
# consistency-level = "one"
# name-separator = "."
# name-position = "last"
# These next lines control how batching works. You should have this enabled
# otherwise you could get dropped metrics or poor performance. Batching
# will buffer points in memory if you have many coming in.
# batch-size = 1000 # will flush if this many points get buffered
# batch-pending = 5 # number of batches that may be pending in memory
# batch-timeout = "1s" # will flush at least this often even if we haven't hit buffer limit
## "name-schema" configures tag names for parsing the metric name from graphite protocol;
## separated by `name-separator`.
## The "measurement" tag is special and the corresponding field will become
## the name of the metric.
## e.g. "type.host.measurement.device" will parse "server.localhost.cpu.cpu0" as
## {
## measurement: "cpu",
## tags: {
## "type": "server",
## "host": "localhost,
## "device": "cpu0"
## }
## }
# name-schema = "type.host.measurement.device"
## If set to true, when the input metric name has more fields than `name-schema` specified,
## the extra fields will be ignored.
## Otherwise an error will be logged and the metric rejected.
# ignore-unnamed = true
###
### [collectd]
###
### Controls the listener for collectd data.
###
[collectd]
enabled = false
# bind-address = ":25826"
# database = "collectd"
# retention-policy = ""
# batch-size = 1000
# batch-pending = 5
# batch-timeout = "10s"
# typesdb = "/usr/share/collectd/types.db"
###
### [opentsdb]
###
### Controls the listener for OpenTSDB data.
###
[opentsdb]
enabled = false
# bind-address = ":4242"
# database = "opentsdb"
# retention-policy = ""
# consistency-level = "one"
# tls-enabled = false
# certificate = "/etc/ssl/influxdb.pem"
# batch-size = 1000
# batch-pending = 5
# batch-timeout = "1s"
###
### [udp]
###
### Controls the listener for InfluxDB line protocol data via UDP.
###
# TODO: Including the udp table prevents service from starting (even if disabled)
# [udp]
# enabled = false
# bind-address = ""
# database = ""
# batch-size = 0
# batch-timeout = "0"
###
### [monitoring]
###
[monitoring]
enabled = {{ monitoring_enabled }}
write-interval = "{{ monitoring_write_interval }}"
###
### [continuous_queries]
###
### Controls how continuous queries are run within InfluxDB.
###
[continuous_queries]
log-enabled = {{ cq_log_enabled }}
enabled = {{ cq_enabled }}
recompute-previous-n = {{ cq_recompute_previous_n }}
recompute-no-older-than = "{{ cq_recompute_no_older_than }}"
compute-runs-per-interval = {{ cq_compute_runs_per_interval }}
compute-no-more-than = "{{ cq_compute_no_more_than }}"
###
### [hinted-handoff]
###
### Controls the hinted handoff feature, which allows nodes to temporarily
### store queued data when one node of a cluster is down for a short period
### of time.
###
[hinted-handoff]
enabled = {{ hh_enabled }}
dir = "{{ hh_dir }}"
max-size = {{ hh_max_size }}
max-age = "{{ hh_max_age }}"
retry-rate-limit = {{ hh_retry_rate_limit }}
retry-interval = "{{ hh_retry_interval }}"
- hosts: all
vars_files:
- defaults/main.yml
- vars/main.yml
tasks:
- include: tasks/main.yml
handlers:
- include: handlers/main.yml
---
# NOTE: Since Ansible uses Python on the backend, all boolean values are capitalized when being
# rendered (which is not valid TOML). To get around this, make sure you quote any boolean values
# (true -> "true") to ensure correct formatting (for template variables).
# InfluxDB configuration file options
disable_reporting: "false"
## Meta Settings
meta_dir: /var/opt/influxdb/meta
meta_hostname: localhost
meta_port: 8088
meta_retention_autocreate: "true"
meta_election_timeout: 1s
meta_heartbeat_timeout: 1s
meta_leader_lease_timeout: 500ms
meta_commit_timeout: 50ms
meta_cluster_tracing: "false"
## Data Settings
data_dir: /var/opt/influxdb/data
data_engine: "tsm1"
data_max_wal_size: 104857600
data_wal_flush_interval: 10m0s
data_wal_partition_flush_delay: 2s
data_wal_dir: /var/opt/influxdb/wal
data_wal_logging_enabled: "true"
data_wal_ready_series_size: 30720
data_wal_compaction_threshold: 0.5
data_wal_max_series_size: 1048576
data_wal_flush_cold_interval: 5s
data_wal_partition_size_threshold: 20971520
## Cluster Settings
cluster_shard_writer_timeout: 5s
cluster_force_remote_mapping: "false"
cluster_write_timeout: 5s
cluster_shard_mapper_timeout: 5s
## Retention Settings
retention_enabled: "true"
retention_check_interval: 30m0s
# Shard-Precreation Settings
shard_pre_enabled: "true"
shard_pre_check_interval: 10m0s
shard_pre_advance_period: 30m0s
## Admin Settings
admin_enabled: "true"
admin_port: 8083
admin_https_enabled: "false"
admin_https_certificate: /etc/ssl/influxdb.pem
## Monitor Settings (not to be confused with 'Monitoring')
monitor_store_enabled: "true"
monitor_store_database: _internal
monitor_store_interval: 10s
## HTTP Settings
http_enabled: "true"
http_port: 8086
http_auth_enabled: "false"
http_log_enabled: "true"
http_write_tracing: "true"
http_pprof_enabled: "false"
http_https_enabled: "false"
http_https_certificate: /etc/ssl/influxdb.pem
## TODO Graphite Settings
## TODO Collectd Settings
## TODO OpenTSDB Settings
## TODO UDP Settings
## Monitoring Settings
monitoring_enabled: "true"
monitoring_write_interval: 24h
## Continuous Queries Settings
cq_log_enabled: "true"
cq_enabled: "true"
cq_recompute_previous_n: 2
cq_recompute_no_older_than: 10m
cq_compute_runs_per_interval: 10
cq_compute_no_more_than: 2m
## Hinted-Handoff Settings
hh_enabled: "true"
hh_dir: /var/opt/influxdb/hh
hh_max_size: 1073741824
hh_max_age: 168h
hh_retry_rate_limit: 0
hh_retry_interval: 1s
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment