commit b6c3c31ef0c2ef8a00819e9956c310d7d99ab55b Author: DCC Admin Date: Sun Nov 30 23:36:33 2025 +0000 RESETEO TOTAL - AHORA SI diff --git a/README.md b/README.md new file mode 100644 index 0000000..4525b1e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Alicante Infraestructura v2 +Este repositorio contiene todo el código Ansible del proyecto. diff --git a/TEST_FILE b/TEST_FILE new file mode 100644 index 0000000..e69de29 diff --git a/group_vars/all.yml b/group_vars/all.yml new file mode 100644 index 0000000..7c2a2c4 --- /dev/null +++ b/group_vars/all.yml @@ -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" diff --git a/inventory.ini b/inventory.ini new file mode 100644 index 0000000..c562df0 --- /dev/null +++ b/inventory.ini @@ -0,0 +1,5 @@ +[gateway_group] +alicante-gateway ansible_host=10.10.10.100 ansible_user=root + +[core_group] +alicante-core ansible_host=10.10.10.102 ansible_user=root diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml new file mode 100644 index 0000000..b5cb752 --- /dev/null +++ b/roles/common/tasks/main.yml @@ -0,0 +1,31 @@ +--- +- name: Actualizar Sistema + apt: + update_cache: yes + upgrade: dist + +- name: Instalar Dependencias Base + apt: + name: + - curl + - git + - htop + - ufw + - gnupg + - sudo + - python3-pip + - python3-psycopg2 + state: present + +- name: Instalar Docker + shell: curl -fsSL https://get.docker.com | sh + args: + creates: /usr/bin/docker + +- name: Instalar Webmin + shell: | + curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh + sh setup-repos.sh + apt-get install webmin --install-recommends -y + args: + creates: /etc/webmin diff --git a/roles/core/tasks/main.yml b/roles/core/tasks/main.yml new file mode 100644 index 0000000..242566f --- /dev/null +++ b/roles/core/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- 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'] diff --git a/roles/core/templates/infra-shared-compose.j2 b/roles/core/templates/infra-shared-compose.j2 new file mode 100644 index 0000000..e69de29 diff --git a/roles/gateway/tasks/main.yml b/roles/gateway/tasks/main.yml new file mode 100644 index 0000000..64b7d0b --- /dev/null +++ b/roles/gateway/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: Crear directorios + file: path=/opt/stacks/{{ item }} state=directory mode=0755 + loop: ['npm', 'authentik'] + +- name: Configurar NPM + template: src=npm-compose.j2 dest=/opt/stacks/npm/compose.yaml + +- name: Configurar Authentik + template: src=authentik-compose.j2 dest=/opt/stacks/authentik/compose.yaml + vars: + authentik_host_ip: "{{ ansible_host }}" + +- name: Levantar Stacks + community.docker.docker_compose_v2: + project_src: "/opt/stacks/{{ item }}" + state: present + loop: ['npm', 'authentik'] diff --git a/roles/gateway/templates/authentik-compose.j2 b/roles/gateway/templates/authentik-compose.j2 new file mode 100644 index 0000000..ad189dd --- /dev/null +++ b/roles/gateway/templates/authentik-compose.j2 @@ -0,0 +1 @@ +services: {} diff --git a/roles/gateway/templates/npm-compose.j2 b/roles/gateway/templates/npm-compose.j2 new file mode 100644 index 0000000..ad189dd --- /dev/null +++ b/roles/gateway/templates/npm-compose.j2 @@ -0,0 +1 @@ +services: {} diff --git a/site.yml b/site.yml new file mode 100644 index 0000000..bc51bda --- /dev/null +++ b/site.yml @@ -0,0 +1,25 @@ +--- +- name: 1. Preparación Común + hosts: all + become: yes + roles: + - common + +- name: 2. Despliegue Core + hosts: core_group + become: yes + roles: + - core + +- name: 3. Despliegue Gateway + hosts: gateway_group + become: yes + roles: + - gateway + + tasks: + - name: "INTEGRACIÓN: Añadir IP del Core al /etc/hosts del Gateway" + lineinfile: + path: /etc/hosts + line: "{{ hostvars[groups['core_group'][0]]['ansible_host'] }} alicante-core" + state: present