-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpod.bu.j2
1019 lines (884 loc) · 30.7 KB
/
pod.bu.j2
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
variant: fcos
version: 1.4.0
passwd:
users:
- name: {{ username }}
groups:
- wheel
password_hash: {{ password_hash }}
ssh_authorized_keys:
{%- if ssh_authorized_keys is iterable and ssh_authorized_keys is not string %}
{%- for key in ssh_authorized_keys %}
- {{ key }}
{%- endfor %}
{%- endif %}
storage:
files:
#######################
### System settings ###
#######################
- path: /etc/hostname
mode: 0644
contents:
inline: {{ hostname }}
# Allow overcommit_memory for redis
- path: /etc/sysctl.d/95-enable-overcommit_memory.conf
mode: 0644
contents:
inline: |
vm.overcommit_memory = 1
#######################
### systemd-network ###
#######################
- path: /etc/systemd/network/10-{{ eth.ifname }}.network
mode: 0644
overwrite: true
contents:
inline: |
[Match]
Name={{ eth.ifname }}
[Network]
DHCP=yes
DNS=1.1.1.1
DNS=1.0.0.1
IPMasquerade=ipv4
[DHCPv4]
# Use wired interface if DHCP (likely a wired internet source)
RouteMetric=1
[Address]
Label={{ eth.ifname }}:0
Address=10.100.0.1/24
- path: /etc/systemd/network/10-wifiAp.link
mode: 0644
overwrite: true
contents:
inline: |
[Match]
Property=ID_VENDOR_ID={{ ap.usb_vendor_id }} ID_MODEL_ID={{ ap.usb_model_id }}
[Link]
Name=wifiAp
- path: /etc/systemd/network/10-wifiAp.network
mode: 0644
overwrite: true
contents:
inline: |
[Match]
Name=wifiAp
[Network]
Address=10.60.0.1/24
DHCPServer=true
IPMasquerade=ipv4
[DHCPServer]
PoolOffset=100
PoolSize=50
EmitDNS=yes
- path: /etc/systemd/network/10-wifiSta.link
mode: 0644
overwrite: true
contents:
inline: |
[Match]
Property=ID_VENDOR_ID={{ wifi.usb_vendor_id }} ID_MODEL_ID={{ wifi.usb_model_id }}
[Link]
Name=wifiSta
- path: /etc/systemd/network/10-wifiSta.network
mode: 0644
overwrite: true
contents:
inline: |
[Match]
Name=wifiSta
[Network]
DHCP=ipv4
[DHCPv4]
# Use Wi-Fi connection after DHCP wired but before anything else
RouteMetric=2
########################
#### wpa_supplicant ####
########################
- path: /etc/wpa_supplicant/wpa_supplicant.conf
mode: 0600
overwrite: true
contents:
inline: |
ctrl_interface=/run/wpa_supplicant
ctrl_interface_group=wheel
update_config=1
# AP scanning
ap_scan=1
# Operating in the US
country=US
{%- if wifi.networks is iterable and wifi.networks is not string %}
{% for ssid in wifi.networks -%}
network={
ssid="{{ ssid }}"
{%- if wifi.networks[ssid] and wifi.networks[ssid].psk %}
psk="{{ wifi.networks[ssid].psk }}"
{%- else %}
key_mgmt=NONE
{%- endif %}
}
{% endfor %}
{% endif %}
###############
### hostapd ###
###############
- path: /etc/hostapd/hostapd.conf
mode: 0644
contents:
inline: |
# Documentation: https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
ssid={{ ap.ssid }}
wpa_passphrase={{ ap.wpa_passphrase }}
# Band: a = 5g (a/n/ac), g = 2g (b/g/n)
hw_mode=g
channel={{ ap.channel }}
country_code={{ ap.country_code }}
interface=wifiAp
driver=nl80211
beacon_int=100
dtim_period=2
max_num_sta=32
rts_threshold=2347
fragm_threshold=2346
auth_algs=1
macaddr_acl=0
ignore_broadcast_ssid=0
wpa=2
wpa_pairwise=CCMP
# WPA-2 AES
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
# IEEE 802.11n
ieee80211n=1
wmm_enabled=1
# Note: Only one ht_capab= line should be active. The content of these lines is
# determined by the capabilities of your adapter.
ht_capab={{ ap.ht_capab }}
##########
## NATS ##
##########
- path: /opt/datastation/nats/nats-server.conf
mode: 0644
contents:
inline: |
server_name: {{ hostname }}
listen: 127.0.0.1:4222
jetstream {
store_dir: /jetstream
max_mem: 1G
max_file: 10G
}
accounts: {
pod: {
jetstream: enabled
users: [
{ user: {{ nats.accounts.gateway.username }}, password: {{ nats.accounts.gateway.password }}, allowed_connection_types: ["MQTT"] },
{ user: {{ nats.accounts.chirpstack.username }}, password: {{ nats.accounts.chirpstack.password }}, allowed_connection_types: ["MQTT"] }
]
}
}
mqtt {
port: 1883
}
###############################
## Chirpstack Gateway Bridge ##
###############################
- path: /opt/datastation/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
mode: 0644
contents:
inline: |
# See https://www.chirpstack.io/gateway-bridge/install/config/ for a full
# configuration example and documentation.
[backend]
type="semtech_udp"
[backend.semtech_udp]
udp_bind = "0.0.0.0:1700"
[integration.mqtt.auth.generic]
servers=["tcp://host.containers.internal:1883"]
username="{{ nats.accounts.chirpstack.username }}"
password="{{ nats.accounts.chirpstack.password }}"
[integration.mqtt]
event_topic_template="us915_{{ chirpstack.us915_subband - 1 }}/gateway/{{ '{{ .GatewayID }}' }}/event/{{ '{{ .EventType }}' }}"
state_topic_template="us915_{{ chirpstack.us915_subband - 1 }}/gateway/{{ '{{ .GatewayID }}' }}/state/{{ '{{ .StateType }}' }}"
command_topic_template="us915_{{ chirpstack.us915_subband - 1 }}/gateway/{{ '{{ .GatewayID }}' }}/command/#"
##################
## Timescale DB ##
##################
- path: /opt/datastation/timescaledb/env
mode: 0644
contents:
inline: |
POSTGRES_PASSWORD={{ timescale.root.password }}
- path: /opt/datastation/timescaledb/initdb/101-init-chirpstack.sh
mode: 0644
contents:
inline: |
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
create role {{ timescale.cs.username }} with login password '{{ timescale.cs.password }}';
create database {{ timescale.cs.database }} with owner {{ timescale.cs.username }};
EOSQL
- path: /opt/datastation/timescaledb/initdb/102-chirpstack_extensions.sh
mode: 0644
contents:
inline: |
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname="{{ timescale.cs.database }}" <<-EOSQL
create extension pg_trgm;
create extension hstore;
EOSQL
- path: /opt/datastation/timescaledb/initdb/103-init-as-events.sh
mode: 0644
contents:
inline: |
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
create role {{ timescale.cs_events.username }} with login password '{{ timescale.cs_events.password }}';
create database {{ timescale.cs_events.database }} with owner {{ timescale.cs_events.username }};
EOSQL
- path: /opt/datastation/timescaledb/initdb/104-chirpstack-as-events_extensions.sh
mode: 0644
contents:
inline: |
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname="{{ timescale.cs_events.database }}" <<-EOSQL
create extension hstore;
EOSQL
################
## Adminer ##
################
- path: /opt/datastation/timescaledb/env
mode: 0644
contents:
inline: |
ADMINER_DESIGN=hever
ADMINER_PLUGINS=edit-calendar json-column
################
## Chirpstack ##
################
- path: /opt/datastation/chirpstack/chirpstack.toml
mode: 0644
contents:
inline: |
[logging]
level="info"
[postgresql]
dsn="postgres://{{ timescale.cs.username }}:{{ timescale.cs.password }}@host.containers.internal/{{ timescale.cs.database }}?sslmode=disable"
max_open_connections=10
min_idle_connections=0
[redis]
servers=[ "redis://localhost/", ]
tls_enabled=false
cluster=false
[network]
net_id="000000"
enabled_regions=[ "us915_{{ chirpstack.us915_subband - 1 }}", ]
[monitoring]
bind="0.0.0.0:8070"
[api]
bind="0.0.0.0:8080"
secret="{{ chirpstack.secret }}"
[integration]
enabled=["postgresql"]
[integration.postgresql]
dsn="postgres://{{ timescale.cs_events.username }}:{{ timescale.cs_events.password }}@host.containers.internal/{{ timescale.cs_events.database }}?sslmode=disable"
- path: /opt/datastation/chirpstack/region_{{ chirpstack.us915_subband }}.toml
mode: 0644
contents:
inline: |
[[regions]]
name="us915_{{ chirpstack.us915_subband - 1 }}"
common_name="US915"
[regions.gateway]
force_gws_private=false
[regions.gateway.backend]
enabled="mqtt"
[regions.gateway.backend.mqtt]
event_topic="us915_{{ chirpstack.us915_subband - 1 }}/gateway/+/event/+"
command_topic="us915_{{ chirpstack.us915_subband - 1 }}/gateway/{{ '{{ gateway_id }}' }}/command/{{ '{{ command }}' }}"
server="tcp://host.containers.internal:1883"
username="{{ nats.accounts.chirpstack.username }}"
password="{{ nats.accounts.chirpstack.password }}"
qos=0
clean_session=false
client_id="Chirpstack-us915_{{ chirpstack.us915_subband - 1 }}"
ca_cert=""
tls_cert=""
tls_key=""
[regions.network]
installation_margin=10
rx_window=0
rx1_delay=1
rx1_dr_offset=0
rx2_dr=8
rx2_frequency=923300000
rx2_prefer_on_rx1_dr_lt=0
rx2_prefer_on_link_budget=false
downlink_tx_power=-1
adr_disabled=false
min_dr=0
max_dr=3
enabled_uplink_channels=[
{{ (chirpstack.us915_subband - 1)*8 }},
{{ (chirpstack.us915_subband - 1)*8+1}},
{{ (chirpstack.us915_subband - 1)*8+2 }},
{{ (chirpstack.us915_subband - 1)*8+3 }},
{{ (chirpstack.us915_subband - 1)*8+4 }},
{{ (chirpstack.us915_subband - 1)*8+5 }},
{{ (chirpstack.us915_subband - 1)*8+6 }},
{{ (chirpstack.us915_subband - 1)*8+7 }},
{{ (chirpstack.us915_subband - 1)+64 }},
]
[regions.network.rejoin_request]
enabled=false
max_count_n=0
max_time_n=0
[regions.network.class_b]
ping_slot_dr=8
ping_slot_frequency=0
- path: /opt/datastation/chirpstack/import-ttn.sh
mode: 0755
contents:
inline: |
#!/usr/bin/env bash
if [[ $EUID -ne 0 ]]; then
sudo "$0" "$@"
exit $?
fi
git -C repo pull || git clone https://github.com/TheThingsNetwork/lorawan-devices
podman exec datastation-chirpstack chirpstack -c /etc/chirpstack import-ttn-lorawan-devices -d /etc/chirpstack/lorawan-devices
###############
### Grafana ###
###############
- path: /opt/datastation/grafana/env
mode: 0644
contents:
inline: |
GF_PLUGINS_ENABLE_ALPHA=true
GF_FEATURE_TOGGLES_ENABLE=publicDashboards
#################
### Prometheus ##
#################
- path: /opt/datastation/prometheus/prometheus.yml
mode: 0644
contents:
inline: |
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 30s
scrape_configs:
- job_name: {{ hostname }}
static_configs:
- targets: ["host.containers.internal:9100"]
- job_name: Prometheus
static_configs:
- targets: ["localhost:9090"]
- job_name: Chirpstack
static_configs:
- targets: ["host.containers.internal:8070"]
##################
### Cloudflare ###
##################
{%if cloudflare is defined %}
- path: /opt/datastation/cloudflared/cerdentials.json
mode: 0600
contents:
inline: |
{{ cloudflare.cerdentials }}
- path: /opt/datastation/cloudflared/config.yaml
mode: 0600
contents:
inline: |
tunnel: {{ cloudflare.tunnel }}
credentials-file: /root/.cloudflared/cerdentials.json
origincert: /root/.cloudflared/cert.pem
ingress:
{%- if cloudflare.chirpstack_fqdn is defined %}
- hostname: {{ cloudflare.chirpstack_fqdn }}
service: http://localhost:8080
{%- endif %}
{%- if cloudflare.grafana_fqdn is defined %}
- hostname: {{ cloudflare.grafana_fqdn }}
service: http://localhost:3000
{%- endif %}
{%- if cloudflare.adminer_fqdn is defined %}
- hostname: {{ cloudflare.adminer_fqdn }}
service: http://localhost:4000
{%- endif %}
{%- if cloudflare.ssh_fqdn is defined %}
- hostname: {{ cloudflare.ssh_fqdn }}
service: ssh://localhost:22
{%- endif %}
- service: http_status:404
{% endif %}
systemd:
units:
#######################
### First boot ###
#######################
- name: rpm-ostree-install.service
enabled: true
contents: |
[Unit]
Description=Install required system packages
Wants=network-online.target
After=network-online.target
# We run before `zincati.service` to avoid conflicting rpm-ostree transactions.
Before=zincati.service
# Only run on first boot
ConditionPathExists=!/var/lib/%N.stamp
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/rpm-ostree install --apply-live --allow-inactive neovim hostapd systemd-networkd wpa_supplicant
# Switch to systemd-networkd
ExecStart=/usr/bin/systemctl disable NetworkManager
ExecStart=/usr/bin/systemctl mask NetworkManager
ExecStart=/usr/bin/systemctl unmask systemd-networkd
ExecStart=/usr/bin/systemctl enable systemd-networkd
# Start hostapd on-boot
ExecStart=/usr/bin/systemctl unmask hostapd
ExecStart=/usr/bin/systemctl enable hostapd
# Start wpa_supplicant on-boot
ExecStart=/usr/bin/systemctl disable wpa_supplicant
ExecStart=/usr/bin/systemctl enable wpa_supplicant@wifiSta
# Only run this service on first-boot
ExecStart=/bin/touch /var/lib/%N.stamp
# Restart the system to get normal "boot up" environment
ExecStartPost=/usr/bin/systemctl reboot
[Install]
WantedBy=multi-user.target
#######################
### System Settings ###
#######################
# Disable THP for redis
- name: disable-transparent-huge-pages.service
enabled: true
contents: |
[Unit]
Description=Disable Transparent Huge Pages
[Service]
Type=oneshot
ExecStart=/usr/bin/sh -c "/usr/bin/echo never | tee /sys/kernel/mm/transparent_hugepage/enabled"
ExecStart=/usr/bin/sh -c "/usr/bin/echo never | tee /sys/kernel/mm/transparent_hugepage/defrag"
[Install]
WantedBy=multi-user.target
# Only wait on the wifiAp interface to come up. We don't expect Internet access all the time.
- name: systemd-networkd-wait-online.service
dropins:
- name: only-wait-for-wifiAp.conf
contents: |
[Service]
ExecStart=
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online -i wifiAp
# Start wpa_supplicant based on inteface name
- name: [email protected]
enabled: false
contents: |
[Unit]
Description=WPA supplicant (%i)
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=dbus.service sys-subsystem-net-devices-%i.device
[Service]
Type=dbus
BusName=fi.w1.wpa_supplicant1
ExecStart=/usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -u -i %i -s
Restart=on-failure
[Install]
WantedBy=sys-subsystem-net-devices-%i.device
###############
### hostapd ###
###############
- name: hostapd.service
mask: false
enabled: false # Enabled by rpm-ostree-install.service, once hostapd is installed
dropins:
- name: restart-on-failure.conf
contents: |
[Service]
Restart=on-failure
##########
## NATS ##
##########
- name: datastation-nats.service
mask: false
enabled: true
contents: |
[Unit]
Description=Datastation NATS
Wants=network-online.target
After=network-online.target rpm-ostree-install.service
# Don't start until after the first-boot install is finished
Requires=rpm-ostree-install.service
StartLimitIntervalSec=0
RequiresMountsFor=%t/containers
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--sdnotify=conmon \
-d \
-p 1883:1883 \
-v datastation-nats-jetstream:/jetstream \
-v /opt/datastation/nats/nats-server.conf:/nats-server.conf:z \
--name datastation-nats \
docker.io/library/nats:2.9.4
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target
###############################
## Chirpstack Gateway Bridge ##
###############################
- name: datastation-chirpstack-gateway-bridge.service
mask: false
enabled: true
contents: |
[Unit]
Description=Datastation Chirpstack Gateway Bridge
Wants=network-online.target
After=network-online.target rpm-ostree-install.service
# Don't start until after the first-boot install is finished
Requires=rpm-ostree-install.service
StartLimitIntervalSec=0
RequiresMountsFor=%t/containers
# User-defined dependencies
After=datastation-nats.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--sdnotify=conmon \
-d \
-p 1700:1700/udp \
-v /opt/datastation/chirpstack-gateway-bridge/:/etc/chirpstack-gateway-bridge:z \
--name datastation-chirpstack-gateway-bridge \
docker.io/chirpstack/chirpstack-gateway-bridge:4.0.1
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target
##################
## Timescale DB ##
##################
- name: datastation-tsdb.service
mask: false
enabled: true
contents: |
[Unit]
Description=Datastation TimescaleDB Postgres Database
Wants=network-online.target
After=network-online.target rpm-ostree-install.service
# Don't start until after the first-boot install is finished
Requires=rpm-ostree-install.service
StartLimitIntervalSec=0
RequiresMountsFor=%t/containers
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--sdnotify=conmon \
-d \
--replace \
-p 5432:5432 \
-v tsdb-data:/home/postgres/pgdata/data \
-v /opt/datastation/timescaledb/initdb/101-init-chirpstack.sh:/docker-entrypoint-initdb.d/101-init-chirpstack.sh:z \
-v /opt/datastation/timescaledb/initdb/102-chirpstack_extensions.sh:/docker-entrypoint-initdb.d/102-chirpstack_extensions.sh:z \
-v /opt/datastation/timescaledb/initdb/103-init-as-events.sh:/docker-entrypoint-initdb.d/103-init-as-events.sh:z \
-v /opt/datastation/timescaledb/initdb/104-chirpstack-as-events_extensions.sh:/docker-entrypoint-initdb.d/104-chirpstack-as-events_extensions.sh:z \
--env-file /opt/datastation/timescaledb/env \
--name datastation-tsdb \
docker.io/timescale/timescaledb-ha:pg14.5-ts2.8.1-oss-p2
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target
#############
## Adminer ##
#############
- name: datastation-adminer.service
mask: false
enabled: true
contents: |
[Unit]
Description=Adminer
Wants=network-online.target
After=network-online.target rpm-ostree-install.service
# Don't start until after the first-boot install is finished
Requires=rpm-ostree-install.service
StartLimitIntervalSec=0
RequiresMountsFor=%t/containers
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--sdnotify=conmon \
-d \
--replace \
-p 4000:8080 \
--env-file /opt/datastation/adminer/env \
--name datastation-adminer \
docker.io/adminer:4.8.1
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target
###########
## Redis ##
###########
- name: datastation-redis.service
mask: false
enabled: true
contents: |
[Unit]
Description=Datastation Redis
Wants=network-online.target
After=network-online.target rpm-ostree-install.service
# Don't start until after the first-boot install is finished
Requires=rpm-ostree-install.service
StartLimitIntervalSec=0
RequiresMountsFor=%t/containers
BindsTo=pod-datastation-chirpstack.service
After=pod-datastation-chirpstack.service
# User-defined dependencies
Requires=datastation-nats.service datastation-tsdb.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--pod-id-file %t/pod-datastation-chirpstack.pod-id \
--sdnotify=conmon \
-d \
--replace \
-v pod-redis:/data \
--name datastation-redis \
docker.io/library/redis:7.0.5-alpine
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target
################
## Chirpstack ##
################
- name: datastation-chirpstack.service
mask: false
enabled: true
contents: |
[Unit]
Description=Datastation Chirpstack
Wants=network-online.target
After=network-online.target pod-datastation-chirpstack.service rpm-ostree-install.service
# Don't start until after the first-boot install is finished
Requires=rpm-ostree-install.service
StartLimitIntervalSec=0
RequiresMountsFor=%t/containers
BindsTo=pod-datastation-chirpstack.service
# User-defined dependencies
Requires=datastation-nats.service datastation-tsdb.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--pod-id-file %t/pod-datastation-chirpstack.pod-id \
--sdnotify=conmon \
-d \
--replace \
-v /opt/datastation/chirpstack:/etc/chirpstack:z \
--name datastation-chirpstack \
docker.io/chirpstack/chirpstack:4.0.2 -c /etc/chirpstack
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target
######################
## Chirpstack (pod) ##
######################
- name: pod-datastation-chirpstack.service
mask: false
enabled: true
contents: |
[Unit]
Description=Datastation Chirpstack pod
Wants=network-online.target
After=network-online.target rpm-ostree-install.service
RequiresMountsFor=
# Don't start until after the first-boot install is finished
Requires=datastation-chirpstack.service datastation-redis.service rpm-ostree-install.service
Before=datastation-chirpstack.service datastation-redis.service
StartLimitIntervalSec=0
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/pod-datastation-chirpstack.pid %t/pod-datastation-chirpstack.pod-id
ExecStartPre=/usr/bin/podman pod create --infra-conmon-pidfile %t/pod-datastation-chirpstack.pid --pod-id-file %t/pod-datastation-chirpstack.pod-id --exit-policy=stop -p 8080:8080 -p 8070:8070 pod-datastation-chirpstack
ExecStart=/usr/bin/podman pod start --pod-id-file %t/pod-datastation-chirpstack.pod-id
ExecStop=/usr/bin/podman pod stop --ignore --pod-id-file %t/pod-datastation-chirpstack.pod-id -t 10
ExecStopPost=/usr/bin/podman pod rm --ignore -f --pod-id-file %t/pod-datastation-chirpstack.pod-id
PIDFile=%t/pod-datastation-chirpstack.pid
Type=forking
[Install]
WantedBy=default.target
#############
## Grafana ##
#############
- name: datastation-grafana.service
mask: false
enabled: true
contents: |
[Unit]
Description=Datastation Grafana
Wants=network-online.target
After=network-online.target rpm-ostree-install.service
# Don't start until after the first-boot install is finished
Requires=rpm-ostree-install.service
StartLimitIntervalSec=0
RequiresMountsFor=%t/containers
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--sdnotify=conmon \
-d \
--replace \
-p 3000:3000 \
-v datastation-grafana:/var/lib/grafana \
--env-file /opt/datastation/grafana/env \
--name datastation-grafana \
docker.io/grafana/grafana-oss:9.2.2
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target
################
## Prometheus ##
################
- name: datastation-prometheus.service
mask: false
enabled: true
contents: |
[Unit]
Description=Datastation Prometheus
Wants=network-online.target
After=network-online.target rpm-ostree-install.service
# Don't start until after the first-boot install is finished
Requires=rpm-ostree-install.service
StartLimitIntervalSec=0
RequiresMountsFor=%t/containers
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--sdnotify=conmon \
-d \
--replace \
-p 9090:9090 \
-v datastation-prometheus:/prometheus \
-v /opt/datastation/prometheus/:/etc/prometheus:z \
--name datastation-prometheus \
docker.io/prom/prometheus:v2.39.1
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all
[Install]
WantedBy=default.target
{% if cloudflare is defined %}
# Manage cloudflared podman container with systemd
- name: [email protected]
mask: false
enabled: true
contents: |
[Unit]
Description=Cloudflared tunnel for Chripstack, ThingsBoard, and SSH access
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers
StartLimitIntervalSec=0
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=always
RestartSec=5s
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \