bk node and refactor
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
"address": ":9000",
|
||||
"insecureAddress": "",
|
||||
"dnsNames": [
|
||||
"{{ services['ca']['domain'] }}.{{ domain['internal'] }}"
|
||||
"{{ services['ca']['domain']['internal'] }}.{{ domain['internal'] }}"
|
||||
],
|
||||
"logger": {
|
||||
"format": "text"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"ca-url": "https://{{ services['ca']['domain'] }}.{{ domain['internal'] }}:{{ services['ca']['ports']['https'] }}",
|
||||
"ca-url": "https://{{ services['ca']['domain']['internal'] }}.{{ domain['internal'] }}:{{ services['ca']['ports']['https'] }}",
|
||||
"ca-config": "/home/step/config/ca.json",
|
||||
"fingerprint": "215c851d2d0d2dbf90fc3507425207c29696ffd587c640c94a68dddb1d84d8e8",
|
||||
"fingerprint": "",
|
||||
"root": "/home/step/certs/{{ root_cert_filename }}"
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ provisioning = /etc/grafana/provisioning
|
||||
[server]
|
||||
protocol = http
|
||||
http_port = {{ services['grafana']['ports']['http'] }}
|
||||
domain = {{ services['grafana']['domain'] }}.{{ domain['internal'] }}
|
||||
root_url = http://{{ services['grafana']['domain'] }}.{{ domain['internal'] }}/
|
||||
domain = {{ services['grafana']['domain']['internal'] }}.{{ domain['internal'] }}
|
||||
root_url = https://{{ services['grafana']['domain']['internal'] }}.{{ domain['internal'] }}/
|
||||
router_logging = false
|
||||
|
||||
[database]
|
||||
type = postgres
|
||||
host = {{ services['postgresql']['domain'] }}.{{ domain['internal'] }}:{{ services['postgresql']['ports']['tcp'] }}
|
||||
host = {{ services['postgresql']['domain']['internal'] }}.{{ domain['internal'] }}:{{ services['postgresql']['ports']['tcp'] }}
|
||||
name = grafana_db
|
||||
user = grafana
|
||||
password = $__file{/run/secrets/GF_DB_PASSWORD}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# https://github.com/lldap/lldap/blob/main/example_configs/grafana_ldap_config.toml
|
||||
[[servers]]
|
||||
host = "{{ services['ldap']['domain'] }}.{{ domain['internal'] }}"
|
||||
host = "{{ services['ldap']['domain']['internal'] }}.{{ domain['internal'] }}"
|
||||
port = {{ services['ldap']['ports']['ldaps'] }}
|
||||
# Activate STARTTLS or LDAPS
|
||||
use_ssl = true
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@ apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
url: https://{{ services['prometheus']['domain'] }}.{{ domain['internal'] }}:{{ services['prometheus']['ports']['https'] }}
|
||||
url: https://{{ services['prometheus']['domain']['internal'] }}.{{ domain['internal'] }}:{{ services['prometheus']['ports']['https'] }}
|
||||
access: proxy
|
||||
isDefault: true
|
||||
jsonData:
|
||||
@@ -16,7 +16,7 @@ datasources:
|
||||
|
||||
- name: Loki
|
||||
type: loki
|
||||
url: https://{{ services['loki']['domain'] }}.{{ domain['internal'] }}:{{ services['loki']['ports']['https'] }}
|
||||
url: https://{{ services['loki']['domain']['internal'] }}.{{ domain['internal'] }}:{{ services['loki']['ports']['https'] }}
|
||||
access: proxy
|
||||
jsonData:
|
||||
tlsAuth: false
|
||||
@@ -26,4 +26,4 @@ datasources:
|
||||
maxLines: 1000
|
||||
secureJsonData:
|
||||
tlsCACert: "$__file{/etc/ssl/grafana/{{ root_cert_filename }}}"
|
||||
httpHeaderValue1: "{{ domain['internal'] }} "
|
||||
httpHeaderValue1: "{{ domain['internal'] }}"
|
||||
|
||||
@@ -13,10 +13,10 @@ Image=docker.io/grafana/grafana:{{ version['containers']['grafana'] }}
|
||||
ContainerName=grafana
|
||||
HostName=grafana
|
||||
|
||||
AddHost={{ services['postgresql']['domain'] }}.{{ domain['internal'] }}:host-gateway
|
||||
AddHost={{ services['ldap']['domain'] }}.{{ domain['internal'] }}:host-gateway
|
||||
AddHost={{ services['prometheus']['domain'] }}.{{ domain['internal'] }}:host-gateway
|
||||
AddHost={{ services['loki']['domain'] }}.{{ domain['internal'] }}:host-gateway
|
||||
AddHost={{ services['postgresql']['domain']['internal'] }}.{{ domain['internal'] }}:host-gateway
|
||||
AddHost={{ services['ldap']['domain']['internal'] }}.{{ domain['internal'] }}:host-gateway
|
||||
AddHost={{ services['prometheus']['domain']['internal'] }}.{{ domain['internal'] }}:host-gateway
|
||||
AddHost={{ services['loki']['domain']['internal'] }}.{{ domain['internal'] }}:host-gateway
|
||||
|
||||
PublishPort={{ services['grafana']['ports']['http'] }}:3000/tcp
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ Image=docker.io/lldap/lldap:{{ version['containers']['ldap'] }}
|
||||
ContainerName=ldap
|
||||
HostName=ldap
|
||||
# They are at the same host (for Pasta, it is needed)
|
||||
AddHost={{ services['postgresql']['domain'] }}.{{ domain['internal'] }}:host-gateway
|
||||
AddHost={{ services['postgresql']['domain']['internal'] }}.{{ domain['internal'] }}:host-gateway
|
||||
# For LDAPS - 636 > 6360 nftables
|
||||
PublishPort={{ services['ldap']['ports']['ldaps'] }}:6360/tcp
|
||||
# Web UI
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
# @authcomment@
|
||||
# TYPE DATABASE USER ADDRESS METHOD
|
||||
|
||||
# TYPE DATABASE USER ADDRESS METHOD
|
||||
# Local host `trust`
|
||||
local all all trust
|
||||
local all all trust
|
||||
|
||||
# Local monitoring connection (host - infra VM) `trust`
|
||||
hostssl postgres alloy {{ hostvars['fw']['network4']['infra']['server'] }}/32 trust
|
||||
hostssl postgres alloy {{ hostvars['fw']['network6']['infra']['server'] }}/128 trust
|
||||
hostssl postgres alloy {{ hostvars['fw']['network4']['subnet']['lla'] }} trust
|
||||
hostssl postgres alloy {{ hostvars['fw']['network6']['subnet']['lla'] }} trust
|
||||
hostssl postgres alloy {{ hostvars['fw']['network4']['infra']['server'] }}/32 trust
|
||||
hostssl postgres alloy {{ hostvars['fw']['network6']['infra']['server'] }}/128 trust
|
||||
hostssl postgres alloy {{ hostvars['fw']['network4']['subnet']['lla'] }} trust
|
||||
hostssl postgres alloy {{ hostvars['fw']['network6']['subnet']['lla'] }} trust
|
||||
|
||||
# Local connection (in postgresql container) needs password (127.0.0.1 - container loopback)
|
||||
host all all 127.0.0.1/32 scram-sha-256
|
||||
host all all ::1/128 scram-sha-256
|
||||
host all all 127.0.0.1/32 scram-sha-256
|
||||
host all all ::1/128 scram-sha-256
|
||||
|
||||
# Local connection (host - infra VM) needs password (169.254.1.0/24 - link_local subnet for containers in pasta mode)
|
||||
hostssl all all {{ hostvars['fw']['network4']['infra']['server'] }}/32 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network6']['infra']['server'] }}/128 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network4']['subnet']['lla'] }} scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network6']['subnet']['lla'] }} scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network4']['infra']['server'] }}/32 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network6']['infra']['server'] }}/128 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network4']['subnet']['lla'] }} scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network6']['subnet']['lla'] }} scram-sha-256
|
||||
|
||||
# auth VM
|
||||
hostssl all all {{ hostvars['fw']['network4']['auth']['server'] }}/32 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network6']['auth']['server'] }}/128 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network4']['auth']['server'] }}/32 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network6']['auth']['server'] }}/128 scram-sha-256
|
||||
|
||||
# app VM (Applications, 192.168.10.13)
|
||||
hostssl all all {{ hostvars['fw']['network4']['app']['server'] }}/32 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network6']['app']['server'] }}/128 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network4']['app']['server'] }}/32 scram-sha-256
|
||||
hostssl all all {{ hostvars['fw']['network6']['app']['server'] }}/128 scram-sha-256
|
||||
|
||||
@@ -41,4 +41,4 @@ autovacuum_vacuum_scale_factor = 0.1
|
||||
autovacuum_analyze_scale_factor = 0.05
|
||||
autovacuum_vacuum_cost_limit = 1000
|
||||
effective_io_concurrency = 200
|
||||
random_page_cost = 1.2
|
||||
random_page_cost = 1.2
|
||||
|
||||
+5
-1
@@ -11,8 +11,12 @@ StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
ExecStartPre=/usr/bin/podman exec postgresql sh -c "mkdir -p /backups/cluster && chown postgres:root /backups/cluster && chmod 770 /backups/cluster"
|
||||
ExecStartPre=/usr/bin/podman exec postgresql sh -c "mkdir -p /backups/sql && chown postgres:root /backups/sql && chmod 770 /backups/sql"
|
||||
|
||||
|
||||
# Run the script
|
||||
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c 'pg_dumpall -U postgres --schema-only | grep -v -E "CREATE ROLE postgres" > /backups/cluster/pg_cluster_$(date "+%%Y-%%m-%%d").sql'
|
||||
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c "find /backups/cluster -maxdepth 1 -type f -mtime +7 -delete"
|
||||
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c 'cp /backups/cluster/pg_cluster_$(date "+%%Y-%%m-%%d").sql /backups/sql/pg_cluster.sql'
|
||||
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c "find /backups/cluster -maxdepth 1 -type f -name 'pg_cluster_*.sql' -mtime +7 -delete"
|
||||
ExecStart=/usr/bin/podman exec postgresql sh -c "chown -R postgres:root /backups/cluster && chmod 660 /backups/cluster/*"
|
||||
ExecStart=/usr/bin/podman exec postgresql sh -c "chown -R postgres:root /backups/sql && chmod 660 /backups/sql/pg_cluster.sql"
|
||||
|
||||
+4
-1
@@ -11,6 +11,7 @@ StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
ExecStartPre=/usr/bin/podman exec postgresql sh -c "mkdir -p /backups/%i && chown postgres:root /backups/%i && chmod 770 /backups/%i"
|
||||
ExecStartPre=/usr/bin/podman exec postgresql sh -c "mkdir -p /backups/sql && chown postgres:root /backups/sql && chmod 770 /backups/sql"
|
||||
|
||||
# Run the script
|
||||
## DB Connection
|
||||
@@ -21,5 +22,7 @@ ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c 'printf "SET session
|
||||
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c 'pg_dump -U postgres -d %i_db --data-only >> /backups/%i/pg_%i_$(date "+%%Y-%%m-%%d").sql'
|
||||
## reset session replication role
|
||||
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c 'printf "SET session_replication_role = origin;\n" >> /backups/%i/pg_%i_$(date "+%%Y-%%m-%%d").sql'
|
||||
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c "find /backups/%i -maxdepth 1 -type f -mtime +7 -delete"
|
||||
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c 'cp -a /backups/%i/pg_%i_$(date "+%%Y-%%m-%%d").sql /backups/sql/pg_%i.sql'
|
||||
ExecStart=/usr/bin/podman exec -u postgres postgresql sh -c "find /backups/%i -maxdepth 1 -type f -name 'pg_%i_*.sql' -mtime +7 -delete"
|
||||
ExecStart=/usr/bin/podman exec postgresql sh -c "chown -R postgres:root /backups/%i && chmod 660 /backups/%i/*"
|
||||
ExecStart=/usr/bin/podman exec postgresql sh -c "chown -R postgres:root /backups/sql && chmod 660 /backups/sql/pg_%i.sql"
|
||||
|
||||
@@ -24,7 +24,7 @@ scrape_configs:
|
||||
scheme: "https"
|
||||
tls_config:
|
||||
ca_file: "/etc/ssl/prometheus/{{ root_cert_filename }}"
|
||||
server_name: "{{ services['prometheus']['domain'] }}.{{ domain['internal'] }}"
|
||||
server_name: "{{ ['internal'] }}.{{ domain['internal'] }}"
|
||||
static_configs:
|
||||
- targets: ["localhost:9090"]
|
||||
# The label name is added as a label `label_name=<label_value>` to any timeseries scraped from this config.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
groups:
|
||||
- name: node_exporters_heartbeat
|
||||
rules:
|
||||
{% for instance in ['vmm', 'fw', 'infra', 'auth', 'app'] %}
|
||||
{% for instance in ["vmm", "fw", "infra", "auth", "app"] %}
|
||||
- alert: {{ instance }}_node_exporter_down
|
||||
expr: |
|
||||
(present_over_time(up{instance="{{ instance }}"}[5m]) or on() vector(0)) == 0
|
||||
@@ -25,7 +25,7 @@ groups:
|
||||
description: "postgresql node is down for 5 mins."
|
||||
- name: Certificate_expiry_check
|
||||
rules:
|
||||
{% for filename in ['root.crt', 'intermediate.crt', 'crowdsec.crt', 'blocky.crt', 'postgresql.crt', 'ldap.crt', 'prometheus.crt', 'loki.crt', 'dsm.crt'] %}
|
||||
{% for filename in ["root.crt", "intermediate.crt", "crowdsec.crt", "blocky.crt", "kopia.crt", "postgresql.crt", "ldap.crt", "prometheus.crt", "loki.crt"] %}
|
||||
- alert: {{ filename | replace('.', '_') }}_is_expired_soon
|
||||
expr: |
|
||||
max(x509_cert_not_after{filename="{{ filename }}"}) - time() < 2592000
|
||||
|
||||
Reference in New Issue
Block a user