Skip to content

Commit 9417856

Browse files
authored
Merge pull request #80 from wiseflat/dev/mgarcia/freqtrade
freqtrade
2 parents 2d440d8 + e75da36 commit 9417856

41 files changed

Lines changed: 347 additions & 78 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ansible/playbooks/paas/main.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,27 @@
1616
ansible.builtin.file:
1717
path: /etc/ansible/facts.d
1818
state: directory
19-
owner: "root"
20-
group: "root"
19+
owner: root
20+
group: root
2121
mode: '0755'
2222

23+
- name: Save Public IP as local fact
24+
when: fact_instance.location == 'frontends'
25+
block:
26+
- name: Get ipinfo.io (if backend instance, delegate_to the first frontend)
27+
ansible.builtin.uri:
28+
url: https://ipinfo.io
29+
http_agent: curl/7.81.0
30+
register: register_uri
31+
check_mode: false
32+
33+
- name: Set ipinfo local_fact
34+
ansible.builtin.copy:
35+
content: |
36+
{{ register_uri.json | to_nice_json }}
37+
dest: /etc/ansible/facts.d/ipinfo.fact
38+
mode: '0644'
39+
2340
- name: Install mandatories packages
2441
ansible.builtin.apt:
2542
pkg:

ansible/playbooks/paas/metrology.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
- mongodb_exporter
4343
- blackbox_exporter
4444
- nginx_exporter
45-
- scan_exporter
4645
- dns_exporter
4746
- script_exporter
4847
- nvidia_gpu_exporter
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
ARGS="--config.file=/etc/blackbox_exporter/config.yaml \
2-
--web.listen-address=127.0.0.1:9115"
2+
--web.listen-address={% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}:9115"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ARGS="-L 127.0.0.1 -c /etc/dns_exporter/config.yml"
1+
ARGS="-L {% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %} -c /etc/dns_exporter/config.yml"

ansible/playbooks/paas/roles/node_exporter/templates/default.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARGS="--log.level=info \
2-
--web.listen-address={{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}:9100 \
2+
--web.listen-address={% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}:9100 \
33
--web.telemetry-path=/metrics \
44
--collector.diskstats.ignored-devices='^(ram|loop|fd|(h|s|v|xv)d[a-z]|nbd|nvme[0-9]+n[0-9]+p|md|dm-)[0-9]+$' \
55
--collector.filesystem.mount-points-exclude='^/(dev(/shm)?|proc|run(/.+)?|sys|var/tmp|(var/lib|home)/(docker|kubelet)/.+)($|/)' \

ansible/playbooks/paas/roles/prometheus/templates/config.j2

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,19 @@ scrape_configs:
6666
regex: "^(__tmp_keep_me)$"
6767

6868
static_configs:
69-
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project %}
69+
{% if hostvars[inventory_hostname].nomad_mode == 'single' %}
70+
- targets: ['127.0.0.1:9100']
71+
labels:
72+
instance: "{{ inventory_hostname }}"
73+
project: "{{ prometheus_project }}"
74+
{% elif hostvars[inventory_hostname].nomad_mode == 'cluster' %}
75+
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project and item != inventory_hostname %}
7076
- targets: ['{{ hostvars[item]['ansible_' + hostvars[item].nomad_iface]['ipv4']['address'] }}:9100']
7177
labels:
7278
instance: "{{ item }}"
7379
project: "{{ prometheus_project }}"
7480
{% endfor %}
81+
{% endif %}
7582
scrape_interval: 60s
7683
scrape_timeout: 59s
7784

