Fix: V3.2 upgrade paths
This commit is contained in:
parent
8396221a29
commit
a86520c5c2
|
|
@ -1,6 +1,22 @@
|
|||
---
|
||||
timezone: "Europe/Madrid"
|
||||
HEAD
|
||||
# Contraseñas Maestras (Se usan para configurar las DBs internas de cada stack)
|
||||
global_db_pass: "RootSecret123"
|
||||
global_redis_pass: "RedisSecret123"
|
||||
authentik_secret: "AlicanteAuthSecret2025_ChangeMe"
|
||||
|
||||
sysadmin_email: "admin@alicante.local"
|
||||
global_db_root_pass: "RootSecret123"
|
||||
global_db_app_pass: "AppSecret123"
|
||||
global_redis_pass: "RedisSecret123"
|
||||
authentik_secret: "GenerarStringLargoAleatorio123456"
|
||||
authentik_pg_pass: "AuthDBSecret123"
|
||||
pg_version: "16"
|
||||
|
||||
# --- ALICANTE CORE V3.2 CONFIGURATION ---
|
||||
# Carbone (Stack Docs)
|
||||
carbone_port: 4000
|
||||
carbone_version: "4"
|
||||
carbone_image: "carbone/carbone"
|
||||
a412b12 (Fix: V3.2 upgrade paths)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
timezone: "Europe/Madrid"
|
||||
sysadmin_email: "admin@alicante.local"
|
||||
global_db_root_pass: "RootSecret123"
|
||||
global_db_app_pass: "AppSecret123"
|
||||
global_redis_pass: "RedisSecret123"
|
||||
authentik_secret: "GenerarStringLargoAleatorio123456"
|
||||
authentik_pg_pass: "AuthDBSecret123"
|
||||
pg_version: "16"
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
services:
|
||||
metabase:
|
||||
image: metabase/metabase:latest
|
||||
environment:
|
||||
MB_DB_TYPE: postgres
|
||||
MB_DB_HOST: postgres-core
|
||||
MB_DB_USER: postgres
|
||||
MB_DB_PASS: {{ global_db_root_pass }}
|
||||
MB_DB_DBNAME: metabase
|
||||
networks:
|
||||
- alicante_net
|
||||
ports:
|
||||
- "3001:3000"
|
||||
|
||||
bookstack:
|
||||
image: lscr.io/linuxserver/bookstack:latest
|
||||
environment:
|
||||
DB_HOST: mariadb-core
|
||||
DB_USER: root
|
||||
DB_PASS: {{ global_db_root_pass }}
|
||||
networks:
|
||||
- alicante_net
|
||||
ports:
|
||||
- "6875:80"
|
||||
|
||||
gotenberg:
|
||||
image: gotenberg/gotenberg:8
|
||||
networks:
|
||||
- alicante_net
|
||||
# Gotenberg es una API, no suele necesitar puerto expuesto si se usa internamente,
|
||||
# pero lo dejamos accesible por si acaso en el 3000 interno (o mapeado si quieres)
|
||||
|
||||
networks:
|
||||
alicante_net:
|
||||
external: true
|
||||
carbone_templates:
|
||||
carbone_output:
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
services:
|
||||
metabase:
|
||||
image: metabase/metabase:latest
|
||||
environment:
|
||||
MB_DB_TYPE: postgres
|
||||
MB_DB_HOST: postgres-core
|
||||
MB_DB_USER: postgres
|
||||
MB_DB_PASS: {{ global_db_root_pass }}
|
||||
MB_DB_DBNAME: metabase
|
||||
networks:
|
||||
- alicante_net
|
||||
ports:
|
||||
- "3001:3000"
|
||||
|
||||
bookstack:
|
||||
image: lscr.io/linuxserver/bookstack:latest
|
||||
environment:
|
||||
DB_HOST: mariadb-core
|
||||
DB_USER: root
|
||||
DB_PASS: {{ global_db_root_pass }}
|
||||
networks:
|
||||
- alicante_net
|
||||
ports:
|
||||
- "6875:80"
|
||||
|
||||
gotenberg:
|
||||
image: gotenberg/gotenberg:8
|
||||
networks:
|
||||
- alicante_net
|
||||
# Gotenberg es una API, no suele necesitar puerto expuesto si se usa internamente,
|
||||
# pero lo dejamos accesible por si acaso en el 3000 interno (o mapeado si quieres)
|
||||
|
||||
networks:
|
||||
alicante_net:
|
||||
external: true
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Colores
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${GREEN}=== ALICANTE CORE UPGRADER V3.2 (FIXED) ===${NC}"
|
||||
|
||||
# 1. Definir archivo correcto (GRACIAS AL COMANDO TREE)
|
||||
TEMPLATE_FILE="roles/core/templates/apps-docs-compose.j2"
|
||||
GROUP_VARS="group_vars/all.yml"
|
||||
|
||||
# Verificar que existe el archivo objetivo
|
||||
if [ ! -f "$TEMPLATE_FILE" ]; then
|
||||
echo -e "${RED}[ERROR] No encuentro $TEMPLATE_FILE${NC}"
|
||||
echo "Por favor, verifica que estás en /sc/alicante-infra"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2. Actualizar group_vars (Idempotente: verifica si ya está)
|
||||
echo -e "${YELLOW}[1/3] Verificando variables globales...${NC}"
|
||||
if grep -q "carbone_port" "$GROUP_VARS"; then
|
||||
echo -e " ✅ Variables ya existen en group_vars/all.yml (del intento anterior)."
|
||||
else
|
||||
cat <<EOT >> "$GROUP_VARS"
|
||||
|
||||
# --- ALICANTE CORE V3.2 CONFIGURATION ---
|
||||
# Carbone (Stack Docs)
|
||||
carbone_port: 4000
|
||||
carbone_version: "4"
|
||||
carbone_image: "carbone/carbone"
|
||||
EOT
|
||||
echo -e " ✅ Variables añadidas."
|
||||
fi
|
||||
|
||||
# 3. Inyectar Servicio Carbone (Método seguro con archivos temporales)
|
||||
echo -e "${YELLOW}[2/3] Parcheando $TEMPLATE_FILE ...${NC}"
|
||||
|
||||
# Crear backup
|
||||
cp "$TEMPLATE_FILE" "${TEMPLATE_FILE}.bak"
|
||||
|
||||
# Crear archivo temporal con el bloque del servicio
|
||||
cat <<EOF > /tmp/carbone_service_block.yml
|
||||
carbone:
|
||||
image: "{{ carbone_image }}:{{ carbone_version }}"
|
||||
container_name: carbone
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "{{ carbone_port }}:4000"
|
||||
environment:
|
||||
TZ: "{{ timezone }}"
|
||||
volumes:
|
||||
- carbone_templates:/app/templates
|
||||
- carbone_output:/app/output
|
||||
networks:
|
||||
- docs_network
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:4000/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
EOF
|
||||
|
||||
# Crear archivo temporal con los volúmenes
|
||||
cat <<EOF > /tmp/carbone_volumes_block.yml
|
||||
carbone_templates:
|
||||
carbone_output:
|
||||
EOF
|
||||
|
||||
# Lógica de inserción:
|
||||
# 1. Si ya existe "container_name: carbone", no hacer nada.
|
||||
# 2. Si no, usar AWK para insertar el bloque de servicio ANTES de la línea "volumes:"
|
||||
# 3. Añadir los volúmenes al final del archivo.
|
||||
|
||||
if grep -q "container_name: carbone" "$TEMPLATE_FILE"; then
|
||||
echo -e " ⚠️ El servicio Carbone ya parece estar en el template."
|
||||
else
|
||||
# Insertar servicio ANTES de la línea que empieza por 'volumes:'
|
||||
awk 'NR==FNR{svc=$0; next} /^volumes:/{print svc} 1' /tmp/carbone_service_block.yml "$TEMPLATE_FILE" > "${TEMPLATE_FILE}.tmp" && mv "${TEMPLATE_FILE}.tmp" "$TEMPLATE_FILE"
|
||||
|
||||
# Añadir volúmenes al final del archivo (asumiendo que volumes: es el último bloque)
|
||||
cat /tmp/carbone_volumes_block.yml >> "$TEMPLATE_FILE"
|
||||
|
||||
echo -e " ✅ Template actualizado correctamente."
|
||||
fi
|
||||
|
||||
# Limpieza
|
||||
rm -f /tmp/carbone_service_block.yml /tmp/carbone_volumes_block.yml
|
||||
|
||||
# 4. Actualizar Checklist
|
||||
echo -e "${YELLOW}[3/3] Actualizando checklist...${NC}"
|
||||
CHECKLIST="deployment-checklist.sh"
|
||||
if [ -f "$CHECKLIST" ]; then
|
||||
if ! grep -q "Carbone" "$CHECKLIST"; then
|
||||
# Añadir check simple al final si no existe
|
||||
echo 'verify_service "Carbone" "4000"' >> "$CHECKLIST"
|
||||
echo -e " ✅ Checklist actualizado."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}=== ¡ACTUALIZACIÓN LOCAL COMPLETADA! ===${NC}"
|
||||
echo -e "Ahora ejecuta:"
|
||||
echo -e "1. git diff (para ver qué ha pasado)"
|
||||
echo -e "2. git add . && git commit -m 'Fix: V3.2 upgrade paths' && git push"
|
||||
echo -e "3. Despliega en Semaphore"
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Colores para output
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}==============================================${NC}"
|
||||
echo -e "${BLUE} ALICANTE CORE UPGRADER: V3.0/3.1 -> V3.2 ${NC}"
|
||||
echo -e "${BLUE}==============================================${NC}"
|
||||
|
||||
# 1. Verificaciones previas
|
||||
REPO_DIR=$(pwd)
|
||||
if [ ! -f "$REPO_DIR/group_vars/all.yml" ]; then
|
||||
echo -e "${RED}[ERROR] No se encuentra group_vars/all.yml. Asegúrate de ejecutar esto en la raíz del repo 'alicante-infra'.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${YELLOW}[1/5] Creando backups de seguridad...${NC}"
|
||||
cp group_vars/all.yml group_vars/all.yml.bak.v3
|
||||
cp roles/core/templates/docs-compose.j2 roles/core/templates/docs-compose.j2.bak.v3
|
||||
if [ -f "deployment-checklist.sh" ]; then cp deployment-checklist.sh deployment-checklist.sh.bak.v3; fi
|
||||
echo -e "${GREEN}Backups creados con extensión .bak.v3${NC}"
|
||||
|
||||
# 2. Actualizar Variables Globales
|
||||
echo -e "${YELLOW}[2/5] Inyectando configuración en group_vars/all.yml...${NC}"
|
||||
|
||||
# Verificamos si ya existe para no duplicar
|
||||
if grep -q "carbone_port" group_vars/all.yml; then
|
||||
echo -e " Variable carbone_port ya existe. Saltando inyección."
|
||||
else
|
||||
cat <<EOT >> group_vars/all.yml
|
||||
|
||||
# --- ALICANTE CORE V3.2 CONFIGURATION ---
|
||||
# Carbone (Stack Docs)
|
||||
carbone_port: 4000
|
||||
carbone_version: "4"
|
||||
carbone_image: "carbone/carbone"
|
||||
EOT
|
||||
echo -e "${GREEN} Variables de Carbone añadidas.${NC}"
|
||||
fi
|
||||
|
||||
# 3. Actualizar Template docs-compose.j2
|
||||
echo -e "${YELLOW}[3/5] Parcheando roles/core/templates/docs-compose.j2...${NC}"
|
||||
|
||||
TEMPLATE_FILE="roles/core/templates/docs-compose.j2"
|
||||
|
||||
# Definimos el bloque del servicio Carbone
|
||||
# NOTA: Usamos indentación de 2 espacios asumiendo estructura estándar docker-compose
|
||||
read -r -d '' CARBONE_SERVICE << EOM
|
||||
carbone:
|
||||
image: "{{ carbone_image }}:{{ carbone_version }}"
|
||||
container_name: carbone
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "{{ carbone_port }}:4000"
|
||||
environment:
|
||||
TZ: "{{ timezone }}"
|
||||
volumes:
|
||||
- carbone_templates:/app/templates
|
||||
- carbone_output:/app/output
|
||||
networks:
|
||||
- docs_network
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:4000/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
EOM
|
||||
|
||||
# Definimos los volúmenes
|
||||
read -r -d '' CARBONE_VOLUMES << EOM
|
||||
carbone_templates:
|
||||
carbone_output:
|
||||
EOM
|
||||
|
||||
# Inserción inteligente usando sed
|
||||
# 1. Insertar servicio antes de la definición global de 'volumes:'
|
||||
if grep -q "container_name: carbone" "$TEMPLATE_FILE"; then
|
||||
echo -e " Servicio Carbone ya existe en el template. Saltando."
|
||||
else
|
||||
# Busca la línea que empieza exactamente con 'volumes:' e inserta el servicio antes
|
||||
sed -i "/^volumes:/i \\$CARBONE_SERVICE" "$TEMPLATE_FILE"
|
||||
|
||||
# Busca la línea que empieza con 'volumes:' e inserta los volúmenes justo después
|
||||
sed -i "/^volumes:/a \\$CARBONE_VOLUMES" "$TEMPLATE_FILE"
|
||||
|
||||
echo -e "${GREEN} Servicio y volúmenes inyectados en el template.${NC}"
|
||||
fi
|
||||
|
||||
# 4. Actualizar Checklist y Docs
|
||||
echo -e "${YELLOW}[4/5] Actualizando scripts de mantenimiento...${NC}"
|
||||
|
||||
if [ -f "deployment-checklist.sh" ]; then
|
||||
if ! grep -q "Carbone" "deployment-checklist.sh"; then
|
||||
# Insertar verificación antes de la función main o al final
|
||||
sed -i '/# Check Management Stack/i \ verify_service "Carbone" "4000"' deployment-checklist.sh
|
||||
echo -e "${GREEN} Checklist actualizado.${NC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Renombrar documentación principal si existe
|
||||
if [ -f "ALICANTE_CORE_V3.1_COMPLETE.md" ]; then
|
||||
mv ALICANTE_CORE_V3.1_COMPLETE.md ALICANTE_CORE_V3.2_COMPLETE.md
|
||||
echo -e "${GREEN} Documentación renombrada a V3.2.${NC}"
|
||||
fi
|
||||
|
||||
# 5. Git Operations
|
||||
echo -e "${YELLOW}[5/5] Preparando Git...${NC}"
|
||||
echo -e "${BLUE}------------------------------------------------${NC}"
|
||||
echo -e "El código ha sido actualizado localmente."
|
||||
echo -e "Para aplicar los cambios, ejecuta los siguientes pasos:"
|
||||
echo -e ""
|
||||
echo -e "1. Revisa los cambios:"
|
||||
echo -e " ${YELLOW}git diff${NC}"
|
||||
echo -e ""
|
||||
echo -e "2. Sube los cambios al repo:"
|
||||
echo -e " ${YELLOW}git add .${NC}"
|
||||
echo -e " ${YELLOW}git commit -m \"Upgrade: Alicante Core V3.2 (Added Carbone)\"${NC}"
|
||||
echo -e " ${YELLOW}git push origin main${NC}"
|
||||
echo -e ""
|
||||
echo -e "3. Ve a Semaphore UI y ejecuta el Deploy."
|
||||
echo -e "${BLUE}------------------------------------------------${NC}"
|
||||
Loading…
Reference in New Issue