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

Updates.

parent 66e4f038
InfluxDB
========
An Ansible role to install, configure, and manage [InfluxDB](https://github.com/influxdb/influxdb) (a time-series database) v0.9 instances.
An Ansible role to install, configure, and manage
[InfluxDB](https://github.com/influxdata/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).
Prior knowledge/experience with InfluxDB is highly recommended. Full
documentation is available
[here](https://docs.influxdata.com/influxdb/latest).
Installation
------------
......@@ -20,38 +24,59 @@ ansible-galaxy install rossmcdonald.influxdb
Role Variables
--------------
The high-level variables are stored in the `defaults/main.yml` file. The most important ones being:
The high-level variables are stored in the `defaults/main.yml` file. The most important one being:
```
# Channel of InfluxDB to install (stable, unstable, nightly)
influxdb_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)
influxdb_cluster_servers: no
# When clustering is enabled, whether or not to overwrite the /etc/hosts file with raw
# IPs (may be useful if no DNS resolution).
influxdb_overwrite_hosts_file: yes
```
More advanced configuration options are stored in the `defaults/main.yml` file, which includes all of the necessary bells and whistles to tweak your configuration. The entire InfluxDB configuration defaults are set using the `defaults/main.yml` file. You may override these via inventory vars, playbook vars, or extra vars.
More advanced configuration options are also stored in the
`defaults/main.yml` file, which includes all of the necessary bells
and whistles to tweak your configuration. There are more advanced
runtime options available in the `vars/main.yml` file as well.
Dependencies
------------
No other Ansible dependencies are required. This role was tested and developed with Ansible 1.9.4.
No other Ansible dependencies are required. This role was tested and
developed with Ansible 1.9.4.
Testing
-------
To test the role locally, it is recommended to either use
[Vagrant](https://www.vagrantup.com/) or Docker. There are a variety
of available Dockerfiles in the `/docker` directory. For more
information on building the images, please review the
`docker/build.sh` script.
To run a playbook within one of the Docker images, simply run:
```
docker run -v $(pwd):/root <DOCKER IMAGE> <PLAYBOOK>
```
For example, to run the included `test.yml` using the included CentOS
7 Docker image, run (after building the image):
```
docker run -v $(pwd):/root ansible.influxdb.centos7 test.yml
```
Example Playbook
----------------
An example playbook is included in the `test.yml` file. There is also a `Vagrantfile`, which can be used for quick local testing leveraging [Vagrant](https://www.vagrantup.com/).
An example playbook is included in the `test.yml` file. There is also
a `Vagrantfile`, which can be used for quick local testing leveraging
[Vagrant](https://www.vagrantup.com/), and a few Docker Dockerfiles
located in the `/docker` directory.
Contributions and Feedback
--------------------------
Any contributions are welcome. For any bugs or feature requests, please open an issue through Github.
Any contributions are welcome. For any bugs or feature requests,
please open an issue through Github.
License
-------
......
- hosts: all
vars_files:
- defaults/main.yml
- vars/main.yml
tasks:
- include: tasks/main.yml
influxdb_cluster_servers: yes
influxdb_overwrite_hosts_file: yes
handlers:
- include: handlers/main.yml
......@@ -154,4 +154,5 @@ influxdb_hh_dir: /var/lib/influxdb/hh
influxdb_hh_max_size: 1073741824
influxdb_hh_max_age: 168h
influxdb_hh_retry_rate_limit: 0
influxdb_hh_retry_interval: 1s
\ No newline at end of file
influxdb_hh_retry_interval: 1s
influxdb_hh_purge_interval: 1h
---
- name: Set clustered configuration
template:
src: etc/default/influxdb.j2
dest: /etc/default/influxdb
force: yes
backup: yes
owner: root
group: root
mode: 0644
register: influxdb_cluster_set
- name: Stop InfluxDB
service:
name: influxdb
state: stopped
when: influxdb_cluster_set.changed or influxdb_purge_peer_data
- name: Purge existing peer data
file:
path: "{{ item }}"
state: absent
with_items:
- "{{ influxdb_meta_dir }}"
- "{{ influxdb_data_dir }}"
- "{{ influxdb_data_wal_dir }}"
when: influxdb_purge_peer_data
# - name: Start InfluxDB
# service:
# name: influxdb
# state: started
# when: influxdb_cluster_set.changed or influxdb_purge_peer_data
# - name: Pause for a moment
# pause:
# seconds: 3
# when: influxdb_cluster_set.changed or influxdb_purge_peer_data
# - name: Collect cluster status
# command: "{{ influxdb_binary_path }}/influx -execute 'show servers'"
# register: influxdb_show_servers_output
# - name: Assert clustering status (local/vagrant)
# assert:
# that:
# - "influxdb_show_servers_output.stdout.find(item)"
# with_items: groups['all']
# when: is_vagrant
# - name: Assert clustering status (non-local)
# assert:
# that:
# - "influxdb_show_servers_output.stdout.find(item)"
# with_items: groups['influxdb']|default([])
# when: "'influxdb' in groups and is_vagrant == False"
\ No newline at end of file
---
- name: Update hosts configuration
template:
src: etc/hosts.j2
dest: /etc/hosts
force: yes
backup: yes
owner: root
group: root
mode: 0644
when: influxdb_overwrite_hosts_file
- include: install-redhat.yml
when: ansible_os_family == "RedHat"
......
......@@ -5,10 +5,6 @@
- include: configure.yml
tags: [influxdb, configure]
- include: cluster.yml
tags: [influxdb, cluster]
when: influxdb_cluster_servers and influxdb_start_service
- name: Start the InfluxDB service
service:
name: influxdb
......@@ -19,7 +15,7 @@
- name: Pause to ensure InfluxDB service is up
pause:
seconds: 3
seconds: 5
when: influxdb_started.changed and influxdb_start_service
- name: Collect service status
......
{% if is_vagrant and influxdb_cluster_servers %}
VAGRANT=true
{% if groups['all'][0] != ansible_hostname %}
INFLUXD_OPTS="-join {% for host in groups['all'] if hostvars[host]['ansible_hostname'] != ansible_hostname %}{% if loop.index0 <= 1 %}{{ hostvars[host]['ansible_all_ipv4_addresses']|last }}:{{ influxdb_meta_http_port }}{% if not loop.index > 1 %},{% endif %}{% endif %}{% endfor %}"
{% endif %}
{% else %}
VAGRANT=false
{% if hostvars[groups['influxdb'][0]]['ansible_hostname'] != ansible_hostname %}
INFLUXD_OPTS="-join {% for host in groups['influxdb'] if hostvars[host]['ansible_hostname'] != ansible_hostname %}{% if loop.index0 <= 1 %}{{ hostvars[host]['ansible_all_ipv4_addresses']|last }}:{{ influxdb_meta_http_port }}{% if not loop.index > 1 %},{% endif %}{% endif %}{% endfor %}"
{% endif %}
{% endif %}
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
0.0.0.0 {{ ansible_hostname }}
{% for host in groups['all'] %}
{% if host != "localhost" and hostvars[host]['ansible_hostname'] != ansible_hostname %}
{{ hostvars[host]['ansible_all_ipv4_addresses'] | last }} {{ hostvars[host]['ansible_hostname'] }}
{% endif %}
{% endfor %}
......@@ -6,6 +6,7 @@
# 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 = {{ influxdb_disable_reporting }}
###
......@@ -25,7 +26,7 @@ reporting-disabled = {{ influxdb_disable_reporting }}
heartbeat-timeout = "{{ influxdb_meta_heartbeat_timeout }}"
leader-lease-timeout = "{{ influxdb_meta_leader_lease_timeout }}"
commit-timeout = "{{ influxdb_meta_commit_timeout }}"
cluster-tracing = {{ influxdb_meta_cluster_tracing }}
cluster-tracing = {{ influxdb_meta_cluster_tracing|lower }}
https-enabled = false
https-certificate = ""
raft-promotion-enabled = true
......@@ -78,10 +79,9 @@ reporting-disabled = {{ influxdb_disable_reporting }}
cache-max-memory-size = 524288000
cache-snapshot-memory-size = 26214400
cache-snapshot-write-cold-duration = "1h0m0s"
compact-min-file-count = 3
compact-full-write-cold-duration = "24h0m0s"
max-points-per-block = 0
data-logging-enabled = true
# data-logging-enabled = true
###
### [cluster]
......@@ -253,14 +253,6 @@ reporting-disabled = {{ influxdb_disable_reporting }}
# batch-size = {{ influxdb_udp_batch_size }}
# batch-timeout = "{{ influxdb_udp_batch_timeout }}"
###
### [monitoring]
###
[monitoring]
enabled = {{ influxdb_monitoring_enabled }}
write-interval = "{{ influxdb_monitoring_write_interval }}"
###
### [continuous_queries]
###
......@@ -270,10 +262,6 @@ reporting-disabled = {{ influxdb_disable_reporting }}
[continuous_queries]
log-enabled = {{ influxdb_cq_log_enabled }}
enabled = {{ influxdb_cq_enabled }}
recompute-previous-n = {{ influxdb_cq_recompute_previous_n }}
recompute-no-older-than = "{{ influxdb_cq_recompute_no_older_than }}"
compute-runs-per-interval = {{ influxdb_cq_compute_runs_per_interval }}
compute-no-more-than = "{{ influxdb_cq_compute_no_more_than }}"
###
### [hinted-handoff]
......@@ -290,3 +278,4 @@ reporting-disabled = {{ influxdb_disable_reporting }}
max-age = "{{ influxdb_hh_max_age }}"
retry-rate-limit = {{ influxdb_hh_retry_rate_limit }}
retry-interval = "{{ influxdb_hh_retry_interval }}"
purge-interval = "{{ influxdb_hh_purge_interval }}"
......@@ -31,7 +31,7 @@ influxdb_stress_metric_tags:
# If supplied, will check for presence of database, and error if not found (useful for upgrade
# testing).
influxdb_verify_database_is_present:
influxdb_verify_database_is_present:
# Path for finding InfluxDB binaries. Added for backwards-compatibility with < 0.9.5
influxdb_binary_path: /usr/bin
Markdown is supported
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