@@ -91,7 +98,7 @@ scrape_configs:
9198
params:
9299
script: [speedtest]
93100
static_configs:
94-
- targets: ['127.0.0.1:9469']
101+
- targets: ['{% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}:9469']
95102
labels:
96103
instance: "{{ inventory_hostname }}"
97104
project: "{{ prometheus_project }}"
@@ -104,7 +111,7 @@ scrape_configs:
104111
regex: "^(go_|prometheus_|promhttp_).*"
105112
source_labels: [__name__]
106113
static_configs:
107-
- targets: ['127.0.0.1:9469']
114+
- targets: ['{% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}:9469']
108115
labels:
109116
instance: "{{ inventory_hostname }}"
110117
project: "{{ prometheus_project }}"
@@ -115,7 +122,7 @@ scrape_configs:
115122
regex: "^(go_|prometheus_|promhttp_).*"
116123
source_labels: [__name__]
117124
static_configs:
118-
- targets: ['127.0.0.1:15353']
125+
- targets: ['{% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}:15353']
119126
labels:
120127
instance: "{{ inventory_hostname }}"
121128
project: "{{ prometheus_project }}"
@@ -135,7 +142,7 @@ scrape_configs:
135142
- source_labels: ["__address__"]
136143
target_label: "instance"
137144
- target_label: "__address__"
138-
replacement: "127.0.0.1:15353"
145+
replacement: "{% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}:15353"
139146
- target_label: "monitor"
140147
replacement: "{{ inventory_hostname }}"
141148
static_configs:
@@ -150,18 +157,27 @@ scrape_configs:
150157
regex: "^(go_|prometheus_|promhttp_).*"
151158
source_labels: [__name__]
152159
static_configs:
160+
{% if hostvars[inventory_hostname].nomad_mode == 'single' %}
153161
- targets: ['127.0.0.1:9323']
154162
labels:
155163
instance: "{{ inventory_hostname }}"
156164
project: "{{ prometheus_project }}"
165+
{% elif hostvars[inventory_hostname].nomad_mode == 'cluster' %}
166+
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project and item != inventory_hostname %}
167+
- targets: ['{{ hostvars[item]['ansible_' + hostvars[item].nomad_iface]['ipv4']['address'] }}:9323']
168+
labels:
169+
instance: "{{ item }}"
170+
project: "{{ prometheus_project }}"
171+
{% endfor %}
172+
{% endif %}
157173

158174
- job_name: "scan_exporter"
159175
metric_relabel_configs:
160176
- action: drop
161177
regex: "^(go_|prometheus_|promhttp_).*"
162178
source_labels: [__name__]
163179
static_configs:
164-
- targets: ['127.0.0.1:2112']
180+
- targets: ['{% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}:2112']
165181
labels:
166182
instance: "{{ inventory_hostname }}"
167183
project: "{{ prometheus_project }}"
@@ -178,13 +194,19 @@ scrape_configs:
178194
tls_config:
179195
insecure_skip_verify: true
180196
static_configs:
181-
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project %}
197+
{% if hostvars[inventory_hostname].nomad_mode == 'single' %}
198+
- targets: ['127.0.0.1:9558']
199+
labels:
200+
instance: "{{ inventory_hostname }}"
201+
project: "{{ prometheus_project }}"
202+
{% elif hostvars[inventory_hostname].nomad_mode == 'cluster' %}
203+
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project and item != inventory_hostname %}
182204
- targets: ['{{ hostvars[item]['ansible_' + hostvars[item].nomad_iface]['ipv4']['address'] }}:9558']
183205
labels:
184206
instance: "{{ item }}"
185207
project: "{{ prometheus_project }}"
186208
{% endfor %}
187-
209+
{% endif %}
188210
- job_name: "nvidia_gpu_exporter"
189211
metric_relabel_configs:
190212
- action: drop
@@ -194,13 +216,19 @@ scrape_configs:
194216
format: ['prometheus']
195217
metrics_path: /metrics
196218
static_configs:
197-
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project %}
219+
{% if hostvars[inventory_hostname].nomad_mode == 'single' %}
220+
- targets: ['127.0.0.1:9835']
221+
labels:
222+
instance: "{{ inventory_hostname }}"
223+
project: "{{ prometheus_project }}"
224+
{% elif hostvars[inventory_hostname].nomad_mode == 'cluster' %}
225+
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project and item != inventory_hostname %}
198226
- targets: ['{{ hostvars[item]['ansible_' + hostvars[item].nomad_iface]['ipv4']['address'] }}:9835']
199227
labels:
200228
instance: "{{ item }}"
201229
project: "{{ prometheus_project }}"
202230
{% endfor %}
203-
231+
{% endif %}
204232
- job_name: "nomad_exporter"
205233
metric_relabel_configs:
206234
- action: drop
@@ -214,13 +242,19 @@ scrape_configs:
214242
tls_config:
215243
insecure_skip_verify: true
216244
static_configs:
217-
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project %}
245+
{% if hostvars[inventory_hostname].nomad_mode == 'single' %}
246+
- targets: ['127.0.0.1:4646']
247+
labels:
248+
instance: "{{ inventory_hostname }}"
249+
project: "{{ prometheus_project }}"
250+
{% elif hostvars[inventory_hostname].nomad_mode == 'cluster' %}
251+
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project and item != inventory_hostname %}
218252
- targets: ['{{ hostvars[item]['ansible_' + hostvars[item].nomad_iface]['ipv4']['address'] }}:4646']
219253
labels:
220254
instance: "{{ item }}"
221255
project: "{{ prometheus_project }}"
222256
{% endfor %}
223-
257+
{% endif %}
224258
- job_name: 'mimir_exporter'
225259
nomad_sd_configs:
226260
- server: "https://{{ nomad_primary_master_address | default(hostvars[inventory_hostname]['ansible_' + hostvars[inventory_hostname].nomad_iface]['ipv4']['address']) }}:4646"
@@ -246,16 +280,22 @@ scrape_configs:
246280
tls_config:
247281
insecure_skip_verify: true
248282
static_configs:
249-
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project %}
283+
{% if hostvars[inventory_hostname].nomad_mode == 'single' %}
284+
- targets: ['127.0.0.1:9080']
285+
labels:
286+
instance: "{{ inventory_hostname }}"
287+
project: "{{ prometheus_project }}"
288+
{% elif hostvars[inventory_hostname].nomad_mode == 'cluster' %}
289+
{% for item in groups['infrastructure'] | default([]) if item.split('.')[4] == prometheus_project and item != inventory_hostname %}
250290
- targets: ['{{ hostvars[item]['ansible_' + hostvars[item].nomad_iface]['ipv4']['address'] }}:9080']
251291
labels:
252292
instance: "{{ item }}"
253293
project: "{{ prometheus_project }}"
254294
{% endfor %}
255-
295+
{% endif %}
256296
- job_name: 'blackbox'
257297
static_configs:
258-
- targets: ['127.0.0.1:9115']
298+
- targets: ['{% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}:9115']
259299
labels:
260300
instance: "{{ inventory_hostname }}"
261301
project: "{{ prometheus_project }}"

