Skip to content

Commit ba543bb

Browse files
committed
Fix merge conflict
2 parents e3c6669 + b74027f commit ba543bb

12 files changed

Lines changed: 251 additions & 21 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
- name: Deploy monitoring proxy
3+
hosts:
4+
- monitoringproxy.dev.ooni.io
5+
- monitoringproxy.prod.ooni.io
6+
become: true
7+
roles:
8+
- role: bootstrap
9+
- role: dehydrated
10+
vars:
11+
ssl_domains:
12+
- "{{ inventory_hostname }}"
13+
tls_cert_dir: /var/lib/dehydrated/certs
14+
- role: nginx
15+
tags: nginx
16+
- role: monitoring_proxy
17+
vars:
18+
monitoring_proxy_public_fqdn: "{{ inventory_hostname }}"
19+
- role: prometheus_node_exporter
20+
vars:
21+
node_exporter_port: 9100
22+
node_exporter_host: "0.0.0.0"
23+
prometheus_nginx_proxy_config:
24+
- location: /metrics/node_exporter
25+
proxy_pass: http://127.0.0.1:9100/metrics

ansible/inventory

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ ams-ps.ooni.nu
3636
[aws-proxy]
3737
clickhouseproxy.dev.ooni.io
3838
clickhouseproxy.prod.ooni.io
39+
monitoringproxy.dev.ooni.io
40+
monitoringproxy.prod.ooni.io
3941

4042
[openvpn]
4143
openvpn1.htz-fsn.prod.ooni.nu

ansible/roles/clickhouse_proxy/tasks/main.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020
notify:
2121
- reload nftables
2222

23-
# For prometheus scrape requests
24-
- name: Allow traffic on port 9200
23+
- name: Allow traffic on port 9100
2524
tags: prometheus-proxy
2625
blockinfile:
27-
path: /etc/ooni/nftables/tcp/9200.nft
26+
path: /etc/ooni/nftables/tcp/9100.nft
2827
create: yes
2928
block: |
30-
add rule inet filter input tcp dport 9200 counter accept comment "prometheus"
29+
add rule inet filter input tcp dport 9100 counter accept comment "node exporter"
3130
notify:
3231
- reload nftables
3332

@@ -50,14 +49,3 @@
5049
notify:
5150
- reload nginx
5251
- restart nginx
53-
54-
- name: Add prometheus proxy nginx config
55-
tags: webserv
56-
template:
57-
src: templates/prometheus-proxy.conf
58-
dest: /etc/nginx/conf.d/prometheus-proxy.conf
59-
mode: 0755
60-
owner: root
61-
notify:
62-
- reload nginx
63-
- restart nginx
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tls_cert_dir: /var/lib/dehydrated/certs
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
- name: test nginx config
2+
command: /usr/sbin/nginx -t -c /etc/nginx/nginx.conf
3+
listen:
4+
- restart nginx
5+
- reload nginx
6+
7+
- name: restart nginx
8+
service:
9+
name: nginx
10+
state: restarted
11+
12+
- name: reload nginx
13+
service:
14+
name: nginx
15+
state: reloaded
16+
17+
- name: reload nftables
18+
tags: nftables
19+
ansible.builtin.systemd_service:
20+
name: nftables
21+
state: reloaded
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# For prometheus scrape requests
3+
- name: Flush all handlers
4+
meta: flush_handlers
5+
- name: Allow traffic on port 9200
6+
tags: prometheus-proxy
7+
blockinfile:
8+
path: /etc/ooni/nftables/tcp/9200.nft
9+
create: yes
10+
block: |
11+
add rule inet filter input tcp dport 9200 counter accept comment "prometheus"
12+
notify:
13+
- reload nftables
14+
15+
# TODO remove this task when the monitoring proxy is deployed
16+
- name: Allow traffic on port 9100
17+
tags: prometheus-proxy
18+
blockinfile:
19+
path: /etc/ooni/nftables/tcp/9100.nft
20+
create: yes
21+
block: |
22+
add rule inet filter input tcp dport 9100 counter accept comment "node exporter"
23+
notify:
24+
- reload nftables
25+
26+
- name: Create the modules-enabled directory if not exists
27+
tags: webserv
28+
ansible.builtin.file:
29+
path: /etc/nginx/modules-enabled
30+
state: directory
31+
mode: 0755
32+
owner: root
33+
group: root
34+
35+
- name: Add prometheus proxy nginx config
36+
tags: webserv
37+
template:
38+
src: templates/prometheus-proxy.conf
39+
dest: /etc/nginx/conf.d/prometheus-proxy.conf
40+
mode: 0755
41+
owner: root
42+
notify:
43+
- reload nginx
44+
- restart nginx

