Skip to content

Commit e8aca6d

Browse files
authored
Merge pull request #261 from ooni/deploy-fastpath-prod
Deploy fastpath prod
2 parents 9dd27fb + 14b67a4 commit e8aca6d

9 files changed

Lines changed: 453 additions & 78 deletions

File tree

ansible/deploy-fastpath.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- name: Deploy fastpath
33
hosts:
44
- fastpath.dev.ooni.io
5+
- fastpath.prod.ooni.io
56
become: true
67
roles:
78
- role: bootstrap
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
s3_ooni_open_data_access_key: "{{ lookup('amazon.aws.aws_ssm', '/oonidevops/secrets/s3_ooni_open_data_access_key', profile='oonidevops_user_prod') }}"
2+
clickhouse_url: "clickhouse://write:{{ lookup('amazon.aws.aws_ssm', '/oonidevops/secrets/clickhouse_write_password', profile='oonidevops_user_prod') }}@clickhouseproxy.prod.ooni.io/ooni"
3+
bucket_name: "ooni-data-eu-fra"
4+
collector_id: "4"
5+
env: "prod"

ansible/inventory

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ openvpn2.htz-fsn.prod.ooni.nu
4545

4646
[aws-backend]
4747
fastpath.dev.ooni.io
48-
# fastpath.prod.ooni.io
48+
fastpath.prod.ooni.io

ansible/roles/fastpath/tasks/main.yml

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
# For prometheus scrape requests
3-
- name: Flush all handlers
3+
- name: Flush all handlers
44
meta: flush_handlers
55

66
- name: Allow traffic on port 9100
@@ -12,7 +12,7 @@
1212
block: |
1313
add rule inet filter input tcp dport 9100 counter accept comment "node exporter"
1414
notify:
15-
- reload nftables
15+
- reload nftables
1616

1717
# For incoming fastpath traffic
1818
- name: Allow traffic on port 8472
@@ -24,7 +24,7 @@
2424
block: |
2525
add rule inet filter input tcp dport 8472 counter accept comment "fastpath"
2626
notify:
27-
- reload nftables
27+
- reload nftables
2828

2929
# For serving jsonl files
3030
- name: Allow traffic on port 8475
@@ -36,28 +36,28 @@
3636
block: |
3737
add rule inet filter input tcp dport 8475 counter accept comment "serve measurement spool"
3838
notify:
39-
- reload nftables
39+
- reload nftables
4040

4141
# Docker seems to have problems with nftables, so this command will translate all iptables
4242
# commands to nftables commands
43-
- name: Update alternatives for iptables
44-
tags: docker
45-
become: yes
46-
ansible.builtin.command: "update-alternatives --set iptables /usr/sbin/iptables-nft"
47-
notify:
48-
- restart docker
49-
50-
- name: Update alternatives for iptables
51-
tags: docker
52-
become: yes
53-
ansible.builtin.command: "update-alternatives --set ip6tables /usr/sbin/ip6tables-nft"
54-
notify:
55-
- restart docker
56-
57-
- name: Flush all handlers # Required to apply iptables settings before docker runs
58-
meta: flush_handlers
59-
60-
### Create fastpath user
43+
# - name: Update alternatives for iptables
44+
# tags: docker
45+
# become: yes
46+
# ansible.builtin.command: "update-alternatives --set iptables /usr/sbin/iptables-nft"
47+
# notify:
48+
# - restart docker
49+
50+
# - name: Update alternatives for iptables
51+
# tags: docker
52+
# become: yes
53+
# ansible.builtin.command: "update-alternatives --set ip6tables /usr/sbin/ip6tables-nft"
54+
# notify:
55+
# - restart docker
56+
57+
# - name: Flush all handlers # Required to apply iptables settings before docker runs
58+
# meta: flush_handlers
59+
60+
### Create fastpath user
6161
- name: Ensure the fastpath group exists
6262
ansible.builtin.group:
6363
name: "{{ fastpath_user }}"
@@ -103,11 +103,11 @@
103103
owner: "{{fastpath_user}}"
104104
become: yes
105105