ansible/playbooks/paas/roles/promtail/templates/config.yaml.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
server:
2-
http_listen_address: {{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}
2+
http_listen_address: {% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}
3+
34
http_listen_port: 9080
45
grpc_listen_port: 0
56
log_level: warn
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Scan_exporter | Stopped scan_exporter
3+
ansible.builtin.service:
4+
name: scan_exporter
5+
state: stopped
6+
enabled: false
7+
ignore_errors: true
8+
9+
- name: Scan_exporter | Remove configuration
10+
ansible.builtin.file:
11+
path: "{{ item.path }}"
12+
state: absent
13+
loop:
14+
- path: /etc/default/scan_exporter
15+
- path: /etc/scan_exporter/config.yml
16+
- path: /etc/systemd/system/scan_exporter.service
17+
18+
- name: Scan_exporter | Daemon reload
19+
ansible.builtin.systemd_service:
20+
daemon_reload: true

ansible/playbooks/paas/roles/scan_exporter/templates/config.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tcp_period: 6h
1010
targets: []
1111
{% else %}
1212
targets:
13-
{% for host in groups['infrastructure'] if (fact_instance.location in ['frontends', 'frontends_vrack'] and host != inventory_hostname) %}
13+
{% for host in groups['infrastructure'] if (host.split(".")[1] == 'frontends' and host != inventory_hostname) %}
1414
- name: "{{ host }}"
1515
ip: "{{ hostvars[host].ansible_local.ipinfo.ip }}"
1616
queries_per_sec: 500
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ARGS="-metric.addr 127.0.0.1:2112 -config /etc/scan_exporter/config.yml"
1+
ARGS="-metric.addr {% if hostvars[inventory_hostname].nomad_mode == 'single' %}127.0.0.1{% else %}{{ hostvars[inventory_hostname]['ansible_' + nomad_iface]['ipv4']['address'] }}{% endif %}:2112 -config /etc/scan_exporter/config.yml"

0 commit comments

Comments
 (0)