Skip to content
This repository has been archived by the owner on Apr 4, 2018. It is now read-only.

[#98091344] Create Influxdb ansible role #1

Merged
merged 9 commits into from
Jul 8, 2015
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vagrant
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2015 Crown Copyright (Government Digital Service)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
# ansible-playbook-influxdb

Ansible role for deploying the [Influxfb](https://github.com/influxdb/influxdb) time series database

### Requirements

The following ansible variables are used by this role - the default values are shown alongside.

```
* influxdb_version: latest # The version of `influxdb` to install.
* influxdb_admin_user: root # The administrator account for `influx_db`
* influxdb_admin_password: root # the password for `influxdb_admin_user` account.
* influxdb_database: testdb # Role will create a database of this name owned by
influxdb_user.
* influxdb_user: someuser # A non-privliged database user account for `influxdb_database`.
* influxdb_password: somepassword # the password for `influxdb_user` account.
* influxdb_http_auth_enabled: false # to disable or `true` to enable http authentication.
```

You will want to override these role variables within your playbooks.

### Usage

```
- hosts: "{{ hosts_prefix }}-*"
sudo: yes
roles:
- influxdb
```
26 changes: 26 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

MEMORY_DEFAULT = 512

Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.hostname = "influx"

config.vm.provider :virtualbox do |v|
v.memory = MEMORY_DEFAULT
end

config.vm.provider :vmware_fusion do |v|
v.vmx["memsize"] = MEMORY_DEFAULT
end

config.vm.network "forwarded_port", guest: 8083, host: 8083, auto_correct: true
config.vm.network "forwarded_port", guest: 8086, host: 8086, auto_correct: true
config.vm.network "forwarded_port", guest: 8088, host: 8088, auto_correct: true

config.vm.provision :shell, inline: "apt-get purge -qq -y --auto-remove chef puppet"
config.vm.provision :ansible do |ansible|
ansible.playbook = "site.yml"
end
end
9 changes: 9 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# defaults file for ansible-playbook-influxdb
#
influxdb_version: latest
influxdb_admin_user: root
influxdb_admin_password: root
influxdb_database: testdb
influxdb_user: someuser
influxdb_password: somepassword
2 changes: 2 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# handlers file for ansible-playbook-influxdb
15 changes: 15 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
galaxy_info:
author: Government Digital Service
company: Government Digital Service, Cabinet Office
description: Installs and setup Influxdb time series database
license: MIT
min_ansible_version: 1.3
platforms:
- name: Ubuntu
versions:
- all
categories:
- database
- database:nosql
dependencies: []
5 changes: 5 additions & 0 deletions site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: all
sudo: yes
roles:
- .
33 changes: 33 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# tasks file for ansible-playbook-influxdb
#

- name: fetch influxdb installation package
get_url: url=http://s3.amazonaws.com/influxdb/influxdb_{{ influxdb_version }}_amd64.deb dest=/tmp/influxdb_{{ influxdb_version }}_amd64.deb mode=0440

- name: install influxdb package
command: dpkg --skip-same-version -i /tmp/influxdb_{{ influxdb_version }}_amd64.deb
register: dpkg_result
changed_when: "dpkg_result.stdout.startswith('Selecting')"

- name: configure influxdb service
template: src=influxdb.conf.j2 dest=/etc/opt/influxdb/influxdb.conf owner=root group=root mode=0644

- name: start influxdb service and ensure that it is enabled
service: name=influxdb enabled=yes state=started

- name: waiting for influxdb service to become available
wait_for: port=8086 timeout=60

- name: create admin user for all influxdb databases
shell: "curl -G http://localhost:8086/query --data-urlencode \"u={{ influxdb_admin_user }}\" --data-urlencode \"p={{ influxdb_admin_password }}\" --data-urlencode \"q=CREATE USER {{ influxdb_admin_user }} WITH PASSWORD '{{ influxdb_admin_password }}' WITH ALL PRIVILEGES\""

- name: create influxdb database
shell: "curl -G http://localhost:8086/query --data-urlencode \"u={{ influxdb_admin_user }}\" --data-urlencode \"p={{ influxdb_admin_password }}\" --data-urlencode \"q=CREATE DATABASE {{ influxdb_database }}\""

- name: create user for influxdb database
shell: "curl -G http://localhost:8086/query --data-urlencode \"u={{ influxdb_admin_user }}\" --data-urlencode \"p={{ influxdb_admin_password }}\" --data-urlencode \"q=CREATE USER {{ influxdb_user }} WITH PASSWORD '{{ influxdb_password }}'\""

- name: grant privileges to user for influxdb database
shell: "curl -G http://localhost:8086/query --data-urlencode \"u={{ influxdb_admin_user }}\" --data-urlencode \"p={{ influxdb_admin_password }}\" --data-urlencode \"q=GRANT ALL ON {{ influxdb_database }} TO {{ influxdb_user }}\""

168 changes: 168 additions & 0 deletions templates/influxdb.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
### 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 = false

###
### [meta]
###
### Controls the parameters for the Raft consensus group that stores metadata
### about the InfluxDB cluster.
###

[meta]
dir = "/var/opt/influxdb/meta"
hostname = "localhost"
bind-address = ":8088"
retention-autocreate = true
election-timeout = "1s"
heartbeat-timeout = "1s"
leader-lease-timeout = "500ms"
commit-timeout = "50ms"

###
### [data]
###
### Controls where the actual shard data for InfluxDB lives.
###

[data]
dir = "/var/opt/influxdb/data"

###
### [cluster]
###
### Controls non-Raft cluster behavior, which generally includes how data is
### shared across shards.
###

[cluster]
shard-writer-timeout = "5s"

###
### [retention]
###
### Controls the enforcement of retention policies for evicting old data.
###

[retention]
enabled = true
check-interval = "10m"

###
### [admin]
###
### Controls the availability of the built-in, web-based admin interface.
###

[admin]
enabled = true
bind-address = ":8083"

###
### [http]
###
### Controls how the HTTP endpoints are configured. These are the primary
### mechanism for getting data into and out of InfluxDB.
###

[http]
enabled = true
bind-address = ":8086"
auth-enabled = {{ influxdb_http_auth_enabled | default('false') }}
log-enabled = true
write-tracing = false
pprof-enabled = false

###
### [[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"

###
### [collectd]
###
### Controls the listener for collectd data.
###

[collectd]
enabled = false
# bind-address = ""
# database = ""
# typesdb = ""

###
### [opentsdb]
###
### Controls the listener for OpenTSDB data.
###

[opentsdb]
enabled = false
# bind-address = ""
# database = ""
# retention-policy = ""

###
### [udp]
###
### Controls the listener for InfluxDB line protocol data via UDP.
###

[udp]
enabled = false
# bind-address = ""
# database = ""
# batch-size = 0
# batch-timeout = "0"

###
### [monitoring]
###

[monitoring]
enabled = true
write-interval = "24h"

###
### [continuous_queries]
###
### Controls how continuous queries are run within InfluxDB.
###

[continuous_queries]
enabled = true
recompute-previous-n = 2
recompute-no-older-than = "10m"
compute-runs-per-interval = 10
compute-no-more-than = "2m"

###
### [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 = true
dir = "/var/opt/influxdb/hh"
max-size = 1073741824
max-age = "168h"
retry-rate-limit = 0
retry-interval = "1s"
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# vars file for ansible-playbook-influxdb