106-
- name: Ensure ooniapi directory existence
106+
- name: Ensure ooniapi directory existence
107107
ansible.builtin.file:
108108
path: /var/lib/ooniapi
109109
state: directory
110-
mode: "0750"
110+
mode: "0711"
111111
owner: "{{fastpath_user}}"
112112
group: "{{fastpath_user}}"
113113

@@ -119,7 +119,7 @@
119119
owner: "{{fastpath_user}}"
120120
group: "{{fastpath_user}}"
121121

122-
- name: Allow nginx access to the spool dir
122+
- name: Allow nginx access to the spool dir
123123
become: true
124124
ansible.builtin.user:
125125
name: nginx
@@ -139,20 +139,22 @@
139139
- name: Ensure fastpath is running
140140
community.docker.docker_container:
141141
name: fastpath
142-
image: ooni/fastpath:v0.87
142+
image: ooni/fastpath:v0.88
143143
state: started
144144
user: "{{user_uid.stdout}}:{{user_gid.stdout}}"
145-
# use network mode = host to allow traffic from fastpath to the statsd exporter without
145+
# use network mode = host to allow traffic from fastpath to the statsd exporter without
146146
# creating a network with redirection rules to match the ports
147-
network_mode: host
147+
network_mode: host
148148
# published_ports: # unused on network_mode: host
149149
# - "8472:8472"
150150
volumes:
151151
- /opt/{{fastpath_user}}/backend/fastpath/fastpath.conf:/etc/ooni/fastpath.conf
152152
- /var/lib/ooniapi:/var/lib/ooniapi
153153
- /var/lib/fastpath:/var/lib/fastpath
154+
tags:
155+
- fastpath
154156

155-
### Serve jsonl from spool dir for oonimeasurements
157+
### Serve jsonl from spool dir for oonimeasurements
156158
- name: Add nginx config file for serving spool dir measurements
157159
tags: fastpath
158160
template:
@@ -161,17 +163,17 @@
161163
mode: "0444"
162164
owner: nginx
163165
become: yes
164-
notify:
166+
notify:
165167
- reload nginx
166168

167169
- name: Ensure the statsd to prometheus exporter is running
168170
community.docker.docker_container:
169171
name: statsd-exporter
170172
image: prom/statsd-exporter:v0.28.0
171173
state: started
172-
published_ports:
174+
published_ports:
173175
- "9102:9102" # for /metrics
174-
- "8125:9125" # for reporting metrics
176+
- "8125:9125" # for reporting metrics
175177
- "8125:9125/udp"
176178

177179
### API Uploader set up
@@ -193,7 +195,7 @@
193195
- name: Install dependencies for uploader
194196
tags: uploader
195197
apt:
196-
pkg:
198+
pkg:
197199
- python3-statsd
198200
- python3-boto3
199201
- python3-clickhouse-driver
@@ -203,7 +205,7 @@
203205
- name: Install uploder service
204206
tags: uploader
205207
template:
206-
src: templates/ooni-api-uploader.service
208+
src: templates/ooni-api-uploader.service
207209
dest: /etc/systemd/system/ooni-api-uploader.service
208210
mode: "0644"
209211
owner: root
@@ -216,6 +218,15 @@
216218
mode: "0644"
217219
owner: root
218220

221+
- name: Create spool dir
222+
tags: uploader
223+
ansible.builtin.file:
224+
path: /var/lib/ooniapi/measurements/incoming/
225+
state: directory
226+
mode: '0711'
227+
owner: "{{fastpath_user}}"
228+
group: "{{fastpath_user}}"
229+
219230
- name: Ensure uploader timer runs
220231
tags: uploader
221232
systemd:

