-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdeploy_influxdb.yml
126 lines (112 loc) · 3.85 KB
/
deploy_influxdb.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
- name: install and configure influxdb cluster
user: root
hosts:
- influxdb_cluster
- influxdb_benchmark
tasks:
- name: install dependencies
apt:
name: "{{ item }}"
state: latest
update_cache: yes
cache_valid_time: 600
with_items:
- python-software-properties
- python-pycurl
- name: install and configure influxdb cluster
user: root
hosts: influxdb_cluster
roles:
- role: selectel.influxdb
influxdb_cluster_group: influxdb_cluster
influxdb_config:
logging:
level: warn
cluster:
seed-servers:
- "{{ hostvars[groups[influxdb_cluster_group][0]]['ansible_default_ipv4']['address'] }}:8090"
post_tasks:
# use shell module instead of uri because https://github.com/ansible/ansible-modules-core/issues/265
- name: Create benchmark db
shell: "curl -X POST 'http://{{ ansible_ssh_host }}:8086/db?u=root&p=root' -d '{\"name\": \"benchmark\"}'"
when: inventory_hostname == groups['influxdb_cluster'][0]
register: create_db
connection: local
changed_when: '" exists" not in create_db.stdout'
- name: install and configure influxdb benchmark host
user: root
hosts: influxdb_benchmark
roles:
- role: selectel.influxdb
influxdb_config:
logging:
level: warn
influxdb_benchmark_config: # if this not defined, then benchmark config generation will be skipped
log_file: benchmark.log
servers:
- connection_string: "{{ hostvars[groups['influxdb_cluster'][0]]['ansible_default_ipv4']['address'] }}:8086"
is_secure: false
skip_verify: false
timeout: 15s
cluster_credentials:
database: benchmark
user: root
password: root
stats_server:
connection_string: "localhost:8086"
database: bench_stat
user: root
password: root
is_secure: false
skip_verify: false
timeout: 10s
post_tasks:
# use shell module instead of uri because https://github.com/ansible/ansible-modules-core/issues/265
- name: Create bench_stat db
shell: "curl -X POST 'http://{{ ansible_ssh_host }}:8086/db?u=root&p=root' -d '{\"name\": \"bench_stat\"}'"
when: inventory_hostname == groups['influxdb_benchmark'][0]
register: create_db
connection: local
changed_when: '" exists" not in create_db.stdout'
- name: Create grafana db
shell: "curl -X POST 'http://{{ ansible_ssh_host }}:8086/db?u=root&p=root' -d '{\"name\": \"grafana\"}'"
when: inventory_hostname == groups['influxdb_benchmark'][0]
register: create_db
connection: local
changed_when: '" exists" not in create_db.stdout'
- name: install and configure influxdb benchmark host
user: root
hosts: influxdb_benchmark
roles:
- role: selectel.grafana
grafana_version: 1.9.0
grafana_config:
datasources:
influxdb:
type: influxdb
url: "https://{{ ansible_ssh_host }}/grafana/influxdb/db/bench_stat"
username: root
password: root
grafana:
type: influxdb
url: "https://{{ ansible_ssh_host }}/grafana/influxdb/db/grafana/"
username: root
password: root
grafanaDB: true
- role: selectel.nginx
nginx_sites_list:
- server_name: default
state: present
cert:
CN: "{{ ansible_fqdn }}"
O: "Company Ltd."
C: "RU"
days: 365
locations:
- location: "/grafana"
rules:
- alias: "/opt/grafana/current"
- index: "index.html"
- location: "/grafana/influxdb/"
rules:
- proxy_pass: "http://{{ ansible_ssh_host }}:8086/"