ansible/roles/clickhouse_proxy/templates/prometheus-proxy.conf renamed to ansible/roles/monitoring_proxy/templates/prometheus-proxy.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
server {
22
listen 9200 ssl;
33

4-
server_name {{ clickhouse_proxy_public_fqdn }};
4+
server_name {{ monitoring_proxy_public_fqdn }};
55

66
include /etc/nginx/ssl_intermediate.conf;
77

ansible/roles/prometheus/vars/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ prometheus_aws_access_key_prod: "{{ lookup('amazon.aws.aws_ssm', '/oonidevops/se
157157
prometheus_aws_secret_key_prod: "{{ lookup('amazon.aws.aws_ssm', '/oonidevops/secrets/ooni_monitoring/secret_key', profile='oonidevops_user_prod') }}"
158158

159159
# We replace the env from relabeling configs
160-
clickhouse_proxy_host: "clickhouseproxy.ENV.ooni.io"
160+
clickhouse_proxy_host: "monitoringproxy.ENV.ooni.io"

tf/environments/dev/main.tf

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ module "ooniapi_cluster" {
299299
# The clickhouse proxy has an nginx configuration
300300
# to proxy requests from the monitoring server
301301
# to the cluster instances
302-
module.ooni_clickhouse_proxy.ec2_sg_id
302+
module.ooni_clickhouse_proxy.ec2_sg_id,
303+
module.ooni_monitoring_proxy.ec2_sg_id
303304
]
304305

305306
tags = merge(
@@ -454,6 +455,11 @@ module "ooni_clickhouse_proxy" {
454455
to_port = 9200,
455456
protocol = "tcp"
456457
cidr_blocks = [for ip in flatten(data.dns_a_record_set.monitoring_host.*.addrs) : "${tostring(ip)}/32"]
458+
}, {
459+
from_port = 9100,
460+
to_port = 9100,
461+
protocol = "tcp"
462+
cidr_blocks = ["${module.ooni_monitoring_proxy.aws_instance_private_ip}/32"]
457463
}]
458464

459465
egress_rules = [{
@@ -488,6 +494,71 @@ resource "aws_route53_record" "clickhouse_proxy_alias" {
488494
]
489495
}
490496

497+
#### Monitoring Proxy
498+
module "ooni_monitoring_proxy" {
499+
source = "../../modules/ec2"
500+
501+
stage = local.environment
502+
503+
vpc_id = module.network.vpc_id
504+
subnet_id = module.network.vpc_subnet_public[0].id
505+
private_subnet_cidr = module.network.vpc_subnet_private[*].cidr_block
506+
dns_zone_ooni_io = local.dns_zone_ooni_io
507+
508+
key_name = module.adm_iam_roles.oonidevops_key_name
509+
instance_type = "t3a.nano"
510+
511+
name = "oonimnprx"
512+
ingress_rules = [{
513+
from_port = 22,
514+
to_port = 22,
515+
protocol = "tcp",
516+
cidr_blocks = ["0.0.0.0/0"],
517+
}, {
518+
from_port = 80,
519+
to_port = 80,
520+
protocol = "tcp",
521+
cidr_blocks = ["0.0.0.0/0"],
522+
}, {
523+
// For the prometheus proxy:
524+
from_port = 9200,
525+
to_port = 9200,
526+
protocol = "tcp"
527+
cidr_blocks = [for ip in flatten(data.dns_a_record_set.monitoring_host.*.addrs) : "${tostring(ip)}/32"]
528+
}]
529+
530+
egress_rules = [{
531+
from_port = 0,
532+
to_port = 0,
533+
protocol = "-1",
534+
cidr_blocks = ["0.0.0.0/0"],
535+
}, {
536+
from_port = 0,
537+
to_port = 0,
538+
protocol = "-1",
539+
ipv6_cidr_blocks = ["::/0"]
540+
}]
541+
542+
sg_prefix = "oomnprx"
543+
tg_prefix = "mnpr"
544+
545+
tags = merge(
546+
local.tags,
547+
{ Name = "ooni-tier1-monitoringproxy" }
548+
)
549+
}
550+
551+
resource "aws_route53_record" "monitoring_proxy_alias" {
552+
zone_id = local.dns_zone_ooni_io
553+
name = "monitoringproxy.${local.environment}.ooni.io"
554+
type = "CNAME"
555+
ttl = 300
556+
557+
records = [
558+
module.ooni_monitoring_proxy.aws_instance_public_dns
559+
]
560+
}
561+
491562
#### OONI Run service
492563

493564
module "ooniapi_oonirun_deployer" {

tf/environments/prod/main.tf

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,12 @@ module "ooni_clickhouse_proxy" {
385385
to_port = 9200,
386386
protocol = "tcp"
387387
cidr_blocks = [for ip in flatten(data.dns_a_record_set.monitoring_host.*.addrs) : "${tostring(ip)}/32"]
388-
}]
388+
}, {
389+
from_port = 9100,
390+
to_port = 9100,
391+
protocol = "tcp"
392+
cidr_blocks = ["${module.ooni_monitoring_proxy.aws_instance_private_ip}/32"]
393+
}]
389394

390395
egress_rules = [{
391396
from_port = 0,
@@ -419,6 +424,70 @@ resource "aws_route53_record" "clickhouse_proxy_alias" {
419424
]
420425
}
421426

427+
#### Monitoring Proxy
428+
module "ooni_monitoring_proxy" {
429+
source = "../../modules/ec2"
430+
431+
stage = local.environment
432+
433+
vpc_id = module.network.vpc_id
434+
subnet_id = module.network.vpc_subnet_public[0].id
435+
private_subnet_cidr = module.network.vpc_subnet_private[*].cidr_block
436+
dns_zone_ooni_io = local.dns_zone_ooni_io
437+
438+
key_name = module.adm_iam_roles.oonidevops_key_name
439+
instance_type = "t3a.nano"
440+
441+
name = "oonimnprx"
442+
ingress_rules = [{
443+
from_port = 22,
444+
to_port = 22,
445+
protocol = "tcp",
446+
cidr_blocks = ["0.0.0.0/0"],
447+
}, {
448+
from_port = 80,
449+
to_port = 80,
450+
protocol = "tcp",
451+
cidr_blocks = ["0.0.0.0/0"],
452+
}, {
453+
// For the prometheus proxy:
454+
from_port = 9200,
455+
to_port = 9200,
456+
protocol = "tcp"
457+
cidr_blocks = [for ip in flatten(data.dns_a_record_set.monitoring_host.*.addrs) : "${tostring(ip)}/32"]
458+
}]
459+
460+
egress_rules = [{
461+
from_port = 0,
462+
to_port = 0,
463+
protocol = "-1",
464+
cidr_blocks = ["0.0.0.0/0"],
465+
}, {
466+
from_port = 0,
467+
to_port = 0,
468+
protocol = "-1",
469+
ipv6_cidr_blocks = ["::/0"]
470+
}]
471+
472+
sg_prefix = "oomnprx"
473+
tg_prefix = "mnpr"
474+
475+
tags = merge(
476+
local.tags,
477+
{ Name = "ooni-tier1-monitoringproxy" }
478+
)
479+
}
480+
481+
resource "aws_route53_record" "monitoring_proxy_alias" {
482+
zone_id = local.dns_zone_ooni_io
483+
name = "monitoringproxy.${local.environment}.ooni.io"
484+
type = "CNAME"
485+
ttl = 300
486+
487+
records = [
488+
module.ooni_monitoring_proxy.aws_instance_public_dns
489+
]
490+
}
422491

423492
### OONI Services Clusters
424493

@@ -441,7 +510,8 @@ module "ooniapi_cluster" {
441510
# The clickhouse proxy has an nginx configuration
442511
# to proxy requests from the monitoring server
443512
# to the cluster instances
444-
module.ooni_clickhouse_proxy.ec2_sg_id
513+
module.ooni_clickhouse_proxy.ec2_sg_id,
514+
module.ooni_monitoring_proxy.ec2_sg_id
445515
]
446516

447517
tags = merge(
@@ -823,7 +893,10 @@ module "ansible_controller" {
823893

824894
dns_zone_ooni_io = local.dns_zone_ooni_io
825895

826-
monitoring_sg_ids = [module.ooni_clickhouse_proxy.ec2_sg_id]
896+
monitoring_sg_ids = [
897+
module.ooni_clickhouse_proxy.ec2_sg_id,
898+
module.ooni_monitoring_proxy.ec2_sg_id
899+
]
827900

828901
tags = {
829902
Environment = local.environment

0 commit comments

Comments
 (0)