chore: build
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||||
|
QyNTUxOQAAACAieAjqMxPu9SLzocyu4o3kGOZZqA8WEwNPgdJRADtLRgAAAJh6wtUQesLV
|
||||||
|
EAAAAAtzc2gtZWQyNTUxOQAAACAieAjqMxPu9SLzocyu4o3kGOZZqA8WEwNPgdJRADtLRg
|
||||||
|
AAAEBTpCulaM9MyR3rKmewOozUK9UxGJfYaME6Bzt35uccnSJ4COozE+71IvOhzK7ijeQY
|
||||||
|
5lmoDxYTA0+B0lEAO0tGAAAAEnhvcl9mYWtlcnNAQXN1c1hvcgECAw==
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICJ4COozE+71IvOhzK7ijeQY5lmoDxYTA0+B0lEAO0tG xor_fakers@AsusXor
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||||
|
QyNTUxOQAAACA5CWvGX+urJzagSGoqjWDC2+svolbRWVs9TKWuxkQ7WgAAAJA2iMzxNojM
|
||||||
|
8QAAAAtzc2gtZWQyNTUxOQAAACA5CWvGX+urJzagSGoqjWDC2+svolbRWVs9TKWuxkQ7Wg
|
||||||
|
AAAEB1HhVAu0nC6PvES3yJsO/KBvtUntDwIaQp7znJgvr5yTkJa8Zf66snNqBIaiqNYMLb
|
||||||
|
6y+iVtFZWz1Mpa7GRDtaAAAADWNhbWVyQEFzdXNYb3I=
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||||
|
QyNTUxOQAAACBN9tO6dO8g5b4BSdShuhozsfip5LavKRmAJ6DPlMzwDQAAAJDOjDh5zow4
|
||||||
|
eQAAAAtzc2gtZWQyNTUxOQAAACBN9tO6dO8g5b4BSdShuhozsfip5LavKRmAJ6DPlMzwDQ
|
||||||
|
AAAEB5AK5VwT8A9XyF90vgQdUbIL8fZAygZV65ebV61tBTV03207p07yDlvgFJ1KG6GjOx
|
||||||
|
+Knktq8pGYAnoM+UzPANAAAADWNhbWVyQEFzdXNYb3I=
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||||
|
QyNTUxOQAAACCWjBZrCPtCi8oAl32aed/Nm6iqVNOHOdaySen6B5jwogAAAIhX0UinV9FI
|
||||||
|
pwAAAAtzc2gtZWQyNTUxOQAAACCWjBZrCPtCi8oAl32aed/Nm6iqVNOHOdaySen6B5jwog
|
||||||
|
AAAEDBdRokUMkqZcgLXREfafmo/ZEMPhjPPZq5I/447cPZW5aMFmsI+0KLygCXfZp5382b
|
||||||
|
qKpU04c51rJJ6foHmPCiAAAAAAECAwQF
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJaMFmsI+0KLygCXfZp5382bqKpU04c51rJJ6foHmPCi
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
# ansible-playbook hardening/playbook-aide-hardening.yml --limit pre-prod-uber
|
# ansible-playbook hardening/playbook-aide-hardening.yml --limit pre-prod-uber
|
||||||
|
|
||||||
- name: Durcissement AIDE - integrite fichiers (CIS Ubuntu 24.04)
|
- name: Durcissement AIDE - integrite fichiers (CIS Ubuntu 24.04)
|
||||||
hosts: prod,pre-prod,bdd-redis-prod,replica-prod,infra,infra-runner,infra-utils,load-balancer
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
serial: 1
|
serial: 1
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
# ansible-playbook hardening/playbook-apparmor-hardening.yml --limit pre-prod-uber
|
# ansible-playbook hardening/playbook-apparmor-hardening.yml --limit pre-prod-uber
|
||||||
|
|
||||||
- name: Durcissement AppArmor (CIS Ubuntu 24.04)
|
- name: Durcissement AppArmor (CIS Ubuntu 24.04)
|
||||||
hosts: prod,pre-prod,bdd-redis-prod,replica-prod,infra,infra-runner,infra-utils,ota-uber,load-balancer
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
serial: 1
|
serial: 1
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
@@ -64,21 +64,25 @@
|
|||||||
when: grub_conf.changed
|
when: grub_conf.changed
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
|
||||||
- name: Forcer tous les profils AppArmor en mode enforce
|
# aa-enforce /etc/apparmor.d/* (glob sur ~120 fichiers) echoue parfois
|
||||||
ansible.builtin.command:
|
# silencieusement sur certains profils (aucune erreur, mais le fichier
|
||||||
cmd: aa-enforce /etc/apparmor.d/*
|
# source n'est pas reecrit) - constate sur des profils avec flags=(complain)
|
||||||
changed_when: true
|
# code en dur dans le fichier (ex: transmission-*). Un appel cible sur le
|
||||||
|
# fichier seul fonctionne systematiquement. Vu le caractere intermittent,
|
||||||
- name: Recharger apparmor (aa-enforce seul ne suffit pas toujours a faire prendre en compte le changement par le kernel)
|
# on refait tout le cycle enforce+reload a chaque retry plutot que de
|
||||||
ansible.builtin.systemd:
|
# seulement re-verifier un etat qui ne changera pas tout seul.
|
||||||
name: apparmor
|
- name: Forcer tous les profils AppArmor en enforce, recharger et verifier (retry complet si un profil est reste en complain)
|
||||||
state: reloaded
|
ansible.builtin.shell: |
|
||||||
|
set -e
|
||||||
- name: Verifier l'etat final (apparmor_status)
|
aa-enforce /etc/apparmor.d/*
|
||||||
ansible.builtin.command:
|
systemctl reload apparmor
|
||||||
cmd: apparmor_status
|
sleep 2
|
||||||
|
apparmor_status
|
||||||
register: aa_status
|
register: aa_status
|
||||||
changed_when: false
|
changed_when: true
|
||||||
|
until: "'0 profiles are in complain mode' in aa_status.stdout"
|
||||||
|
retries: 5
|
||||||
|
delay: 2
|
||||||
failed_when: >
|
failed_when: >
|
||||||
'profiles are in complain mode' in aa_status.stdout and
|
'profiles are in complain mode' in aa_status.stdout and
|
||||||
not (aa_status.stdout | regex_search('^0\s*profiles are in complain mode', multiline=True))
|
not (aa_status.stdout | regex_search('^0\s*profiles are in complain mode', multiline=True))
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
# ansible-playbook hardening/playbook-audit-rules-cis-rest.yml --limit pre-prod-uber
|
# ansible-playbook hardening/playbook-audit-rules-cis-rest.yml --limit pre-prod-uber
|
||||||
|
|
||||||
- name: Regles d'audit detaillees restantes CIS 6.2.3.x (Ubuntu 24.04)
|
- name: Regles d'audit detaillees restantes CIS 6.2.3.x (Ubuntu 24.04)
|
||||||
hosts: prod,pre-prod,bdd-redis-prod,replica-prod,infra,infra-runner,infra-utils,load-balancer
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
serial: 1
|
serial: 1
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
# ansible-playbook hardening/playbook-audit-rules-sudo-omnex.yml --limit pre-prod-uber
|
# ansible-playbook hardening/playbook-audit-rules-sudo-omnex.yml --limit pre-prod-uber
|
||||||
|
|
||||||
- name: Regles d'audit detaillees - sudo + omnex (CIS Ubuntu 24.04)
|
- name: Regles d'audit detaillees - sudo + omnex (CIS Ubuntu 24.04)
|
||||||
hosts: prod,pre-prod,bdd-redis-prod,replica-prod,infra,infra-runner,infra-utils,load-balancer
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
serial: 1
|
serial: 1
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
# ansible-playbook hardening/playbook-coredump-auditd-hardening.yml --limit pre-prod-uber
|
# ansible-playbook hardening/playbook-coredump-auditd-hardening.yml --limit pre-prod-uber
|
||||||
|
|
||||||
- name: Durcissement core dumps + apport + auditd (CIS Ubuntu 24.04)
|
- name: Durcissement core dumps + apport + auditd (CIS Ubuntu 24.04)
|
||||||
hosts: prod,pre-prod,bdd-redis-prod,replica-prod,infra,infra-runner,infra-utils,load-balancer
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
serial: 1
|
serial: 1
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
@@ -76,13 +76,16 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
- name: Verifier la presence de audit=1 dans GRUB_CMDLINE_LINUX
|
- name: Ajouter audit=1 audit_backlog_limit=8192 a GRUB_CMDLINE_LINUX (sans ecraser d'autres flags existants, ex: apparmor=1)
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.shell: |
|
||||||
path: /etc/default/grub
|
set -e
|
||||||
regexp: '^GRUB_CMDLINE_LINUX='
|
if ! grep -q 'audit=1' /etc/default/grub; then
|
||||||
line: 'GRUB_CMDLINE_LINUX="audit=1 audit_backlog_limit=8192"'
|
cp /etc/default/grub /etc/default/grub.bak-cis-audit
|
||||||
backup: true
|
sed -i 's/^\(GRUB_CMDLINE_LINUX="[^"]*\)"/\1 audit=1 audit_backlog_limit=8192"/' /etc/default/grub
|
||||||
|
echo CHANGED
|
||||||
|
fi
|
||||||
register: grub_conf
|
register: grub_conf
|
||||||
|
changed_when: "'CHANGED' in grub_conf.stdout"
|
||||||
|
|
||||||
- name: Regenerer grub.cfg si la config a change
|
- name: Regenerer grub.cfg si la config a change
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
# ansible-playbook hardening/playbook-cron-packages-hardening.yml --limit pre-prod-uber
|
# ansible-playbook hardening/playbook-cron-packages-hardening.yml --limit pre-prod-uber
|
||||||
|
|
||||||
- name: Durcissement cron/at + retrait paquets insecurises (CIS Ubuntu 24.04)
|
- name: Durcissement cron/at + retrait paquets insecurises (CIS Ubuntu 24.04)
|
||||||
hosts: prod,pre-prod,bdd-redis-prod,replica-prod,infra,infra-runner,infra-utils,load-balancer
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
serial: 1
|
serial: 1
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
# ansible-playbook hardening/playbook-journald-rsyslog-chrony.yml --limit pre-prod-uber
|
# ansible-playbook hardening/playbook-journald-rsyslog-chrony.yml --limit pre-prod-uber
|
||||||
|
|
||||||
- name: Durcissement journald/rsyslog/timesyncd (CIS Ubuntu 24.04)
|
- name: Durcissement journald/rsyslog/timesyncd (CIS Ubuntu 24.04)
|
||||||
hosts: prod,pre-prod,bdd-redis-prod,replica-prod,infra,infra-runner,infra-utils,load-balancer
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
serial: 1
|
serial: 1
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
# ansible-playbook hardening/playbook-kernel-sysctl-hardening.yml --limit pre-prod-uber
|
# ansible-playbook hardening/playbook-kernel-sysctl-hardening.yml --limit pre-prod-uber
|
||||||
|
|
||||||
- name: Durcissement kernel modules + sysctl reseau (CIS Ubuntu 24.04)
|
- name: Durcissement kernel modules + sysctl reseau (CIS Ubuntu 24.04)
|
||||||
hosts: prod,pre-prod,bdd-redis-prod,replica-prod,infra,infra-runner,infra-utils,load-balancer
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
serial: 1
|
serial: 1
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
# ansible-playbook infra/playbook-pam-hardening.yml --limit pre-prod-uber
|
# ansible-playbook infra/playbook-pam-hardening.yml --limit pre-prod-uber
|
||||||
#
|
#
|
||||||
- name: Durcissement PAM (CIS Ubuntu 24.04)
|
- name: Durcissement PAM (CIS Ubuntu 24.04)
|
||||||
hosts: bdd-redis-prod
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
serial: 1
|
serial: 1
|
||||||
any_errors_fatal: true
|
any_errors_fatal: true
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
- name: SSH HARDENNING
|
- name: SSH HARDENNING
|
||||||
hosts: prod,pre-prod,replica-prod,infra,infra-runner,infra-utils,ota-uber,load-balancer,!backup-mln
|
hosts: k3s-prod
|
||||||
become: true
|
become: true
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
tasks:
|
tasks:
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
---
|
||||||
|
# Installe et enrole l'agent Wazuh sur le cluster k3s (master + 3 workers).
|
||||||
|
# Ces hosts ne sont pas sur le VPN (voir inventory/host.ini) : ils joignent
|
||||||
|
# le manager (185.103.167.138) via son IP publique sur le port 1514/tcp,
|
||||||
|
# deja ouvert cote firewall (monitoring/security/firewall-monitoring-uber.sh).
|
||||||
|
# 1514 est publie directement par le conteneur wazuh_manager (pas via nginx) :
|
||||||
|
# aucune config nginx necessaire pour la connexion des agents.
|
||||||
|
#
|
||||||
|
# Enrolement par cle manuelle (manage_agents -a/-e sur le manager, puis -i
|
||||||
|
# sur l'agent) plutot que par agent-auth/authd (port 1515) : evite d'avoir a
|
||||||
|
# ouvrir un port supplementaire pour un enrolement one-shot.
|
||||||
|
|
||||||
|
- name: Installer et enroler l'agent Wazuh sur le cluster k3s
|
||||||
|
hosts: k3s-prod
|
||||||
|
become: true
|
||||||
|
gather_facts: false
|
||||||
|
|
||||||
|
vars:
|
||||||
|
wazuh_manager_ip: "185.103.167.138"
|
||||||
|
wazuh_agent_keys:
|
||||||
|
master-k3s: "MDE2IG1hc3Rlci1rM3MgYW55IDk3Y2UzYzM2MmVkOTQ0M2JmZThjMTQ1ODlkNjFlMTk0NmZlOWU1MjE2YjdlMDAzYzBiZGQxZDdjYmMwNjgzMjM="
|
||||||
|
slave-1-k3s: "MDE3IHNsYXZlLTEtazNzIGFueSA4OTFiZmRmOGVjZWIxYzY3OGRkYjk2MzU3NGVhOGM2YjYxMThmMDcyMTBiNjc3ZWNlMmIwZTA5MjYzN2Y1ZTNm"
|
||||||
|
slave-2-k3s: "MDE4IHNsYXZlLTItazNzIGFueSA4YzhiOTdmOTAyZDllOTRjZGI1ZjEyOGIyNjI1M2FkY2Y0MTdiYjg4NmQxYTNmNTkwMTcwOTNiZTk4ZTU0NmY2"
|
||||||
|
slave-3-k3s: "MDE5IHNsYXZlLTMtazNzIGFueSBjMGFmYWFlZDM1ZWQwMmI5ZWVlMGE1OTA4NmRhMWY5NTFlZmFjYmI5OTBkMGNlOWNjYjRmMmY2MjRhYTk4NmRj"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Ajouter la cle GPG Wazuh
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: https://packages.wazuh.com/key/GPG-KEY-WAZUH
|
||||||
|
dest: /tmp/gpg-key-wazuh
|
||||||
|
|
||||||
|
- name: Importer la cle GPG dans un keyring dedie
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
set -e
|
||||||
|
gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import /tmp/gpg-key-wazuh
|
||||||
|
chmod 644 /usr/share/keyrings/wazuh.gpg
|
||||||
|
args:
|
||||||
|
creates: /usr/share/keyrings/wazuh.gpg
|
||||||
|
|
||||||
|
- name: Ajouter le depot apt Wazuh
|
||||||
|
ansible.builtin.apt_repository:
|
||||||
|
repo: "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main"
|
||||||
|
filename: wazuh
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Installer wazuh-agent
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: wazuh-agent
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Configurer l'adresse du manager dans ossec.conf
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /var/ossec/etc/ossec.conf
|
||||||
|
regexp: "^\\s*<address>.*</address>"
|
||||||
|
line: " <address>{{ wazuh_manager_ip }}</address>"
|
||||||
|
|
||||||
|
- name: Verifier si une cle est deja importee
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /var/ossec/etc/client.keys
|
||||||
|
register: client_keys
|
||||||
|
|
||||||
|
- name: Importer la cle d'enrolement (une seule fois)
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
set -e
|
||||||
|
echo y | /var/ossec/bin/manage_agents -i "{{ wazuh_agent_keys[inventory_hostname] }}"
|
||||||
|
when: not client_keys.stat.exists or client_keys.stat.size == 0
|
||||||
|
|
||||||
|
- name: Activer et demarrer wazuh-agent
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: wazuh-agent
|
||||||
|
state: restarted
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
- name: Confirmer le succes pour cet host
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "✅ Wazuh agent installé et enrôlé sur {{ inventory_hostname }} (manager {{ wazuh_manager_ip }}:1514)."
|
||||||
Executable
+148
@@ -0,0 +1,148 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ── Charger les IDs créés par setup-portabase.sh ─────────────
|
||||||
|
source /home/ubuntu/docker/s3-backup/portabase-ids.env
|
||||||
|
|
||||||
|
BASE="http://10.0.0.4"
|
||||||
|
H="x-api-key: $API_KEY"
|
||||||
|
BDD_HOST="10.0.0.5"
|
||||||
|
SSH_KEY="/root/.ssh/key_bdd_redis" # clé SSH vers bdd-redis-prod
|
||||||
|
|
||||||
|
echo "[1/4] Attente de connexion de l'agent..."
|
||||||
|
echo " Déploiement de l'agent sur bdd-redis-prod ($BDD_HOST)..."
|
||||||
|
|
||||||
|
ssh -o StrictHostKeyChecking=no -i "$SSH_KEY" root@"$BDD_HOST" << AGENT_EOF
|
||||||
|
# Installer Docker si absent
|
||||||
|
if ! command -v docker &>/dev/null; then
|
||||||
|
echo " Installation de Docker..."
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y -qq ca-certificates curl gnupg lsb-release
|
||||||
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||||
|
echo "deb [arch=\$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||||
|
systemctl enable --now docker
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p /opt/portabase-agent
|
||||||
|
cd /opt/portabase-agent
|
||||||
|
|
||||||
|
cat > docker-compose.yml << 'COMPOSE'
|
||||||
|
services:
|
||||||
|
portabase-agent:
|
||||||
|
image: portabase/agent:latest
|
||||||
|
container_name: portabase-agent
|
||||||
|
restart: always
|
||||||
|
network_mode: host
|
||||||
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
- TZ=Europe/Paris
|
||||||
|
- DATABASES_CONFIG_FILE=config.toml
|
||||||
|
volumes:
|
||||||
|
- ./databases.toml:/config/config.toml:ro
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- agent-data:/data
|
||||||
|
- agent-tmp:/tmp
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
agent-data:
|
||||||
|
agent-tmp:
|
||||||
|
COMPOSE
|
||||||
|
|
||||||
|
cat > .env << ENVEOF
|
||||||
|
EDGE_KEY=$EDGE_KEY
|
||||||
|
ENVEOF
|
||||||
|
chmod 600 .env
|
||||||
|
|
||||||
|
cat > databases.toml << 'TOML'
|
||||||
|
[[databases]]
|
||||||
|
name = "Production PostgreSQL - gestion_commande_db"
|
||||||
|
database = "gestion_commande_db"
|
||||||
|
type = "postgresql"
|
||||||
|
username = "admin_gestion_commande_db"
|
||||||
|
password = "1SWDxH20rV7K2Uc2PNlwCaCxfVZEtKomF0CK9OMh"
|
||||||
|
port = 5432
|
||||||
|
host = "127.0.0.1"
|
||||||
|
generated_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
|
||||||
|
|
||||||
|
[[databases]]
|
||||||
|
name = "Production Redis"
|
||||||
|
type = "redis"
|
||||||
|
password = "k6UYX9RtuXJVV1HUeefbSukMcSwjvVgRsh2qJGPh"
|
||||||
|
port = 6379
|
||||||
|
host = "127.0.0.1"
|
||||||
|
generated_id = "b2c3d4e5-f6a7-8901-bcde-f12345678901"
|
||||||
|
TOML
|
||||||
|
|
||||||
|
docker compose pull -q
|
||||||
|
docker compose up -d
|
||||||
|
echo " Agent démarré"
|
||||||
|
AGENT_EOF
|
||||||
|
|
||||||
|
echo "[2/4] Attente que l'agent se connecte au dashboard..."
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
LAST=$(curl -sf "$BASE/api/v1/agents/$AGENT_ID" -H "$H" | python3 -c "import sys,json; print(json.load(sys.stdin).get('lastContact',''))" 2>/dev/null || true)
|
||||||
|
if [ -n "$LAST" ] && [ "$LAST" != "None" ] && [ "$LAST" != "null" ]; then
|
||||||
|
echo " Agent connecté (lastContact=$LAST)"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[3/4] Récupération des bases détectées..."
|
||||||
|
sleep 10
|
||||||
|
DBS=$(curl -sf "$BASE/api/v1/databases" -H "$H")
|
||||||
|
echo "$DBS" | python3 -c "
|
||||||
|
import sys, json
|
||||||
|
dbs = json.load(sys.stdin)
|
||||||
|
if isinstance(dbs, list):
|
||||||
|
for db in dbs:
|
||||||
|
print(f\" - {db.get('name','?')} (id={db['id']}, type={db.get('type','?')})\")
|
||||||
|
elif isinstance(dbs, dict) and 'data' in dbs:
|
||||||
|
for db in dbs['data']:
|
||||||
|
print(f\" - {db.get('name','?')} (id={db['id']}, type={db.get('type','?')})\")
|
||||||
|
else:
|
||||||
|
print(' Format inattendu:', json.dumps(dbs)[:200])
|
||||||
|
"
|
||||||
|
|
||||||
|
# Récupérer les IDs des bases PostgreSQL
|
||||||
|
PG_DB_ID=$(echo "$DBS" | python3 -c "
|
||||||
|
import sys, json
|
||||||
|
dbs = json.load(sys.stdin)
|
||||||
|
if isinstance(dbs, dict) and 'data' in dbs: dbs = dbs['data']
|
||||||
|
for db in dbs:
|
||||||
|
if db.get('type') == 'postgresql':
|
||||||
|
print(db['id'])
|
||||||
|
break
|
||||||
|
" 2>/dev/null || true)
|
||||||
|
|
||||||
|
echo "[4/4] Configuration du schedule de backup..."
|
||||||
|
|
||||||
|
if [ -n "$PG_DB_ID" ]; then
|
||||||
|
# Attacher la DB au projet
|
||||||
|
curl -sf -X PATCH "$BASE/api/v1/databases/$PG_DB_ID" \
|
||||||
|
-H "$H" -H "Content-Type: application/json" \
|
||||||
|
-d "{\"projectId\":\"$PROJECT_ID\"}" > /dev/null
|
||||||
|
echo " PostgreSQL attaché au projet"
|
||||||
|
|
||||||
|
# Configurer le backup quotidien (tous les jours à 02:00 et 02:15 pour 15min d'intervalle)
|
||||||
|
# cron: toutes les 15 min = */15 * * * * mais le user veut "tous les jours avec 15 min d'intervalle"
|
||||||
|
# = une backup par jour, pas toutes les 15 min. Donc cron = 0 2 * * * (02h00 chaque jour)
|
||||||
|
curl -sf -X PUT "$BASE/api/v1/databases/$PG_DB_ID/backup-policy" \
|
||||||
|
-H "$H" -H "Content-Type: application/json" \
|
||||||
|
-d '{"cron":"0 2 * * *","retentionCount":30}' > /dev/null
|
||||||
|
echo " Schedule: backup quotidien à 02h00, rétention 30 jours"
|
||||||
|
else
|
||||||
|
echo " ERREUR: base PostgreSQL non trouvée. Vérifier dans l'UI."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "============================================"
|
||||||
|
echo " Configuration terminée !"
|
||||||
|
echo " Dashboard : $BASE"
|
||||||
|
echo " Agent : connecté depuis bdd-redis-prod"
|
||||||
|
echo " Backup : quotidien à 02h00 UTC"
|
||||||
|
echo " Rétention : 30 derniers backups"
|
||||||
|
echo "============================================"
|
||||||
Executable
+189
@@ -0,0 +1,189 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BASE="http://10.0.0.4"
|
||||||
|
AGENT_ID="1f687170-8730-439d-82e6-dc23be878046"
|
||||||
|
PROJECT_ID="30dbbcc0-6f98-41b8-9a1d-12f0a1cc95e3"
|
||||||
|
ORG_ID="470f4039-8448-43c4-8aa5-0259e36a5f46"
|
||||||
|
|
||||||
|
# Load API key from env
|
||||||
|
source /home/ubuntu/docker/s3-backup/.env.api
|
||||||
|
H="x-api-key: $API_KEY"
|
||||||
|
ORIGIN="Origin: $BASE"
|
||||||
|
|
||||||
|
echo "=== [1/5] Attach agent to organization ==="
|
||||||
|
curl -s -w "\nHTTP %{http_code}\n" -X POST "$BASE/api/v1/organizations/$ORG_ID/agents" \
|
||||||
|
-H "$H" -H "$ORIGIN" -H "Content-Type: application/json" \
|
||||||
|
-d "{\"agentId\":\"$AGENT_ID\"}"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== [2/5] Get Edge Key ==="
|
||||||
|
EDGE_RESP=$(curl -sf "$BASE/api/v1/agents/$AGENT_ID/key" -H "$H" -H "$ORIGIN")
|
||||||
|
echo "Raw response: $EDGE_RESP"
|
||||||
|
|
||||||
|
EDGE_KEY=$(echo "$EDGE_RESP" | python3 -c "
|
||||||
|
import sys, json
|
||||||
|
d = json.load(sys.stdin)
|
||||||
|
if 'data' in d:
|
||||||
|
print(d['data'].get('edgeKey',''))
|
||||||
|
elif 'edgeKey' in d:
|
||||||
|
print(d['edgeKey'])
|
||||||
|
else:
|
||||||
|
print('')
|
||||||
|
" 2>/dev/null || true)
|
||||||
|
|
||||||
|
if [ -z "$EDGE_KEY" ]; then
|
||||||
|
echo "ERROR: Could not get EDGE_KEY"
|
||||||
|
echo "Response was: $EDGE_RESP"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "EDGE_KEY=$EDGE_KEY"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== [3/5] Save IDs ==="
|
||||||
|
cat > /home/ubuntu/docker/s3-backup/portabase-ids.env << EOF
|
||||||
|
API_KEY=$API_KEY
|
||||||
|
ORG_ID=$ORG_ID
|
||||||
|
AGENT_ID=$AGENT_ID
|
||||||
|
PROJECT_ID=$PROJECT_ID
|
||||||
|
EDGE_KEY=$EDGE_KEY
|
||||||
|
EOF
|
||||||
|
chmod 600 /home/ubuntu/docker/s3-backup/portabase-ids.env
|
||||||
|
echo " Saved to portabase-ids.env"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== [4/5] Deploy agent on bdd-redis-prod ==="
|
||||||
|
BDD_HOST="10.0.0.5"
|
||||||
|
SSH_KEY="/root/.ssh/key_bdd_redis"
|
||||||
|
|
||||||
|
ssh -o StrictHostKeyChecking=no -i "$SSH_KEY" root@"$BDD_HOST" bash -s -- "$EDGE_KEY" << 'AGENT_EOF'
|
||||||
|
EDGE_KEY="$1"
|
||||||
|
|
||||||
|
if ! command -v docker &>/dev/null; then
|
||||||
|
echo " Installing Docker..."
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y -qq ca-certificates curl gnupg lsb-release
|
||||||
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||||
|
systemctl enable --now docker
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p /opt/portabase-agent
|
||||||
|
cd /opt/portabase-agent
|
||||||
|
|
||||||
|
cat > docker-compose.yml << 'COMPOSE'
|
||||||
|
services:
|
||||||
|
portabase-agent:
|
||||||
|
image: portabase/agent:latest
|
||||||
|
container_name: portabase-agent
|
||||||
|
restart: always
|
||||||
|
network_mode: host
|
||||||
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
- TZ=Europe/Paris
|
||||||
|
- DATABASES_CONFIG_FILE=config.toml
|
||||||
|
volumes:
|
||||||
|
- ./databases.toml:/config/config.toml:ro
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- agent-data:/data
|
||||||
|
- agent-tmp:/tmp
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
agent-data:
|
||||||
|
agent-tmp:
|
||||||
|
COMPOSE
|
||||||
|
|
||||||
|
cat > .env << ENVEOF
|
||||||
|
EDGE_KEY=$EDGE_KEY
|
||||||
|
ENVEOF
|
||||||
|
chmod 600 .env
|
||||||
|
|
||||||
|
cat > databases.toml << 'TOML'
|
||||||
|
[[databases]]
|
||||||
|
name = "Production PostgreSQL - gestion_commande_db"
|
||||||
|
database = "gestion_commande_db"
|
||||||
|
type = "postgresql"
|
||||||
|
username = "admin_gestion_commande_db"
|
||||||
|
password = "1SWDxH20rV7K2Uc2PNlwCaCxfVZEtKomF0CK9OMh"
|
||||||
|
port = 5432
|
||||||
|
host = "127.0.0.1"
|
||||||
|
generated_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
|
||||||
|
|
||||||
|
[[databases]]
|
||||||
|
name = "Production Redis"
|
||||||
|
type = "redis"
|
||||||
|
password = "k6UYX9RtuXJVV1HUeefbSukMcSwjvVgRsh2qJGPh"
|
||||||
|
port = 6379
|
||||||
|
host = "127.0.0.1"
|
||||||
|
generated_id = "b2c3d4e5-f6a7-8901-bcde-f12345678901"
|
||||||
|
TOML
|
||||||
|
|
||||||
|
docker compose pull -q 2>/dev/null || true
|
||||||
|
docker compose up -d
|
||||||
|
echo " Agent started"
|
||||||
|
AGENT_EOF
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== [5/5] Wait for agent connection & configure backup ==="
|
||||||
|
echo " Waiting for agent to connect..."
|
||||||
|
for i in $(seq 1 30); do
|
||||||
|
AGENT_RESP=$(curl -sf "$BASE/api/v1/agents/$AGENT_ID" -H "$H" -H "$ORIGIN" 2>/dev/null || true)
|
||||||
|
LAST=$(echo "$AGENT_RESP" | python3 -c "
|
||||||
|
import sys, json
|
||||||
|
d = json.load(sys.stdin)
|
||||||
|
if 'data' in d: d = d['data']
|
||||||
|
print(d.get('lastContact',''))
|
||||||
|
" 2>/dev/null || true)
|
||||||
|
if [ -n "$LAST" ] && [ "$LAST" != "None" ] && [ "$LAST" != "null" ]; then
|
||||||
|
echo " Agent connected (lastContact=$LAST)"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo " Waiting... ($i/30)"
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
echo " Waiting for database detection..."
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
DBS=$(curl -sf "$BASE/api/v1/databases" -H "$H" -H "$ORIGIN" 2>/dev/null || echo '{}')
|
||||||
|
echo " Databases response: $DBS"
|
||||||
|
|
||||||
|
PG_DB_ID=$(echo "$DBS" | python3 -c "
|
||||||
|
import sys, json
|
||||||
|
d = json.load(sys.stdin)
|
||||||
|
dbs = d.get('data', d) if isinstance(d, dict) else d
|
||||||
|
if isinstance(dbs, list):
|
||||||
|
for db in dbs:
|
||||||
|
if db.get('type') == 'postgresql':
|
||||||
|
print(db['id'])
|
||||||
|
break
|
||||||
|
" 2>/dev/null || true)
|
||||||
|
|
||||||
|
if [ -n "$PG_DB_ID" ]; then
|
||||||
|
echo " PostgreSQL detected: $PG_DB_ID"
|
||||||
|
|
||||||
|
curl -sf -X PATCH "$BASE/api/v1/databases/$PG_DB_ID" \
|
||||||
|
-H "$H" -H "$ORIGIN" -H "Content-Type: application/json" \
|
||||||
|
-d "{\"projectId\":\"$PROJECT_ID\"}" > /dev/null 2>&1 || true
|
||||||
|
echo " PostgreSQL attached to project"
|
||||||
|
|
||||||
|
curl -sf -X PUT "$BASE/api/v1/databases/$PG_DB_ID/backup-policy" \
|
||||||
|
-H "$H" -H "$ORIGIN" -H "Content-Type: application/json" \
|
||||||
|
-d '{"cron":"0 2 * * *","retentionCount":30}' > /dev/null 2>&1 || true
|
||||||
|
echo " Schedule: daily backup at 02:00, retention 30"
|
||||||
|
else
|
||||||
|
echo " WARNING: PostgreSQL database not found via API"
|
||||||
|
echo " You may need to configure backup schedule manually in the UI"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "============================================"
|
||||||
|
echo " Portabase setup complete!"
|
||||||
|
echo " Dashboard : $BASE"
|
||||||
|
echo " Agent : bdd-redis-prod (10.0.0.5)"
|
||||||
|
echo " Backup : daily at 02:00 UTC"
|
||||||
|
echo " Retention : 30 backups"
|
||||||
|
echo "============================================"
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
---
|
||||||
|
# ============================================================
|
||||||
|
# Portabase – Dashboard (backup-mln) + Agent (bdd-redis-prod)
|
||||||
|
# ============================================================
|
||||||
|
#
|
||||||
|
# Étape 1 – Déployer le dashboard :
|
||||||
|
# ansible-playbook -i inventory/host.ini infra/playbook-portabase.yml --tags dashboard
|
||||||
|
#
|
||||||
|
# Étape 2 – Ouvrir http://10.0.0.4:8887, créer un compte admin,
|
||||||
|
# puis Organisation > Settings > Agents > créer un agent,
|
||||||
|
# copier l'Edge Key
|
||||||
|
#
|
||||||
|
# Étape 3 – Déployer l'agent :
|
||||||
|
# ansible-playbook -i inventory/host.ini infra/playbook-portabase.yml --tags agent \
|
||||||
|
# -e portabase_edge_key="<EDGE_KEY>"
|
||||||
|
#
|
||||||
|
# Étape 4 – Dans l'UI, ajouter les bases via l'agent (ou laisser
|
||||||
|
# le fichier databases.toml déployé automatiquement)
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
# ════════════════════════════════════════════════════════════
|
||||||
|
# PLAY 1 : Dashboard sur backup-mln
|
||||||
|
# ════════════════════════════════════════════════════════════
|
||||||
|
- name: Déployer Portabase Dashboard
|
||||||
|
hosts: backup-mln
|
||||||
|
become: true
|
||||||
|
gather_facts: true
|
||||||
|
|
||||||
|
vars:
|
||||||
|
portabase_dir: /home/ubuntu/docker/s3-backup
|
||||||
|
portabase_port: 8887
|
||||||
|
docker_dir: ../monitoring/s3-backup
|
||||||
|
docker_compose: ../monitoring/s3-backup/docker-compose.yml
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Déployer docker-compose.yml du dashboard
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ docker_dir }}"
|
||||||
|
dest: "{{ portabase_dir }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0640"
|
||||||
|
notify: Redémarrer Portabase
|
||||||
|
tags: [dashboard]
|
||||||
|
|
||||||
|
- name: Démarrer Portabase Dashboard
|
||||||
|
ansible.builtin.command: docker compose up -d
|
||||||
|
args:
|
||||||
|
chdir: "{{ portabase_dir }}"
|
||||||
|
tags: [dashboard]
|
||||||
|
|
||||||
|
- name: Attendre que le dashboard soit prêt
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "http://127.0.0.1:{{ portabase_port }}/api/health"
|
||||||
|
status_code: 200
|
||||||
|
register: health
|
||||||
|
retries: 15
|
||||||
|
delay: 5
|
||||||
|
until: health.status == 200
|
||||||
|
tags: [dashboard]
|
||||||
|
|
||||||
|
- name: Afficher l'URL du dashboard
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: >-
|
||||||
|
Dashboard Portabase accessible sur http://{{ vpn_ip }}:{{ portabase_port }}
|
||||||
|
— Créer un agent dans l'UI et copier l'Edge Key pour l'étape suivante.
|
||||||
|
tags: [dashboard]
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- name: Redémarrer Portabase
|
||||||
|
ansible.builtin.command: docker compose up -d --force-recreate
|
||||||
|
args:
|
||||||
|
chdir: "{{ docker_dir }}"
|
||||||
|
tags: [dashboard]
|
||||||
|
|
||||||
|
# ════════════════════════════════════════════════════════════
|
||||||
|
# PLAY 2 : Agent sur bdd-redis-prod
|
||||||
|
# ════════════════════════════════════════════════════════════
|
||||||
|
- name: Déployer Portabase Agent
|
||||||
|
hosts: bdd-redis-prod
|
||||||
|
become: true
|
||||||
|
gather_facts: true
|
||||||
|
|
||||||
|
vars:
|
||||||
|
agent_dir: /opt/portabase-agent
|
||||||
|
docker_dir: ../monitoring/bdd-redis-prod-agent
|
||||||
|
docker_compose: ../monitoring/bdd-redis-prod-agent/docker-compose.yml
|
||||||
|
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Vérifier que portabase_edge_key est fourni
|
||||||
|
ansible.builtin.fail:
|
||||||
|
msg: >-
|
||||||
|
Variable 'portabase_edge_key' requise.
|
||||||
|
Relancez avec : -e portabase_edge_key="<EDGE_KEY>"
|
||||||
|
when: portabase_edge_key is not defined or portabase_edge_key == ""
|
||||||
|
tags: [agent]
|
||||||
|
|
||||||
|
# ── Docker (si absent) ──────────────────────────────────
|
||||||
|
- name: Vérifier si Docker est installé
|
||||||
|
ansible.builtin.command: docker --version
|
||||||
|
register: docker_check
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
tags: [agent]
|
||||||
|
|
||||||
|
- name: Créer le répertoire de l'agent
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ agent_dir }}"
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0750"
|
||||||
|
tags: [agent]
|
||||||
|
|
||||||
|
- name: Déployer docker-compose.yml de l'agent
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ docker_compose }}"
|
||||||
|
dest: "{{ agent_dir }}/docker-compose.yml"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0640"
|
||||||
|
notify: Redémarrer l'agent
|
||||||
|
tags: [agent]
|
||||||
|
|
||||||
|
- name: Déployer la configuration des bases de données
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: ../templates/databases.toml
|
||||||
|
dest: "{{ agent_dir }}/databases.toml"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0600"
|
||||||
|
notify: Redémarrer l'agent
|
||||||
|
tags: [agent]
|
||||||
|
|
||||||
|
- name: Déployer la CA interne Portabase (certificat auto-signé du dashboard)
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ docker_dir }}/portabase-ca.pem"
|
||||||
|
dest: "{{ agent_dir }}/portabase-ca.pem"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Redémarrer l'agent
|
||||||
|
tags: [agent]
|
||||||
|
|
||||||
|
- name: Déployer l'Edge Key de l'agent
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "EDGE_KEY={{ portabase_edge_key }}\n"
|
||||||
|
dest: "{{ agent_dir }}/.env"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0600"
|
||||||
|
notify: Redémarrer l'agent
|
||||||
|
tags: [agent]
|
||||||
|
|
||||||
|
- name: Démarrer l'agent Portabase
|
||||||
|
ansible.builtin.command: docker compose up -d
|
||||||
|
args:
|
||||||
|
chdir: "{{ agent_dir }}"
|
||||||
|
tags: [agent]
|
||||||
|
|
||||||
|
- name: Afficher le statut
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: >-
|
||||||
|
Agent Portabase déployé sur {{ inventory_hostname }}.
|
||||||
|
Il se connecte au dashboard via l'Edge Key et poll toutes les 5s.
|
||||||
|
La base {{ db_name }} (PostgreSQL) est configurée.
|
||||||
|
tags: [agent]
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- name: Redémarrer l'agent
|
||||||
|
ansible.builtin.command: docker compose up -d --force-recreate
|
||||||
|
args:
|
||||||
|
chdir: "{{ agent_dir }}"
|
||||||
|
tags: [agent]
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
---
|
||||||
|
# Renouvellement automatique du certificat Let's Encrypt de s3-uber
|
||||||
|
# (uber-stup.club + gitea/ota/rustfs/s3.uber-stup.club, cert partage par le
|
||||||
|
# conteneur nginx s3_nginx).
|
||||||
|
#
|
||||||
|
# Problemes corriges :
|
||||||
|
# - certbot etait configure avec l'authenticator "nginx" (nginx sur l'hote),
|
||||||
|
# or nginx tourne dans Docker et occupe deja le port 80 : le renouvellement
|
||||||
|
# echouait systematiquement ("bind() to 0.0.0.0:80 failed").
|
||||||
|
# - le conteneur sert une COPIE des certs (/home/ubuntu/docker/nginx/certs),
|
||||||
|
# jamais mise a jour depuis /etc/letsencrypt/live.
|
||||||
|
#
|
||||||
|
# Solution : authenticator "standalone" + hooks certbot
|
||||||
|
# pre : arrete s3_nginx (libere le port 80)
|
||||||
|
# deploy : copie fullchain/privkey dans le dossier monte par nginx
|
||||||
|
# post : redemarre s3_nginx (execute meme si le renouvellement echoue)
|
||||||
|
# Coupure ~15 s des services derriere s3_nginx a chaque renouvellement (tous les
|
||||||
|
# ~60 jours, en pleine nuit via certbot.timer).
|
||||||
|
|
||||||
|
- name: Renouvellement automatique du certificat s3-uber
|
||||||
|
hosts: s3-uber
|
||||||
|
become: true
|
||||||
|
gather_facts: false
|
||||||
|
|
||||||
|
vars:
|
||||||
|
nginx_container: s3_nginx
|
||||||
|
nginx_certs_dir: /home/ubuntu/docker/nginx/certs
|
||||||
|
cert_owner: ubuntu
|
||||||
|
cert_group: docker
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Creer les dossiers de hooks certbot
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "/etc/letsencrypt/renewal-hooks/{{ item }}"
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
loop: [pre, deploy, post]
|
||||||
|
|
||||||
|
- name: Hook pre - arreter nginx pour liberer le port 80
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/letsencrypt/renewal-hooks/pre/stop-nginx.sh
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
content: |
|
||||||
|
#!/bin/bash
|
||||||
|
docker stop {{ nginx_container }}
|
||||||
|
|
||||||
|
- name: Hook deploy - copier le cert renouvele pour nginx
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/letsencrypt/renewal-hooks/deploy/copy-to-nginx.sh
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
content: |
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
install -o {{ cert_owner }} -g {{ cert_group }} -m 0644 "$RENEWED_LINEAGE/fullchain.pem" {{ nginx_certs_dir }}/fullchain.pem
|
||||||
|
install -o {{ cert_owner }} -g {{ cert_group }} -m 0640 "$RENEWED_LINEAGE/privkey.pem" {{ nginx_certs_dir }}/privkey.pem
|
||||||
|
|
||||||
|
- name: Hook post - redemarrer nginx (meme si le renouvellement echoue)
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/letsencrypt/renewal-hooks/post/start-nginx.sh
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
content: |
|
||||||
|
#!/bin/bash
|
||||||
|
docker start {{ nginx_container }}
|
||||||
|
|
||||||
|
- name: Passer l'authenticator certbot en standalone
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/letsencrypt/renewal/uber-stup.club.conf
|
||||||
|
regexp: "^authenticator\\s*="
|
||||||
|
line: "authenticator = standalone"
|
||||||
|
|
||||||
|
- name: Retirer l'installer nginx (nginx n'est plus sur l'hote)
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/letsencrypt/renewal/uber-stup.club.conf
|
||||||
|
regexp: "^installer\\s*="
|
||||||
|
line: "installer = None"
|
||||||
Executable
+99
@@ -0,0 +1,99 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
BASE="http://10.0.0.4"
|
||||||
|
SESSION_COOKIE=""
|
||||||
|
API_KEY=""
|
||||||
|
|
||||||
|
# ── 1. Login et création API key ─────────────────────────────
|
||||||
|
echo "[1/7] Login..."
|
||||||
|
RESP=$(curl -sf -D- -X POST "$BASE/api/auth/sign-in/email" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"email":"admin@portabase.local","password":"Admin@Portabase2026!"}')
|
||||||
|
|
||||||
|
SESSION_COOKIE=$(echo "$RESP" | grep -oP 'better-auth\.session_token=[^;]+')
|
||||||
|
echo " Session OK"
|
||||||
|
|
||||||
|
echo "[2/7] Création API key..."
|
||||||
|
KEY_RESP=$(curl -sf -X POST "$BASE/api/auth/api-key/create" \
|
||||||
|
-b "$SESSION_COOKIE" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"name":"automation","expiresIn":null}')
|
||||||
|
|
||||||
|
API_KEY=$(echo "$KEY_RESP" | python3 -c "import sys,json; print(json.load(sys.stdin).get('key',''))" 2>/dev/null || true)
|
||||||
|
|
||||||
|
if [ -z "$API_KEY" ]; then
|
||||||
|
echo " Endpoint api-key/create indisponible, insertion directe en DB..."
|
||||||
|
API_KEY="pb_$(openssl rand -hex 24)"
|
||||||
|
HASHED=$(echo -n "$API_KEY" | sha256sum | awk '{print $1}')
|
||||||
|
PREFIX=$(echo "$API_KEY" | cut -c1-7)
|
||||||
|
START=$(echo "$API_KEY" | cut -c1-10)
|
||||||
|
USER_ID=$(docker exec portabase-pg psql -U portabase -d portabase -tAc "SELECT id FROM \"user\" WHERE role='superadmin' LIMIT 1;")
|
||||||
|
|
||||||
|
docker exec portabase-pg psql -U portabase -d portabase -c "
|
||||||
|
INSERT INTO apikey (id, name, start, prefix, key, reference_id, enabled, rate_limit_enabled, request_count, remaining, created_at, updated_at)
|
||||||
|
VALUES (gen_random_uuid(), 'automation', '$START', '$PREFIX', '$HASHED', '$USER_ID', true, false, 0, NULL, NOW(), NOW());"
|
||||||
|
echo " API key créée en DB"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo " API_KEY=$API_KEY"
|
||||||
|
H="x-api-key: $API_KEY"
|
||||||
|
|
||||||
|
# ── 2. Organisation ──────────────────────────────────────────
|
||||||
|
echo "[3/7] Création organisation..."
|
||||||
|
ORG=$(curl -sf -X POST "$BASE/api/v1/organizations" \
|
||||||
|
-H "$H" -H "Content-Type: application/json" \
|
||||||
|
-d '{"name":"Production","description":"Backup infrastructure"}')
|
||||||
|
ORG_ID=$(echo "$ORG" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||||
|
echo " org_id=$ORG_ID"
|
||||||
|
|
||||||
|
# ── 3. Agent ─────────────────────────────────────────────────
|
||||||
|
echo "[4/7] Création agent..."
|
||||||
|
AGENT=$(curl -sf -X POST "$BASE/api/v1/agents" \
|
||||||
|
-H "$H" -H "Content-Type: application/json" \
|
||||||
|
-d '{"name":"bdd-redis-prod","description":"PostgreSQL + Redis on 10.0.0.5"}')
|
||||||
|
AGENT_ID=$(echo "$AGENT" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||||
|
echo " agent_id=$AGENT_ID"
|
||||||
|
|
||||||
|
# Attacher l'agent à l'organisation
|
||||||
|
curl -sf -X POST "$BASE/api/v1/organizations/$ORG_ID/agents" \
|
||||||
|
-H "$H" -H "Content-Type: application/json" \
|
||||||
|
-d "{\"agentId\":\"$AGENT_ID\"}" > /dev/null
|
||||||
|
echo " Agent attaché à l'organisation"
|
||||||
|
|
||||||
|
# Récupérer l'Edge Key
|
||||||
|
EDGE_KEY=$(curl -sf "$BASE/api/v1/agents/$AGENT_ID/key" -H "$H" | python3 -c "import sys,json; print(json.load(sys.stdin)['edgeKey'])")
|
||||||
|
echo " EDGE_KEY=$EDGE_KEY"
|
||||||
|
|
||||||
|
# ── 4. Projet ────────────────────────────────────────────────
|
||||||
|
echo "[5/7] Création projet..."
|
||||||
|
PROJECT=$(curl -sf -X POST "$BASE/api/v1/organizations/$ORG_ID/projects" \
|
||||||
|
-H "$H" -H "Content-Type: application/json" \
|
||||||
|
-d '{"name":"Backup DB Prod","description":"Sauvegarde quotidienne PostgreSQL + Redis"}')
|
||||||
|
PROJECT_ID=$(echo "$PROJECT" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||||
|
echo " project_id=$PROJECT_ID"
|
||||||
|
|
||||||
|
# ── 5. Sauvegarder les infos ─────────────────────────────────
|
||||||
|
echo "[6/7] Sauvegarde des identifiants..."
|
||||||
|
cat > /home/ubuntu/docker/s3-backup/portabase-ids.env << EOF
|
||||||
|
API_KEY=$API_KEY
|
||||||
|
ORG_ID=$ORG_ID
|
||||||
|
AGENT_ID=$AGENT_ID
|
||||||
|
PROJECT_ID=$PROJECT_ID
|
||||||
|
EDGE_KEY=$EDGE_KEY
|
||||||
|
EOF
|
||||||
|
chmod 600 /home/ubuntu/docker/s3-backup/portabase-ids.env
|
||||||
|
|
||||||
|
echo "[7/7] Résumé"
|
||||||
|
echo "============================================"
|
||||||
|
echo " Dashboard : $BASE"
|
||||||
|
echo " API Key : $API_KEY"
|
||||||
|
echo " Org ID : $ORG_ID"
|
||||||
|
echo " Agent ID : $AGENT_ID"
|
||||||
|
echo " Project ID : $PROJECT_ID"
|
||||||
|
echo " Edge Key : $EDGE_KEY"
|
||||||
|
echo ""
|
||||||
|
echo " IDs sauvegardés dans : /home/ubuntu/docker/s3-backup/portabase-ids.env"
|
||||||
|
echo ""
|
||||||
|
echo " Prochaine étape : déployer l'agent sur bdd-redis-prod avec cette EDGE_KEY"
|
||||||
|
echo "============================================"
|
||||||
@@ -19,22 +19,3 @@ backend_local_port: 8080
|
|||||||
backend_port: 80
|
backend_port: 80
|
||||||
nginx_proxy_timeout: 60
|
nginx_proxy_timeout: 60
|
||||||
nginx_max_body_size: "10M"
|
nginx_max_body_size: "10M"
|
||||||
|
|
||||||
# Sauvegarde Postgres (Plakar) — prod/playbook-backup.yml
|
|
||||||
plakar_version: "1.1.4"
|
|
||||||
plakar_go_version: "1.24.0"
|
|
||||||
plakar_backup_user: plakar-backup
|
|
||||||
plakar_home_dir: /var/lib/plakar-backup
|
|
||||||
plakar_dump_dir: /var/lib/plakar-backup/dumps
|
|
||||||
plakar_config_dir: /etc/plakar-backup
|
|
||||||
plakar_passphrase_file: /etc/plakar-backup/passphrase
|
|
||||||
|
|
||||||
# Dépôt Plakar (Kloset) distant — stocké sur MinIO via S3
|
|
||||||
plakar_store_name: minio-backup
|
|
||||||
plakar_s3_endpoint: "10.0.0.4:8080"
|
|
||||||
plakar_s3_bucket: backup-db-prod-mln
|
|
||||||
plakar_s3_prefix: postgresql
|
|
||||||
plakar_s3_access_key: admin
|
|
||||||
plakar_s3_secret_key: "admin@12345"
|
|
||||||
plakar_s3_use_tls: true
|
|
||||||
plakar_email: "free6nk33@gmail.com"
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Utilisé par hardening/playbook-ssh-hardenning.yml — même convention que
|
||||||
|
# group_vars/omnex-prod (mot de passe sudo identique au reste de la flotte).
|
||||||
|
user_ssh: "omnex"
|
||||||
|
group_ssh: "ssh"
|
||||||
|
password_user_ssh: "$6$w6GBkTHgj8K84P7o$pToS4pRMGLKwfpRfnz6i.WpO72Lt5DLtFQWZJsKL2dKvQrdKdi2q8xRuWqq/W3ybFNLQapvAqN33HexVjajGw0" #aiQgIAcCVIy1E33ReRssfm414dm
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Utilisé par infra/playbook-harden-ssh.yml
|
||||||
|
user_ssh: "omnex"
|
||||||
|
group_ssh: "ssh"
|
||||||
|
password_user_ssh: "$6$w6GBkTHgj8K84P7o$pToS4pRMGLKwfpRfnz6i.WpO72Lt5DLtFQWZJsKL2dKvQrdKdi2q8xRuWqq/W3ybFNLQapvAqN33HexVjajGw0" #aiQgIAcCVIy1E33ReRssfm414dm
|
||||||
@@ -33,7 +33,16 @@ monitoring-uber ansible_host=185.103.167.138 ansible_user=omnex ansible_ssh_priv
|
|||||||
vpn-uber ansible_host=131.123.42.158 ansible_user=omnex ansible_ssh_private_key_file=.ssh/omnex vpn_ip=10.0.0.1 ansible_become_pass=aiQgIAcCVIy1E33ReRssfm414dm
|
vpn-uber ansible_host=131.123.42.158 ansible_user=omnex ansible_ssh_private_key_file=.ssh/omnex vpn_ip=10.0.0.1 ansible_become_pass=aiQgIAcCVIy1E33ReRssfm414dm
|
||||||
backup-mln ansible_host=85.121.176.241 ansible_user=root ansible_ssh_private_key_file=.ssh/key_backup vpn_ip=10.0.0.4
|
backup-mln ansible_host=85.121.176.241 ansible_user=root ansible_ssh_private_key_file=.ssh/key_backup vpn_ip=10.0.0.4
|
||||||
|
|
||||||
|
[omnex-prod]
|
||||||
|
omnex-prod ansible_host=132.243.166.157 ansible_user=omnex ansible_ssh_private_key_file=.ssh/omnex ansible_become_pass=aiQgIAcCVIy1E33ReRssfm414dm
|
||||||
|
|
||||||
[infra:children]
|
[infra:children]
|
||||||
infra-monitoring-security
|
infra-monitoring-security
|
||||||
infra-runner
|
infra-runner
|
||||||
infra-utils
|
infra-utils
|
||||||
|
|
||||||
|
[k3s-prod]
|
||||||
|
master-k3s ansible_host=176.116.0.189 ansible_user=omnex ansible_ssh_private_key_file=.ssh/omnex ansible_become_pass=aiQgIAcCVIy1E33ReRssfm414dm
|
||||||
|
slave-1-k3s ansible_host=93.185.167.134 ansible_user=omnex ansible_ssh_private_key_file=.ssh/omnex ansible_become_pass=aiQgIAcCVIy1E33ReRssfm414dm
|
||||||
|
slave-2-k3s ansible_host=185.139.215.125 ansible_user=omnex ansible_ssh_private_key_file=.ssh/omnex ansible_become_pass=aiQgIAcCVIy1E33ReRssfm414dm
|
||||||
|
slave-3-k3s ansible_host=5.252.20.74 ansible_user=omnex ansible_ssh_private_key_file=.ssh/omnex ansible_become_pass=aiQgIAcCVIy1E33ReRssfm414dm
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
services:
|
||||||
|
portabase-agent:
|
||||||
|
image: portabase/agent:latest
|
||||||
|
container_name: portabase-agent
|
||||||
|
restart: always
|
||||||
|
network_mode: host
|
||||||
|
env_file: .env
|
||||||
|
entrypoint: ["sh", "-c", "update-ca-certificates && exec /entrypoint.sh"]
|
||||||
|
environment:
|
||||||
|
- TZ=Europe/Paris
|
||||||
|
- DATABASES_CONFIG_FILE=config.toml
|
||||||
|
volumes:
|
||||||
|
- ./databases.toml:/config/config.toml:ro
|
||||||
|
- ./portabase-ca.pem:/usr/local/share/ca-certificates/portabase-ca.crt:ro
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- agent-data:/data
|
||||||
|
- agent-tmp:/tmp
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
agent-data:
|
||||||
|
agent-tmp:
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDMTCCAhmgAwIBAgIUB8Gk3zRJRK0QDqPNiZeRgkszE3gwDQYJKoZIhvcNAQEL
|
||||||
|
BQAwIDEeMBwGA1UEAwwVUG9ydGFiYXNlIEludGVybmFsIENBMB4XDTI2MTAxNDE4
|
||||||
|
MTIxNloXDTM2MTAxMTE4MTIxNlowIDEeMBwGA1UEAwwVUG9ydGFiYXNlIEludGVy
|
||||||
|
bmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAto+OO/LBNdM9
|
||||||
|
Lp+JgkNZPQ3/u1nlXSvkz1OFwEM+EHxnAerGAY7zFykR7XKygMcVztKP38AIR779
|
||||||
|
/QN0Lavc1wAEQ2Pf/wPrAa6sfshbiJdbkMsmmsRdBTdiw/jHtX9x73rlQgCqRhEI
|
||||||
|
HPbv//abKpB3Z1F3idS1zoFcN2KgABQiR/g1VuSHLzYmrpvvxEOtNFW6dcldtdHH
|
||||||
|
k0j8JiQWCehziOmdbe5dlrO5B/SzCbPKGvgZBE/RVP1sbYy/QhG273zekidYWp7r
|
||||||
|
HgAOgEg5x7JjO+ID7T2ClDZG0CgIn5Qrs9/FaMHfzVYLR/+wnvn+DzRuez96d9Ol
|
||||||
|
qt9SfzSH1QIDAQABo2MwYTAdBgNVHQ4EFgQU/D2ZdNhuSaZi80ch9BEYue3Deesw
|
||||||
|
HwYDVR0jBBgwFoAU/D2ZdNhuSaZi80ch9BEYue3DeeswDwYDVR0TAQH/BAUwAwEB
|
||||||
|
/zAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggEBAI6yP69LA4shWw5I
|
||||||
|
uUEOYkq3uHsawlb2XshPy9FAom1lXSyLsaiznwpN0R+aX1787dWAhJz169iH7kSx
|
||||||
|
AAxMVq26o2+TwBAhvortB+Cel5iNB2Qi4fq3Abky/bla4br3+qNZ5JQkimcgK2OE
|
||||||
|
PHGT1cJHLcG5fk6VK4mWpHZBJpRqDuF+21eOapywObBOjDoYl56iPp/vZSTnIvxn
|
||||||
|
qniRJdFQf/itXVKlNeJl/H3q1DKrFZL96yFPkImxi+4O9lter/1l1Jp3RP5cx59K
|
||||||
|
49X0qj91TiNG+v/P9TtjGzCzwlXojB0zeoJjjmB6BWaOfjLm7FvvZm3DMO6W7DyP
|
||||||
|
xlh0tQs=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
@@ -30,3 +30,6 @@ PRIVATE_KEY_MOBILE_PREPROD=LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2Z0lCQURBT
|
|||||||
ADMIN_PASSWORD_MOBILE_PREPROD=thxz419zFmNdh547A3vrQE1v
|
ADMIN_PASSWORD_MOBILE_PREPROD=thxz419zFmNdh547A3vrQE1v
|
||||||
UPLOAD_KEY_MOBILE_PREPROD=8f65a01120509b149f3a781b139391272519041b
|
UPLOAD_KEY_MOBILE_PREPROD=8f65a01120509b149f3a781b139391272519041b
|
||||||
POSTGRES_PASS_MOBILE_PREPROD=uS6K8V54JeUHOYsbEDdbIt
|
POSTGRES_PASS_MOBILE_PREPROD=uS6K8V54JeUHOYsbEDdbIt
|
||||||
|
|
||||||
|
RUSTFS_ACCESS_KEY=iBacJPHUHSf6SMTnxrr
|
||||||
|
RUSTFS_SECRET_KEY=4jNzZhstv1WkwTwtvR4gHSbrx01m4sJl4LBBleeJ
|
||||||
|
|||||||
@@ -168,6 +168,33 @@ services:
|
|||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|
||||||
|
rustfs_perm:
|
||||||
|
image: alpine:latest
|
||||||
|
container_name: rustfs_perm
|
||||||
|
volumes:
|
||||||
|
- /mnt/data:/data
|
||||||
|
command: chown -R 10001:10001 /data
|
||||||
|
|
||||||
|
rustfs:
|
||||||
|
image: rustfs/rustfs:latest
|
||||||
|
depends_on:
|
||||||
|
rustfs_perm:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
hostname: rustfs
|
||||||
|
container_name: rustfs
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- /mnt/data:/data
|
||||||
|
- /mnt/logs:/logs
|
||||||
|
environment:
|
||||||
|
- RUSTFS_ACCESS_KEY=${RUSTFS_ACCESS_KEY:-iBacJPHUHSf6SMTnxrr}
|
||||||
|
- RUSTFS_SECRET_KEY=${RUSTFS_SECRET_KEY:-4jNzZhstv1WkwTwtvR4gHSbrx01m4sJl4LBBleeJ}
|
||||||
|
- RUSTFS_SERVER_DOMAINS=rustfs.uber-stup.club
|
||||||
|
- RUSTFS_CONSOLE_ENABLE=true
|
||||||
|
- RUSTFS_ADDRESS=:9000
|
||||||
|
- RUSTFS_CONSOLE_ADDRESS=:9001
|
||||||
|
networks:
|
||||||
|
- ota-net
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
container_name: ota-nginx
|
container_name: ota-nginx
|
||||||
@@ -188,6 +215,7 @@ services:
|
|||||||
- ota-omnex-admin
|
- ota-omnex-admin
|
||||||
- ota-mobile-prod
|
- ota-mobile-prod
|
||||||
- ota-mobile-preprod
|
- ota-mobile-preprod
|
||||||
|
- rustfs
|
||||||
|
|
||||||
dozzle-agent:
|
dozzle-agent:
|
||||||
image: amir20/dozzle:latest
|
image: amir20/dozzle:latest
|
||||||
@@ -210,3 +238,4 @@ volumes:
|
|||||||
ota_mobile_prod_releases:
|
ota_mobile_prod_releases:
|
||||||
ota_mobile_preprod_releases:
|
ota_mobile_preprod_releases:
|
||||||
certbot_www:
|
certbot_www:
|
||||||
|
rustfs:
|
||||||
|
|||||||
@@ -166,3 +166,61 @@ server {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
listen [::]:443 ssl;
|
||||||
|
http2 on;
|
||||||
|
server_name backup-omnex.uber-stup.club;
|
||||||
|
|
||||||
|
ssl_certificate /etc/nginx/certs/backup-omnex.uber-stup.club.crt;
|
||||||
|
ssl_certificate_key /etc/nginx/certs/backup-omnex.uber-stup.club.key;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/rustfs_access.log;
|
||||||
|
error_log /var/log/nginx/rustfs_error.log;
|
||||||
|
|
||||||
|
resolver 127.0.0.11 valid=30s;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
set $upstream http://rustfs:9001;
|
||||||
|
proxy_pass $upstream;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_read_timeout 300s;
|
||||||
|
client_max_body_size 500m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name backup-s3.uber-stup.club;
|
||||||
|
|
||||||
|
ssl_certificate /etc/nginx/certs/backup-s3.uber-stup.club.crt;
|
||||||
|
ssl_certificate_key /etc/nginx/certs/backup-s3.uber-stup.club.key;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/rustfs_s3_access.log;
|
||||||
|
error_log /var/log/nginx/rustfs_s3_error.log;
|
||||||
|
|
||||||
|
resolver 127.0.0.11 valid=30s;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
set $upstream http://rustfs:9000;
|
||||||
|
proxy_pass $upstream;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_read_timeout 300s;
|
||||||
|
client_max_body_size 2g;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ docker run --rm \
|
|||||||
certbot/certbot renew --webroot -w /var/www/certbot --quiet
|
certbot/certbot renew --webroot -w /var/www/certbot --quiet
|
||||||
|
|
||||||
changed=0
|
changed=0
|
||||||
for sub in ota-prod ota-preprod ota-omnex-cli ota-omnex-admin ota-mobile-prod ota-mobile-preprod; do
|
for sub in ota-prod ota-preprod ota-omnex-cli ota-omnex-admin ota-mobile-prod ota-mobile-preprod backup-omnex backup-s3; do
|
||||||
domain="${sub}.uber-stup.club"
|
domain="${sub}.uber-stup.club"
|
||||||
if ! docker run --rm -v ota_certbot_letsencrypt:/etc/letsencrypt -v /opt/ota/certs:/out alpine \
|
if ! docker run --rm -v ota_certbot_letsencrypt:/etc/letsencrypt -v /opt/ota/certs:/out alpine \
|
||||||
sh -c "cmp -s /etc/letsencrypt/live/${domain}/fullchain.pem /out/${domain}.crt"; then
|
sh -c "cmp -s /etc/letsencrypt/live/${domain}/fullchain.pem /out/${domain}.crt"; then
|
||||||
|
|||||||
@@ -1,2 +1,15 @@
|
|||||||
RUSTFS_ACCESS_KEY=iBacJPHUHSf6SMTnxrr
|
PROJECT_URL=https://10.0.0.4
|
||||||
RUSTFS_SECRET_KEY=4jNzZhstv1WkwTwtvR4gHSbrx01m4sJl4LBBleeJ
|
PROJECT_SECRET=dOkGZW0Iz+Ga8hBAttU+TlOf/RYwTe0txz7fyGzINzI=
|
||||||
|
POSTGRES_USER=portabase
|
||||||
|
POSTGRES_PASSWORD=8BIAtiI580SzvupmKWW
|
||||||
|
POSTGRES_HOST=db
|
||||||
|
POSTGRES_PORT=5432
|
||||||
|
POSTGRES_DB=portabase
|
||||||
|
DATABASE_URL=postgresql://portabase:8BIAtiI580SzvupmKWW@db:5432/portabase?schema=public
|
||||||
|
SKIP_ONBOARDING=true
|
||||||
|
API_ENABLED=true
|
||||||
|
AUTH_DEFAULT_USER_NAME=admin
|
||||||
|
AUTH_DEFAULT_USER=admin@portabase.local
|
||||||
|
AUTH_DEFAULT_PASSWORD=Admin@Portabase2026!
|
||||||
|
OPENAPI_ENABLED=true
|
||||||
|
TRUSTED_DOMAINS=https://10.0.0.4
|
||||||
|
|||||||
@@ -5,31 +5,54 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "10.0.0.4:80:80"
|
- "10.0.0.4:80:80"
|
||||||
- "10.0.0.4:8080:8080"
|
- "10.0.0.4:443:443"
|
||||||
- "10.0.0.4:9000:9000"
|
|
||||||
- "10.0.0.4:9001:9001"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
- ./certs:/etc/nginx/certs:ro
|
- ./certs:/etc/nginx/certs:ro
|
||||||
- nginx_logs:/var/log/nginx
|
- nginx_logs:/var/log/nginx
|
||||||
depends_on:
|
depends_on:
|
||||||
- minio
|
- portabase
|
||||||
networks:
|
networks:
|
||||||
- s3_net
|
- s3_net
|
||||||
|
|
||||||
minio:
|
portabase:
|
||||||
image: minio/minio:latest
|
image: portabase/portabase:latest
|
||||||
container_name: s3_minio
|
container_name: portabase-app
|
||||||
restart: unless-stopped
|
restart: always
|
||||||
hostname: minio
|
env_file: .env
|
||||||
volumes:
|
|
||||||
- /mnt/data:/data
|
|
||||||
environment:
|
environment:
|
||||||
- MINIO_ROOT_USER=admin
|
- TZ=Europe/Paris
|
||||||
- MINIO_ROOT_PASSWORD=admin@12345
|
expose:
|
||||||
- MINIO_ADDRESS=:9000
|
- "80"
|
||||||
- MINIO_CONSOLE_ADDRESS=:9001
|
volumes:
|
||||||
command: minio server /data --console-address :9001
|
- portabase-data:/data
|
||||||
|
depends_on:
|
||||||
|
db:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost/api/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
start_period: 60s
|
||||||
|
networks:
|
||||||
|
- s3_net
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
container_name: portabase-pg
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- postgres-data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: portabase
|
||||||
|
POSTGRES_USER: portabase
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U portabase -d portabase"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
networks:
|
networks:
|
||||||
- s3_net
|
- s3_net
|
||||||
|
|
||||||
@@ -102,3 +125,5 @@ volumes:
|
|||||||
clamav_db:
|
clamav_db:
|
||||||
clamav_logs:
|
clamav_logs:
|
||||||
clamav_scan_logs:
|
clamav_scan_logs:
|
||||||
|
portabase-data:
|
||||||
|
postgres-data:
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ events {
|
|||||||
http {
|
http {
|
||||||
resolver 127.0.0.11 valid=10s ipv6=off;
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||||
|
|
||||||
# ── MinIO Console GUI HTTPS (VPN: 10.0.0.4:8080) ────────
|
# ── Portabase Dashboard HTTPS (VPN: 10.0.0.4:443) ───────
|
||||||
server {
|
server {
|
||||||
listen 8080 ssl;
|
listen 443 ssl;
|
||||||
server_name 10.0.0.4 _;
|
server_name 10.0.0.4 _;
|
||||||
|
|
||||||
ssl_certificate /etc/nginx/certs/cert.pem;
|
ssl_certificate /etc/nginx/certs/cert.pem;
|
||||||
@@ -17,11 +17,19 @@ http {
|
|||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||||
|
|
||||||
access_log /var/log/nginx/minio_console_access.log;
|
access_log /var/log/nginx/portabase_access.log;
|
||||||
error_log /var/log/nginx/minio_console_error.log;
|
error_log /var/log/nginx/portabase_error.log;
|
||||||
|
|
||||||
|
location /api/v1 {
|
||||||
|
return 403;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /openapi {
|
||||||
|
return 403;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://minio:9001;
|
proxy_pass http://portabase:80;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
@@ -31,7 +39,7 @@ http {
|
|||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
proxy_read_timeout 300s;
|
proxy_read_timeout 300s;
|
||||||
client_max_body_size 500m;
|
client_max_body_size 50m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,56 +48,7 @@ http {
|
|||||||
listen 80;
|
listen 80;
|
||||||
server_name _;
|
server_name _;
|
||||||
location / {
|
location / {
|
||||||
return 301 https://$host:8080$request_uri;
|
return 301 https://$host$request_uri;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ── MinIO Console Direct HTTPS (VPN: 10.0.0.4:9001) ──────
|
|
||||||
server {
|
|
||||||
listen 9001 ssl;
|
|
||||||
server_name 10.0.0.4 _;
|
|
||||||
|
|
||||||
ssl_certificate /etc/nginx/certs/cert.pem;
|
|
||||||
ssl_certificate_key /etc/nginx/certs/key.pem;
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
|
||||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
||||||
|
|
||||||
access_log /var/log/nginx/minio_console_direct_access.log;
|
|
||||||
error_log /var/log/nginx/minio_console_direct_error.log;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://minio:9001;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto https;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "upgrade";
|
|
||||||
proxy_buffering off;
|
|
||||||
proxy_read_timeout 300s;
|
|
||||||
client_max_body_size 500m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ── MinIO S3 API HTTP (VPN: 10.0.0.4:9000) ────────────────
|
|
||||||
server {
|
|
||||||
listen 9000;
|
|
||||||
server_name 10.0.0.4 _;
|
|
||||||
|
|
||||||
access_log /var/log/nginx/minio_s3_api_access.log;
|
|
||||||
error_log /var/log/nginx/minio_s3_api_error.log;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://minio:9000;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Host $http_host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto http;
|
|
||||||
proxy_buffering off;
|
|
||||||
proxy_read_timeout 300s;
|
|
||||||
client_max_body_size 2g;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,6 @@
|
|||||||
|
# RustFS
|
||||||
RUSTFS_ACCESS_KEY=JJg3uFeuKUUrdqq4oefQ8sIp6hnI
|
RUSTFS_ACCESS_KEY=JJg3uFeuKUUrdqq4oefQ8sIp6hnI
|
||||||
RUSTFS_SECRET_KEY=7wPrOd1324t411q7VnuzfNkQXCch4U5qqOHx
|
RUSTFS_SECRET_KEY=7wPrOd1324t411q7VnuzfNkQXCch4U5qqOHx
|
||||||
|
|
||||||
|
# Portabase Agent
|
||||||
|
EDGE_KEY=<A_REMPLIR>
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[[databases]]
|
||||||
|
name = "Production PostgreSQL - gestion_commande_db"
|
||||||
|
database = "gestion_commande_db"
|
||||||
|
type = "postgresql"
|
||||||
|
username = "admin_gestion_commande_db"
|
||||||
|
password = "1SWDxH20rV7K2Uc2PNlwCaCxfVZEtKomF0CK9OMh"
|
||||||
|
port = 5432
|
||||||
|
host = "127.0.0.1"
|
||||||
|
generated_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
|
||||||
@@ -45,6 +45,21 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- s3_net
|
- s3_net
|
||||||
|
|
||||||
|
portabase-agent:
|
||||||
|
image: portabase/agent:latest
|
||||||
|
container_name: portabase-agent
|
||||||
|
restart: always
|
||||||
|
network_mode: host
|
||||||
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
- TZ=Europe/Paris
|
||||||
|
- DATABASES_CONFIG_FILE=config.toml
|
||||||
|
volumes:
|
||||||
|
- ./databases.toml:/config/config.toml:ro
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- agent-data:/data
|
||||||
|
- agent-tmp:/tmp
|
||||||
|
|
||||||
dozzle-agent:
|
dozzle-agent:
|
||||||
image: amir20/dozzle:latest
|
image: amir20/dozzle:latest
|
||||||
command: agent
|
command: agent
|
||||||
@@ -60,3 +75,5 @@ networks:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
nginx_logs:
|
nginx_logs:
|
||||||
|
agent-data:
|
||||||
|
agent-tmp:
|
||||||
|
|||||||
@@ -1,52 +1,34 @@
|
|||||||
|
|
||||||
worker_processes auto;
|
worker_processes auto;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
resolver 127.0.0.11 valid=10s ipv6=off;
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name _;
|
server_name _;
|
||||||
return 301 http://$host:9001$request_uri;
|
|
||||||
}
|
|
||||||
# ── RustFS Console ──────────────────────────────────────
|
|
||||||
server {
|
|
||||||
listen 9001;
|
|
||||||
server_name _;
|
|
||||||
access_log /var/log/nginx/rustfs_access.log;
|
|
||||||
error_log /var/log/nginx/rustfs_error.log;
|
|
||||||
location / {
|
|
||||||
set $upstream http://rustfs:9001;
|
|
||||||
proxy_pass $upstream;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "upgrade";
|
|
||||||
proxy_read_timeout 300s;
|
|
||||||
client_max_body_size 500m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ── RustFS S3 API ───────────────────────────────────────
|
access_log /var/log/nginx/portabase_access.log;
|
||||||
server {
|
error_log /var/log/nginx/portabase_error.log;
|
||||||
listen 9000;
|
|
||||||
server_name _;
|
|
||||||
access_log /var/log/nginx/rustfs_s3_access.log;
|
|
||||||
error_log /var/log/nginx/rustfs_s3_error.log;
|
|
||||||
location / {
|
location / {
|
||||||
set $upstream http://rustfs:9000;
|
proxy_pass http://portabase:80;
|
||||||
proxy_pass $upstream;
|
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $http_host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_cache_convert_head off;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
proxy_read_timeout 300s;
|
proxy_read_timeout 300s;
|
||||||
|
proxy_send_timeout 300s;
|
||||||
client_max_body_size 2g;
|
client_max_body_size 2g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,2 @@
|
|||||||
RUSTFS_ACCESS_KEY=iBacJPHUHSf6SMTnxrr
|
RUSTFS_ACCESS_KEY=iBacJPHUHSf6SMTnxrr
|
||||||
RUSTFS_SECRET_KEY=4jNzZhstv1WkwTwtvR4gHSbrx01m4sJl4LBBleeJ
|
RUSTFS_SECRET_KEY=4jNzZhstv1WkwTwtvR4gHSbrx01m4sJl4LBBleeJ
|
||||||
|
|
||||||
XAVIA_ADMIN_PASSWORD=2VYfheOweyMiP510GGfjNYmq3vJGJ
|
|
||||||
XAVIA_UPLOAD_KEY=dNW2tiNXRR6w1cLwlmCOyKFIKvoTz8xQMSyd
|
|
||||||
XAVIA_PRIVATE_KEY_BASE_64=MlRvcGlyNHpFRjhYOTlvUjMxbHFCVHRQdjYyelh4Wnc0MDM4TkZaVQ==
|
|
||||||
XAVIA_POSTGRES_USER=xavia
|
|
||||||
XAVIA_POSTGRES_PASSWORD=6DzLcsb5rgWukuGdrHtRBQ222f
|
|
||||||
XAVIA_POSTGRES_DB=releases_db
|
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ services:
|
|||||||
- nginx_logs:/var/log/nginx
|
- nginx_logs:/var/log/nginx
|
||||||
depends_on:
|
depends_on:
|
||||||
- rustfs
|
- rustfs
|
||||||
- xavia
|
|
||||||
- gitea
|
|
||||||
networks:
|
networks:
|
||||||
- s3_net
|
- s3_net
|
||||||
|
|
||||||
@@ -45,56 +43,6 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- s3_net
|
- s3_net
|
||||||
|
|
||||||
xavia_db:
|
|
||||||
image: postgres:16-alpine
|
|
||||||
container_name: xavia_db
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
- POSTGRES_USER=${XAVIA_POSTGRES_USER:-xavia}
|
|
||||||
- POSTGRES_PASSWORD=${XAVIA_POSTGRES_PASSWORD}
|
|
||||||
- POSTGRES_DB=${XAVIA_POSTGRES_DB:-releases_db}
|
|
||||||
volumes:
|
|
||||||
- xavia_db_data:/var/lib/postgresql/data
|
|
||||||
- ./init-db:/docker-entrypoint-initdb.d:ro
|
|
||||||
networks:
|
|
||||||
- s3_net
|
|
||||||
|
|
||||||
xavia:
|
|
||||||
image: xaviaio/xavia-ota:latest
|
|
||||||
container_name: xavia
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
- HOST=https://ota.uber-stup.club
|
|
||||||
- BLOB_STORAGE_TYPE=local
|
|
||||||
- DB_TYPE=postgres
|
|
||||||
- ADMIN_PASSWORD=${XAVIA_ADMIN_PASSWORD}
|
|
||||||
- UPLOAD_KEY=${XAVIA_UPLOAD_KEY}
|
|
||||||
- PRIVATE_KEY_BASE_64=${XAVIA_PRIVATE_KEY_BASE_64}
|
|
||||||
- POSTGRES_USER=${XAVIA_POSTGRES_USER:-xavia}
|
|
||||||
- POSTGRES_PASSWORD=${XAVIA_POSTGRES_PASSWORD}
|
|
||||||
- POSTGRES_DB=${XAVIA_POSTGRES_DB:-releases_db}
|
|
||||||
- POSTGRES_HOST=xavia_db
|
|
||||||
- POSTGRES_PORT=5432
|
|
||||||
volumes:
|
|
||||||
- xavia_blobs:/app/blobs
|
|
||||||
depends_on:
|
|
||||||
- xavia_db
|
|
||||||
networks:
|
|
||||||
- s3_net
|
|
||||||
gitea:
|
|
||||||
image: docker.gitea.com/gitea:latest
|
|
||||||
container_name: gitea
|
|
||||||
environment:
|
|
||||||
- USER_UID=1000
|
|
||||||
- USER_GID=1000
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- gitea:/data
|
|
||||||
- /etc/timezone:/etc/timezone:ro
|
|
||||||
- /etc/localtime:/etc/localtime:ro
|
|
||||||
networks:
|
|
||||||
- s3_net
|
|
||||||
|
|
||||||
dozzle-agent:
|
dozzle-agent:
|
||||||
image: amir20/dozzle:latest
|
image: amir20/dozzle:latest
|
||||||
command: agent
|
command: agent
|
||||||
@@ -110,6 +58,3 @@ networks:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
nginx_logs:
|
nginx_logs:
|
||||||
xavia_db_data:
|
|
||||||
xavia_blobs:
|
|
||||||
gitea:
|
|
||||||
|
|||||||
@@ -95,31 +95,4 @@ http {
|
|||||||
client_max_body_size 500m;
|
client_max_body_size 500m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
|
||||||
listen 443 ssl;
|
|
||||||
server_name gitea.uber-stup.club;
|
|
||||||
|
|
||||||
ssl_certificate /etc/nginx/certs/fullchain.pem;
|
|
||||||
ssl_certificate_key /etc/nginx/certs/privkey.pem;
|
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
|
||||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
||||||
|
|
||||||
access_log /var/log/nginx/gitea_access.log;
|
|
||||||
error_log /var/log/nginx/gitea_error.log;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
set $upstream http://gitea:3000;
|
|
||||||
proxy_pass $upstream;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection "upgrade";
|
|
||||||
proxy_read_timeout 300s;
|
|
||||||
client_max_body_size 500m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ Firewall rules for monitoring stack with Wazuh, Dozzle, Beszel, and VPN infrastr
|
|||||||
| 51820 | UDP | Any | WireGuard VPN | ALLOW |
|
| 51820 | UDP | Any | WireGuard VPN | ALLOW |
|
||||||
| 443 | TCP | 10.0.0.0/24 | Wazuh Dashboard (VPN) | ALLOW |
|
| 443 | TCP | 10.0.0.0/24 | Wazuh Dashboard (VPN) | ALLOW |
|
||||||
| 8080 | TCP | 10.0.0.0/24 | Dozzle logs (VPN) | ALLOW |
|
| 8080 | TCP | 10.0.0.0/24 | Dozzle logs (VPN) | ALLOW |
|
||||||
| 8090 | TCP | 10.0.0.0/24 | Beszel monitoring (VPN) | ALLOW |
|
| 8090 | TCP | 10.0.0.0/24 | Beszel dashboard (VPN only, never public) | ALLOW |
|
||||||
| 9000-9001 | TCP | 10.0.0.0/24 | S3/RustFS (VPN) | ALLOW |
|
| 9000-9001 | TCP | 10.0.0.0/24 | S3/RustFS (VPN) | ALLOW |
|
||||||
|
| 10002 | TCP | 176.116.0.189, 93.185.167.134, 185.139.215.125, 5.252.20.74 (k3s-prod, hors VPN) | Beszel agents k3s — `/api/` uniquement, voir nginx.conf | ALLOW |
|
||||||
|
|
||||||
### Outbound Rules (OUTPUT)
|
### Outbound Rules (OUTPUT)
|
||||||
- **Default:** ACCEPT (all traffic allowed)
|
- **Default:** ACCEPT (all traffic allowed)
|
||||||
@@ -138,6 +139,19 @@ Beszel agents installed on all infrastructure servers:
|
|||||||
|
|
||||||
**Note:** vpn-uber agent is accessible **only from VPN** due to firewall rules.
|
**Note:** vpn-uber agent is accessible **only from VPN** due to firewall rules.
|
||||||
|
|
||||||
|
### k3s cluster (reverse direction)
|
||||||
|
|
||||||
|
Unlike the servers above (Hub connects OUT to the agent), the k3s DaemonSet
|
||||||
|
agents connect OUT to the Hub instead — cluster nodes aren't on the VPN mesh
|
||||||
|
and there's no single stable "agent" endpoint per pod to dial into. Hub's
|
||||||
|
reverse-connection port (10002, see nginx.conf) is exposed publicly but
|
||||||
|
restricted to the 4 k3s-prod node IPs + `/api/` path only — the dashboard
|
||||||
|
itself (8090) is never touched by this and stays VPN-only.
|
||||||
|
|
||||||
|
| Server | Type | Direction | Port | Access |
|
||||||
|
|--------|------|-----------|------|--------|
|
||||||
|
| k3s-prod (4 nodes) | Kubernetes DaemonSet | Agent → Hub | 10002 (Hub side) | Hub's public IP, restricted to the 4 node IPs (see `omnex/ansible/inventory/host.ini`) |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ services:
|
|||||||
- "10.0.0.2:8080:8080"
|
- "10.0.0.2:8080:8080"
|
||||||
- "10.0.0.2:8090:8090"
|
- "10.0.0.2:8090:8090"
|
||||||
- "10.0.0.2:3001:3001"
|
- "10.0.0.2:3001:3001"
|
||||||
|
- "10002:10002"
|
||||||
volumes:
|
volumes:
|
||||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
- ./nginx/certs:/etc/nginx/certs:ro
|
- ./nginx/certs:/etc/nginx/certs:ro
|
||||||
@@ -64,6 +65,11 @@ services:
|
|||||||
hostname: wazuh.manager
|
hostname: wazuh.manager
|
||||||
container_name: wazuh_manager
|
container_name: wazuh_manager
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "20m"
|
||||||
|
max-file: "5"
|
||||||
ulimits:
|
ulimits:
|
||||||
memlock:
|
memlock:
|
||||||
soft: -1
|
soft: -1
|
||||||
@@ -123,7 +129,7 @@ services:
|
|||||||
soft: 65536
|
soft: 65536
|
||||||
hard: 65536
|
hard: 65536
|
||||||
environment:
|
environment:
|
||||||
- "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g"
|
- "OPENSEARCH_JAVA_OPTS=-Xms2g -Xmx2g"
|
||||||
- INDEXER_PASSWORD=${WAZUH_INDEXER_PASSWORD}
|
- INDEXER_PASSWORD=${WAZUH_INDEXER_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
- wazuh_indexer_data:/var/lib/wazuh-indexer
|
- wazuh_indexer_data:/var/lib/wazuh-indexer
|
||||||
|
|||||||
@@ -70,6 +70,19 @@ iptables -A INPUT -p tcp --dport 8090 -s 10.0.0.0/24 -j ACCEPT
|
|||||||
iptables -A INPUT -p tcp --dport 9000 -s 10.0.0.0/24 -j ACCEPT
|
iptables -A INPUT -p tcp --dport 9000 -s 10.0.0.0/24 -j ACCEPT
|
||||||
iptables -A INPUT -p tcp --dport 9001 -s 10.0.0.0/24 -j ACCEPT
|
iptables -A INPUT -p tcp --dport 9001 -s 10.0.0.0/24 -j ACCEPT
|
||||||
|
|
||||||
|
# ─── Agents Beszel k3s (10002, hors VPN) ───────────────────────
|
||||||
|
# Nœuds k3s-prod : pas sur le VPN (voir omnex/ansible/inventory/host.ini),
|
||||||
|
# seule voie possible = leur IP publique. Restreint à ces 4 IP précises
|
||||||
|
# (pas 0.0.0.0/0) ; nginx filtre en plus par chemin (/api/ uniquement,
|
||||||
|
# voir nginx.conf) — le dashboard Beszel (8090) reste VPN-only, inchangé.
|
||||||
|
iptables -A INPUT -p tcp --dport 10002 -s 176.116.0.189 -j ACCEPT # master-k3s
|
||||||
|
iptables -A INPUT -p tcp --dport 10002 -s 93.185.167.134 -j ACCEPT # slave-1-k3s
|
||||||
|
iptables -A INPUT -p tcp --dport 10002 -s 185.139.215.125 -j ACCEPT # slave-2-k3s
|
||||||
|
iptables -A INPUT -p tcp --dport 10002 -s 5.252.20.74 -j ACCEPT # slave-3-k3s
|
||||||
|
iptables -A INPUT -p tcp --dport 1514 -s 176.116.0.189 -j ACCEPT # master-k3s
|
||||||
|
iptables -A INPUT -p tcp --dport 1514 -s 93.185.167.134 -j ACCEPT # slave-1-k3s
|
||||||
|
iptables -A INPUT -p tcp --dport 1514 -s 185.139.215.125 -j ACCEPT # slave-2-k3s
|
||||||
|
iptables -A INPUT -p tcp --dport 1514 -s 5.252.20.74 -j ACCEPT # slave-3-k3s
|
||||||
# ─── ICMP ─────────────────────────────────────────────────────
|
# ─── ICMP ─────────────────────────────────────────────────────
|
||||||
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
|
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
|
||||||
iptables -A INPUT -p icmp --icmp-type destination-unreachable -j ACCEPT
|
iptables -A INPUT -p icmp --icmp-type destination-unreachable -j ACCEPT
|
||||||
@@ -95,8 +108,9 @@ echo " • Wazuh 1514/tcp FROM pre-prod (185.103.166.112) — agents Wazuh"
|
|||||||
echo " • VPN 51820/udp — WireGuard"
|
echo " • VPN 51820/udp — WireGuard"
|
||||||
echo " • Wazuh Dashboard 443/tcp FROM 10.0.0.0/24 (VPN)"
|
echo " • Wazuh Dashboard 443/tcp FROM 10.0.0.0/24 (VPN)"
|
||||||
echo " • Dozzle 8080/tcp FROM 10.0.0.0/24 (VPN)"
|
echo " • Dozzle 8080/tcp FROM 10.0.0.0/24 (VPN)"
|
||||||
echo " • Beszel 8090/tcp FROM 10.0.0.0/24 (VPN)"
|
echo " • Beszel 8090/tcp FROM 10.0.0.0/24 (VPN) — dashboard, jamais public"
|
||||||
echo " • S3/RustFS 9000-9001/tcp FROM 10.0.0.0/24 (VPN)"
|
echo " • S3/RustFS 9000-9001/tcp FROM 10.0.0.0/24 (VPN)"
|
||||||
|
echo " • Beszel agents k3s 10002/tcp FROM les 4 IP publiques des nœuds k3s-prod"
|
||||||
echo " • OUTPUT (Internet/DNS)"
|
echo " • OUTPUT (Internet/DNS)"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Règles appliquées (DENY) :"
|
echo "Règles appliquées (DENY) :"
|
||||||
|
|||||||
@@ -59,6 +59,52 @@ http {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ── Beszel agents k3s (10002, public) ────────────────────
|
||||||
|
# Port DÉDIÉ aux agents Beszel du cluster k3s (hors VPN, pas d'autre
|
||||||
|
# moyen de les joindre) — distinct du 8090 (dashboard, VPN uniquement).
|
||||||
|
# Même backend (beszel:8090), mais restreint :
|
||||||
|
# - IP source : uniquement les 4 nœuds k3s (pas 0.0.0.0/0)
|
||||||
|
# - Chemin : uniquement /api/ (enregistrement + heartbeat des agents),
|
||||||
|
# tout le reste (dashboard, admin PocketBase sous /_/) renvoie 403 —
|
||||||
|
# à VÉRIFIER après coup (voir access_log) que les agents n'appellent
|
||||||
|
# pas un chemin hors /api/ non couvert ici.
|
||||||
|
server {
|
||||||
|
listen 10002 ssl;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
ssl_certificate /etc/nginx/certs/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/nginx/certs/privkey.pem;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/beszel_agents_access.log;
|
||||||
|
error_log /var/log/nginx/beszel_agents_error.log;
|
||||||
|
|
||||||
|
# Nœuds k3s-prod (voir omnex/ansible/inventory/host.ini) — aucun
|
||||||
|
# autre client de ce port.
|
||||||
|
allow 176.116.0.189; # master-k3s
|
||||||
|
allow 93.185.167.134; # slave-1-k3s
|
||||||
|
allow 185.139.215.125; # slave-2-k3s
|
||||||
|
allow 5.252.20.74; # slave-3-k3s
|
||||||
|
deny all;
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://beszel:8090;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_read_timeout 3600s;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
return 403;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# ── Wazuh (443) ──────────────────────────────────────────
|
# ── Wazuh (443) ──────────────────────────────────────────
|
||||||
server {
|
server {
|
||||||
listen 443 ssl default_server;
|
listen 443 ssl default_server;
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
KM34RWnxhn2dwEVfe9jhONhqhpPSytYm1TFA/w5CMk0=
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Z9MBRzvdvk6uCovQTbI4DgtWkntMddJWlEr/7tIbXCI=
|
||||||
@@ -23,7 +23,11 @@ net.ipv4.conf.default.rp_filter = 1
|
|||||||
net.ipv4.ip_forward = 0
|
net.ipv4.ip_forward = 0
|
||||||
net.ipv6.conf.all.forwarding = 0
|
net.ipv6.conf.all.forwarding = 0
|
||||||
{% else %}
|
{% else %}
|
||||||
# ip_forward laisse actif (defaut systeme = 1) : ce host heberge Docker et/ou fait relais VPN,
|
# ip_forward force actif : ce host heberge Docker et/ou fait relais VPN (ou le fera bientot),
|
||||||
# le desactiver casserait le NAT des ports publies ou le routage entre pairs WireGuard.
|
# le desactiver casserait le NAT des ports publies ou le routage entre pairs WireGuard.
|
||||||
|
# Fixe explicitement (pas de simple "defaut systeme") pour ne pas dependre de l'ordre
|
||||||
|
# d'installation de Docker, qui active lui-meme ip_forward mais seulement une fois installe.
|
||||||
# CIS 35608 restera donc en echec ici par necessite fonctionnelle, pas par oubli.
|
# CIS 35608 restera donc en echec ici par necessite fonctionnelle, pas par oubli.
|
||||||
|
net.ipv4.ip_forward = 1
|
||||||
|
net.ipv6.conf.all.forwarding = 1
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[[databases]]
|
||||||
|
name = "Production PostgreSQL - {{ db_name }}"
|
||||||
|
database = "{{ db_name }}"
|
||||||
|
type = "postgresql"
|
||||||
|
username = "{{ db_user }}"
|
||||||
|
password = "{{ db_password }}"
|
||||||
|
port = {{ db_port }}
|
||||||
|
host = "127.0.0.1"
|
||||||
|
generated_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
|
||||||
Reference in New Issue
Block a user