deploiement de snowshare

This commit is contained in:
2026-07-30 11:47:24 +00:00
parent b170c71db0
commit cc73e4214a
4 changed files with 196 additions and 0 deletions

View File

@@ -26,3 +26,7 @@ passwordpusher ansible_host=10.100.5.104 ansible_user=ansible ansible_python_int
[immich_servers]
immich ansible_host=10.100.5.111 ansible_user=ansible ansible_python_interpreter=/usr/bin/python3
# END ANSIBLE MANAGED immich
# BEGIN ANSIBLE MANAGED snowshare
[snowshare_servers]
snowshare ansible_host=10.100.5.112 ansible_user=ansible ansible_python_interpreter=/usr/bin/python3
# END ANSIBLE MANAGED snowshare

View File

@@ -218,6 +218,29 @@
delegate_to: localhost
become: false
- name: Supprimer l ancienne cle SSH connue
known_hosts:
name: "{{ lxc_ip_address }}"
state: absent
delegate_to: localhost
become: false
- name: Scanner la nouvelle cle SSH du LXC
command: ssh-keyscan -H {{ lxc_ip_address }}
register: lxc_ssh_keyscan
changed_when: false
delegate_to: localhost
become: false
- name: Ajouter la nouvelle cle SSH du LXC dans known_hosts
known_hosts:
name: "{{ lxc_ip_address }}"
key: "{{ item }}"
state: present
loop: "{{ lxc_ssh_keyscan.stdout_lines }}"
delegate_to: localhost
become: false
# Ajout automatique du nouveau LXC dans inventory/hosts.ini.
#
# blockinfile evite les doublons:

View File

@@ -0,0 +1,118 @@
---
# Playbook: deploy-snowshare.yml
#
# But:
# - Deployer Snowshare dans le LXC snowshare
# - Copier le docker-compose.yml depuis Git
# - Generer .env.runtime si absent
# - Creer un lien .env pour Docker Compose
# - Demarrer la stack Docker Compose
# - Verifier que le port 3000 repond
#
# Important:
# - Les secrets ne doivent pas etre dans Git
# - Le fichier .env.runtime reste sur le LXC
- name: Deployer Snowshare
hosts: snowshare_servers
become: true
gather_facts: false
vars:
stack_name: snowshare
stack_path: /opt/stacks/snowshare
compose_source: "{{ playbook_dir }}/../services/snowshare/docker-compose.yml"
snowshare_domain: snowshare.thomasmlg.fr
tasks:
- name: Verifier que Docker est installe
command: docker --version
changed_when: false
- name: Verifier que Docker Compose est installe
command: docker compose version
changed_when: false
- name: Creer le dossier de la stack
file:
path: "{{ stack_path }}"
state: directory
owner: root
group: root
mode: "0750"
- name: Generer le fichier env runtime si absent
shell: |
set -e
umask 077
if [ ! -f "{{ stack_path }}/.env.runtime" ]; then
POSTGRES_PASSWORD="$(openssl rand -hex 32)"
NEXTAUTH_SECRET="$(openssl rand -hex 32)"
{
printf 'POSTGRES_USER=snowshare\n'
printf 'POSTGRES_PASSWORD=%s\n' "$POSTGRES_PASSWORD"
printf 'POSTGRES_DB=snowshare\n'
printf 'DATABASE_URL=postgres://snowshare:%s@db:5432/snowshare\n' "$POSTGRES_PASSWORD"
printf 'NEXTAUTH_URL=https://{{ snowshare_domain }}\n'
printf 'NEXTAUTH_SECRET=%s\n' "$NEXTAUTH_SECRET"
printf 'ALLOW_SIGNUP=true\n'
} > "{{ stack_path }}/.env.runtime"
fi
chown root:root "{{ stack_path }}/.env.runtime"
chmod 600 "{{ stack_path }}/.env.runtime"
args:
executable: /bin/bash
no_log: true
changed_when: true
- name: Creer le lien env pour Docker Compose
file:
src: "{{ stack_path }}/.env.runtime"
dest: "{{ stack_path }}/.env"
state: link
owner: root
group: root
- name: Copier le fichier Docker Compose
copy:
src: "{{ compose_source }}"
dest: "{{ stack_path }}/docker-compose.yml"
owner: root
group: root
mode: "0644"
- name: Valider la configuration Docker Compose
command: docker compose config
args:
chdir: "{{ stack_path }}"
changed_when: false
- name: Telecharger les images Docker
command: docker compose pull
args:
chdir: "{{ stack_path }}"
- name: Demarrer la stack Snowshare
command: docker compose up -d
args:
chdir: "{{ stack_path }}"
- name: Attendre le port Snowshare
wait_for:
host: 127.0.0.1
port: 3000
timeout: 180
- name: Afficher les conteneurs de la stack
command: docker compose ps
args:
chdir: "{{ stack_path }}"
register: compose_ps
changed_when: false
- name: Afficher le statut Docker Compose
debug:
var: compose_ps.stdout_lines

View File

@@ -0,0 +1,51 @@
---
services:
db:
image: postgres:16-alpine
container_name: snowshare-db
restart: unless-stopped
env_file:
- .env.runtime
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 10
app:
image: turodev/snowshare:latest
container_name: snowshare-app
restart: unless-stopped
depends_on:
db:
condition: service_healthy
env_file:
- .env.runtime
environment:
DATABASE_URL: ${DATABASE_URL}
NEXTAUTH_URL: ${NEXTAUTH_URL}
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
ALLOW_SIGNUP: ${ALLOW_SIGNUP}
ports:
- "3000:3000"
volumes:
- uploads:/app/uploads
volumes:
db-data:
uploads: