107 lines
3.6 KiB
YAML
Raw Normal View History

---
# Copyright 2016, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Deploy influxdb
hosts: "cluster-metrics"
gather_facts: true
user: root
tasks:
Adding influx relay to make the existing monitoring stack highly available Added Influxdb relay to make the existing monitoring stack highly available. Relay replicates the data to multiple database instances. Also added configutation in HAProxy that load balances the read queries to influxdb instances and write queries to influxdb relays ┌─────────────────┐ │writes & queries │ └─────────────────┘ │ ▼ ┌───────────────┐ │ │ ┌────────│ Load Balancer │─────────┐ │ │ │ │ │ └──────┬─┬──────┘ │ │ │ │ │ │ │ │ │ │ ┌──────┘ └────────┐ │ │ │ ┌─────────────┐ │ │┌──────┐ │ │ │/write or UDP│ │ ││/query│ │ ▼ └─────────────┘ ▼ │└──────┘ │ ┌──────────┐ ┌──────────┐ │ │ │ InfluxDB │ │ InfluxDB │ │ │ │ Relay │ │ Relay │ │ │ └──┬────┬──┘ └────┬──┬──┘ │ │ │ | | │ │ │ | ┌─┼──────────────┘ | │ │ │ │ └──────────────┐ │ │ │ ▼ ▼ ▼ ▼ │ │ ┌──────────┐ ┌──────────┐ │ │ │ │ │ │ │ └─▶│ InfluxDB │ │ InfluxDB │◀─┘ │ │ │ │ └──────────┘ └──────────┘ This patch is dependent on this patch: https://review.openstack.org/#/c/392328/ Change-Id: I05bdaa0e2fb251b48df1d26d09ad63942872293a
2016-10-24 00:32:41 +00:00
- name: Check init system
command: cat /proc/1/comm
changed_when: false
register: _pid1_name
tags:
- always
- name: Set the name of pid1
set_fact:
pid1_name: "{{ _pid1_name.stdout }}"
tags:
- always
- name: InfluxDB datapath bind mount
lxc_container:
name: "{{ inventory_hostname }}"
container_command: |
[[ ! -d "/var/lib/influxdb" ]] && mkdir -p "/var/lib/influxdb"
container_config:
- "lxc.mount.entry=/openstack/{{ inventory_hostname }} var/lib/influxdb none bind 0 0"
delegate_to: "{{ physical_host }}"
- name: Add influxdata apt-keys
apt_key:
url: "https://repos.influxdata.com/influxdb.key"
state: "present"
- name: Add influxdata repo
apt_repository:
repo: "deb https://repos.influxdata.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: "present"
update_cache: yes
- name: Install influxdb
apt:
pkg: "influxdb"
state: "latest"
- name: Drop influxdb config file
template:
src: templates/influxdb.conf.j2
dest: /etc/influxdb/influxdb.conf
- name: Enable and restart influxdb
service:
name: "influxdb"
enabled: true
state: restarted
- name: Wait for influxdb to be ready
wait_for:
Adding influx relay to make the existing monitoring stack highly available Added Influxdb relay to make the existing monitoring stack highly available. Relay replicates the data to multiple database instances. Also added configutation in HAProxy that load balances the read queries to influxdb instances and write queries to influxdb relays ┌─────────────────┐ │writes & queries │ └─────────────────┘ │ ▼ ┌───────────────┐ │ │ ┌────────│ Load Balancer │─────────┐ │ │ │ │ │ └──────┬─┬──────┘ │ │ │ │ │ │ │ │ │ │ ┌──────┘ └────────┐ │ │ │ ┌─────────────┐ │ │┌──────┐ │ │ │/write or UDP│ │ ││/query│ │ ▼ └─────────────┘ ▼ │└──────┘ │ ┌──────────┐ ┌──────────┐ │ │ │ InfluxDB │ │ InfluxDB │ │ │ │ Relay │ │ Relay │ │ │ └──┬────┬──┘ └────┬──┬──┘ │ │ │ | | │ │ │ | ┌─┼──────────────┘ | │ │ │ │ └──────────────┐ │ │ │ ▼ ▼ ▼ ▼ │ │ ┌──────────┐ ┌──────────┐ │ │ │ │ │ │ │ └─▶│ InfluxDB │ │ InfluxDB │◀─┘ │ │ │ │ └──────────┘ └──────────┘ This patch is dependent on this patch: https://review.openstack.org/#/c/392328/ Change-Id: I05bdaa0e2fb251b48df1d26d09ad63942872293a
2016-10-24 00:32:41 +00:00
host: "{{ hostvars[item]['ansible_host'] }}"
port: "{{ influxdb_port }}"
delay: 1
Adding influx relay to make the existing monitoring stack highly available Added Influxdb relay to make the existing monitoring stack highly available. Relay replicates the data to multiple database instances. Also added configutation in HAProxy that load balances the read queries to influxdb instances and write queries to influxdb relays ┌─────────────────┐ │writes & queries │ └─────────────────┘ │ ▼ ┌───────────────┐ │ │ ┌────────│ Load Balancer │─────────┐ │ │ │ │ │ └──────┬─┬──────┘ │ │ │ │ │ │ │ │ │ │ ┌──────┘ └────────┐ │ │ │ ┌─────────────┐ │ │┌──────┐ │ │ │/write or UDP│ │ ││/query│ │ ▼ └─────────────┘ ▼ │└──────┘ │ ┌──────────┐ ┌──────────┐ │ │ │ InfluxDB │ │ InfluxDB │ │ │ │ Relay │ │ Relay │ │ │ └──┬────┬──┘ └────┬──┬──┘ │ │ │ | | │ │ │ | ┌─┼──────────────┘ | │ │ │ │ └──────────────┐ │ │ │ ▼ ▼ ▼ ▼ │ │ ┌──────────┐ ┌──────────┐ │ │ │ │ │ │ │ └─▶│ InfluxDB │ │ InfluxDB │◀─┘ │ │ │ │ └──────────┘ └──────────┘ This patch is dependent on this patch: https://review.openstack.org/#/c/392328/ Change-Id: I05bdaa0e2fb251b48df1d26d09ad63942872293a
2016-10-24 00:32:41 +00:00
with_items: "{{ groups['cluster-metrics'] }}"
- name: Create metrics DB
shell: >
influx -username {{ influxdb_db_root_name }}
-password {{ influxdb_db_root_password }}
-execute "{{ item }}"
with_items:
- "CREATE DATABASE {{ influxdb_db_name }}"
- "CREATE RETENTION POLICY {{ influxdb_db_retention_policy }} ON {{ influxdb_db_name }} DURATION {{ influxdb_db_retention }} REPLICATION {{ influxdb_db_replication }}"
- "CREATE USER {{ influxdb_db_metric_user }} WITH PASSWORD '{{ influxdb_db_metric_password }}'"
- "GRANT ALL ON {{ influxdb_db_name }} TO {{ influxdb_db_metric_user }}"
Adding influx relay to make the existing monitoring stack highly available Added Influxdb relay to make the existing monitoring stack highly available. Relay replicates the data to multiple database instances. Also added configutation in HAProxy that load balances the read queries to influxdb instances and write queries to influxdb relays ┌─────────────────┐ │writes & queries │ └─────────────────┘ │ ▼ ┌───────────────┐ │ │ ┌────────│ Load Balancer │─────────┐ │ │ │ │ │ └──────┬─┬──────┘ │ │ │ │ │ │ │ │ │ │ ┌──────┘ └────────┐ │ │ │ ┌─────────────┐ │ │┌──────┐ │ │ │/write or UDP│ │ ││/query│ │ ▼ └─────────────┘ ▼ │└──────┘ │ ┌──────────┐ ┌──────────┐ │ │ │ InfluxDB │ │ InfluxDB │ │ │ │ Relay │ │ Relay │ │ │ └──┬────┬──┘ └────┬──┬──┘ │ │ │ | | │ │ │ | ┌─┼──────────────┘ | │ │ │ │ └──────────────┐ │ │ │ ▼ ▼ ▼ ▼ │ │ ┌──────────┐ ┌──────────┐ │ │ │ │ │ │ │ └─▶│ InfluxDB │ │ InfluxDB │◀─┘ │ │ │ │ └──────────┘ └──────────┘ This patch is dependent on this patch: https://review.openstack.org/#/c/392328/ Change-Id: I05bdaa0e2fb251b48df1d26d09ad63942872293a
2016-10-24 00:32:41 +00:00
- name: Install git
apt:
pkg: "git"
state: "latest"
- name: Install GOLang
script: files/deploy_go.sh
- name: Download and install influx-relay
script: files/deploy_influxdbrelay.sh
- name: Drop influx relay toml file
template:
src: templates/relay.toml.j2
dest: /opt/influxdb-relay/relay.toml
- name: Drop Influx Relay upstart
template:
src: templates/influxdbrelay.conf.j2
dest: /etc/init/influxdbrelay.conf
when: pid1_name == "init"
- name: Drop Influx Relay service file
template:
src: templates/influxdbrelay.service.j2
dest: /etc/systemd/system/influxdbrelay.service
when: pid1_name == "systemd"
- name: Enable and restart influxdb
service:
name: "influxdbrelay"
state: restarted
vars_files:
- vars.yml