alicante-infra/reparar.sh

131 lines
3.4 KiB
Bash

#!/bin/bash
# Ir a la carpeta del proyecto
cd /root/alicante-infra || cd /sc/alicante-infra
echo "🔧 Reparando plantillas vacías..."
# --- 1. REPARAR TEMPLATES GATEWAY ---
cat > roles/gateway/templates/npm-compose.j2 <<EOF
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
- '80:80'
- '81:81'
- '443:443'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
EOF
cat > roles/gateway/templates/authentik-compose.j2 <<EOF
services:
postgresql:
image: docker.io/library/postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_PASSWORD: {{ authentik_pg_pass }}
POSTGRES_USER: authentik
POSTGRES_DB: authentik
volumes:
- database:/var/lib/postgresql/data
redis:
image: docker.io/library/redis:alpine
restart: unless-stopped
volumes:
- redis:/data
server:
image: ghcr.io/goauthentik/server:2024.10
restart: unless-stopped
command: server
environment:
AUTHENTIK_REDIS__HOST: redis
AUTHENTIK_POSTGRESQL__HOST: postgresql
AUTHENTIK_POSTGRESQL__USER: authentik
AUTHENTIK_POSTGRESQL__NAME: authentik
AUTHENTIK_POSTGRESQL__PASSWORD: {{ authentik_pg_pass }}
AUTHENTIK_SECRET_KEY: {{ authentik_secret }}
ports:
- "9000:9000"
- "9443:9443"
depends_on:
- postgresql
- redis
worker:
image: ghcr.io/goauthentik/server:2024.10
restart: unless-stopped
command: worker
environment:
AUTHENTIK_REDIS__HOST: redis
AUTHENTIK_POSTGRESQL__HOST: postgresql
AUTHENTIK_POSTGRESQL__USER: authentik
AUTHENTIK_POSTGRESQL__NAME: authentik
AUTHENTIK_POSTGRESQL__PASSWORD: {{ authentik_pg_pass }}
AUTHENTIK_SECRET_KEY: {{ authentik_secret }}
depends_on:
- postgresql
- redis
volumes:
database:
redis:
EOF
# --- 2. REPARAR TASKS CORE (Parece que faltaban pasos) ---
cat > roles/core/tasks/main.yml <<EOF
---
- name: Crear Red Interna
community.docker.docker_network: name=alicante_net
- name: Crear directorios
file: path=/opt/stacks/{{ item }} state=directory
loop: ['infra-shared', 'business', 'docs', 'dashboard']
- name: Desplegar Infra Shared
template: src=infra-shared-compose.j2 dest=/opt/stacks/infra-shared/compose.yaml
- name: Levantar Infra
community.docker.docker_compose_v2: project_src=/opt/stacks/infra-shared
- name: Esperar DB
command: docker exec postgres-core pg_isready
retries: 10
delay: 5
- name: Crear Bases de Datos
community.postgresql.postgresql_db:
name: "{{ item }}"
login_host: "{{ ansible_host }}"
login_password: "{{ global_db_root_pass }}"
port: 5432
loop: ['dolibarr', 'teable', 'activepieces', 'metabase', 'nextcloud']
- name: Configurar Negocio
template: src=apps-business-compose.j2 dest=/opt/stacks/business/compose.yaml
- name: Configurar Docs
template: src=apps-docs-compose.j2 dest=/opt/stacks/docs/compose.yaml
- name: Configurar Dashboard
template: src=dashboard-compose.j2 dest=/opt/stacks/dashboard/compose.yaml
- name: Levantar Todo
community.docker.docker_compose_v2: project_src=/opt/stacks/{{ item }}
loop: ['business', 'docs', 'dashboard']
EOF
echo "✅ Archivos reparados."
# --- 3. SUBIR A GIT ---
git add .
git commit -m "Reparacion plantillas vacias y tareas core"
git push
echo "🚀 Listo. Dale al RUN en Semaphore."