tf/environments/dev/main.tf

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -322,20 +322,19 @@ resource "aws_iam_role_policy" "ooniprobe_role" {
322322
name = "${local.name}-task-role"
323323
role = module.ooniapi_cluster.container_host_role.name
324324

325-
policy = format(<<EOF
325+
policy = <<EOF
326326
{
327327
"Version": "2012-10-17",
328328
"Statement": [
329329
{
330330
"Sid": "",
331331
"Effect": "Allow",
332332
"Action": "s3:PutObject",
333-
"Resource": "%s/*"
333+
"Resource": "${aws_s3_bucket.ooniprobe_failed_reports.arn}/*"
334334
}
335335
]
336336
}
337337
EOF
338-
, aws_s3_bucket.ooniprobe_failed_reports.arn)
339338
}
340339

341340
module "ooniapi_ooniprobe_deployer" {
@@ -379,7 +378,7 @@ module "ooniapi_ooniprobe" {
379378
}
380379

381380
task_environment = {
382-
FASTPATH_URL = format("http://fastpath.%s.ooni.io:8472", local.environment)
381+
FASTPATH_URL = "http://fastpath.${local.environment}.ooni.io:8472"
383382
FAILED_REPORTS_BUCKET = aws_s3_bucket.ooniprobe_failed_reports.bucket
384383
COLLECTOR_ID = 3 # use a different one in prod
385384
}
@@ -615,12 +614,12 @@ module "ooni_fastpath" {
615614
from_port = 8472,
616615
to_port = 8472,
617616
protocol = "tcp",
618-
cidr_blocks = module.network.vpc_subnet_private[*].cidr_block,
617+
cidr_blocks = concat(module.network.vpc_subnet_private[*].cidr_block, module.network.vpc_subnet_public[*].cidr_block),
619618
}, {
620619
from_port = 8475, # for serving jsonl files
621620
to_port = 8475,
622621
protocol = "tcp",
623-
cidr_blocks = module.network.vpc_subnet_private[*].cidr_block,
622+
cidr_blocks = concat(module.network.vpc_subnet_private[*].cidr_block, module.network.vpc_subnet_public[*].cidr_block),
624623
}, {
625624
from_port = 9100,
626625
to_port = 9100,
@@ -891,7 +890,7 @@ module "ooniapi_oonimeasurements" {
891890

892891
task_environment = {
893892
# it has to be a json-compliant array
894-
OTHER_COLLECTORS = jsonencode(["http://fastpath.${local.environment}.ooni.io:8475"])
893+
OTHER_COLLECTORS = jsonencode(["https://backend-", "http://fastpath.${local.environment}.ooni.io:8475"])
895894
BASE_URL = "https://api.${local.environment}.ooni.io"
896895
S3_BUCKET_NAME = "ooni-data-eu-fra-test"
897896
}
@@ -943,6 +942,7 @@ locals {
943942
"ooniauth.${local.environment}.ooni.io" : local.dns_zone_ooni_io,
944943
"ooniprobe.${local.environment}.ooni.io" : local.dns_zone_ooni_io,
945944
"oonirun.${local.environment}.ooni.io" : local.dns_zone_ooni_io,
945+
"oonimeasurements.${local.environment}.ooni.io" : local.dns_zone_ooni_io,
946946
"8.th.dev.ooni.io" : local.dns_zone_ooni_io,
947947
}
948948
ooniapi_frontend_main_domain_name = "api.${local.environment}.ooni.io"
@@ -983,6 +983,10 @@ resource "aws_acm_certificate" "ooniapi_frontend" {
983983
tags = local.tags
984984

985985
subject_alternative_names = keys(local.ooniapi_frontend_alternative_domains)
986+
987+
lifecycle {
988+
create_before_destroy = true
989+
}
986990
}
987991

988992
resource "aws_route53_record" "ooniapi_frontend_cert_validation" {

0 commit comments

Comments
 (0)