procedures_ansible_guia_de_arquitectura_verificacion
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| procedures_ansible_guia_de_arquitectura_verificacion [2026/01/19 05:35] – [Verificación] aperez | procedures_ansible_guia_de_arquitectura_verificacion [2026/01/19 05:56] (current) – removed aperez | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Ansible Automation Server — Arquitectura Final y Guía de Verificación ====== | ||
| - | |||
| - | ===== Objetivo ===== | ||
| - | Este documento describe el **estado final operativo y validado** del servidor Ansible. | ||
| - | Su propósito es servir como: | ||
| - | |||
| - | * Guía mínima de verificación de arquitectura | ||
| - | * Referencia técnica oficial | ||
| - | * Manual de reconstrucción del entorno | ||
| - | * Base de auditoría y troubleshooting | ||
| - | * Fuente de verdad del servidor | ||
| - | |||
| - | ---- | ||
| - | |||
| - | ===== 1. Arquitectura General ===== | ||
| - | |||
| - | * OS: Linux (Debian / Ubuntu) | ||
| - | * Usuario operativo: root | ||
| - | * Path base Ansible: / | ||
| - | * Python: entorno virtual (venv) | ||
| - | * Automatización: | ||
| - | - Ansible (network_cli / ssh) | ||
| - | - Expect (fallback controlado) | ||
| - | * Métodos de conexión: | ||
| - | - libssh (preferido) | ||
| - | - paramiko (fallback) | ||
| - | - ssh clásico (Instant / Controllers) | ||
| - | |||
| - | ---- | ||
| - | |||
| - | ===== 2. Árbol de Directorios FINAL ===== | ||
| - | |||
| - | <code text> | ||
| - | / | ||
| - | ├── ansible.cfg | ||
| - | ├── requirements.yml | ||
| - | ├── venv/ | ||
| - | │ | ||
| - | ├── inventory/ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | ├── playbooks/ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | ├── scripts/ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | │ | ||
| - | ├── logs/ | ||
| - | │ | ||
| - | ├── tmp/ | ||
| - | │ | ||
| - | └── backups/ | ||
| - | ├── cli_backup/ | ||
| - | └── Report_inventory/ | ||
| - | ├── NORTH/ | ||
| - | └── SOUTH/ | ||
| - | |||
| - | /root/.ssh | ||
| - | ├── known_hosts | ||
| - | ├── known_hosts.bak.* | ||
| - | └── authorized_keys | ||
| - | </ | ||
| - | |||
| - | ---- | ||
| - | |||
| - | ===== 3. /root/.ssh — Componente CRÍTICO ===== | ||
| - | |||
| - | ====== ¿Por qué es obligatorio? | ||
| - | |||
| - | El directorio **/ | ||
| - | |||
| - | * Ansible (`network_cli`) | ||
| - | * libssh / paramiko | ||
| - | * SSH clásico | ||
| - | * Scripts Expect | ||
| - | * Scripts de actualización de host keys | ||
| - | |||
| - | Sin esta ruta correctamente configurada: | ||
| - | * libssh puede fallar silenciosamente | ||
| - | * SSH puede rechazar conexiones | ||
| - | * Expect puede abortar por mismatch de host key | ||
| - | * Ansible puede quedar inconsistente entre nodos | ||
| - | |||
| - | Este diseño **centraliza el control de confianza SSH** del servidor. | ||
| - | |||
| - | ---- | ||
| - | |||
| - | ===== 4. Estructura y Permisos SSH ===== | ||
| - | |||
| - | <code text> | ||
| - | /root/.ssh | ||
| - | ├── known_hosts | ||
| - | ├── known_hosts.bak.* | ||
| - | └── authorized_keys | ||
| - | </ | ||
| - | |||
| - | Permisos **OBLIGATORIOS**: | ||
| - | |||
| - | <code bash> | ||
| - | chmod 700 /root/.ssh | ||
| - | chmod 600 / | ||
| - | </ | ||
| - | |||
| - | --- | ||
| - | |||
| - | ===== 5. Gestión de known_hosts ===== | ||
| - | |||
| - | ====== Scripts disponibles ====== | ||
| - | |||
| - | * knownhosts_north.sh | ||
| - | * knownhosts_south.sh | ||
| - | * knownhosts_update.sh | ||
| - | |||
| - | Estos scripts: | ||
| - | * Extraen IPs desde inventarios | ||
| - | * Limpian entradas antiguas | ||
| - | * Ejecutan ssh-keyscan | ||
| - | * Deduplican claves | ||
| - | * Generan backups | ||
| - | * Evitan ejecuciones simultáneas (lock) | ||
| - | |||
| - | ====== Ejecución recomendada ====== | ||
| - | |||
| - | <code bash> | ||
| - | / | ||
| - | / | ||
| - | </ | ||
| - | |||
| - | Resultados esperados: | ||
| - | * / | ||
| - | * Backup automático con timestamp | ||
| - | * Logs en / | ||
| - | |||
| - | --- | ||
| - | |||
| - | ===== 6. Entorno Virtual y Dependencias ===== | ||
| - | |||
| - | ====== Activación ====== | ||
| - | <code bash> | ||
| - | cd / | ||
| - | source venv/ | ||
| - | </ | ||
| - | |||
| - | ====== Dependencias del sistema (una sola vez) ====== | ||
| - | <code bash> | ||
| - | apt-get update | ||
| - | apt-get install -y \ | ||
| - | build-essential \ | ||
| - | pkg-config \ | ||
| - | libssh-dev \ | ||
| - | libssl-dev \ | ||
| - | python3-dev | ||
| - | </ | ||
| - | |||
| - | ====== Python / pylibssh ====== | ||
| - | <code bash> | ||
| - | python -m pip install -U pip setuptools wheel | ||
| - | python -m pip install ansible-pylibssh | ||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| - | ===== Instalación y Verificación de ansible-pylibssh (venv) ===== | ||
| - | |||
| - | ==== 1) Activar entorno virtual ==== | ||
| - | |||
| - | <code bash> | ||
| - | cd / | ||
| - | source venv/ | ||
| - | </ | ||
| - | |||
| - | ==== 2) Instalar dependencias del sistema (solo una vez) ==== | ||
| - | |||
| - | <code bash> | ||
| - | apt-get update | ||
| - | apt-get install -y \ | ||
| - | build-essential \ | ||
| - | pkg-config \ | ||
| - | libssh-dev \ | ||
| - | libssl-dev \ | ||
| - | python3-dev | ||
| - | </ | ||
| - | |||
| - | ==== 3) Instalar ansible-pylibssh dentro del venv ==== | ||
| - | |||
| - | <code bash> | ||
| - | python -m pip install -U pip setuptools wheel | ||
| - | python -m pip install ansible-pylibssh | ||
| - | </ | ||
| - | |||
| - | ==== 4) Verificación de pylibssh ==== | ||
| - | |||
| - | <code bash> | ||
| - | python -c " | ||
| - | </ | ||
| - | |||
| - | ==== 5) Verificación de versión de Ansible ==== | ||
| - | |||
| - | <code bash> | ||
| - | ansible --version | ||
| - | </ | ||
| - | |||
| - | ==== f) Verificación ==== | ||
| - | <code bash> | ||
| - | python -c " | ||
| - | ansible --version | ||
| - | </ | ||
| - | |||
| - | ---- | ||
| - | |||
| - | ===== 7. Ansible Galaxy — Collections ===== | ||
| - | |||
| - | <code yaml> | ||
| - | collections: | ||
| - | - name: arubanetworks.aoscx | ||
| - | - name: arubanetworks.aos_switch | ||
| - | - name: dellemc.os6 | ||
| - | - name: cisco.ios | ||
| - | - name: ansible.netcommon | ||
| - | - name: ansible.utils | ||
| - | </ | ||
| - | |||
| - | Instalación: | ||
| - | <code bash> | ||
| - | ansible-galaxy collection install \ | ||
| - | -r / | ||
| - | -p / | ||
| - | --force | ||
| - | </ | ||
| - | |||
| - | ---- | ||
| - | |||
| - | ===== 8. Relación SSH ↔ Expect ↔ Ansible ===== | ||
| - | |||
| - | | Componente | Usa /root/.ssh | Motivo | | ||
| - | |-----------|---------------|--------| | ||
| - | | Ansible network_cli | Sí | Validación host key | | ||
| - | | libssh | Sí | Trust store | | ||
| - | | paramiko | Sí | Known hosts | | ||
| - | | Expect | Sí | StrictHostKeyChecking | | ||
| - | | ssh-keyscan | Sí | Población automática | | ||
| - | |||
| - | --- | ||
| - | |||
| - | ===== 9. Checklist SSH (CRÍTICO) ===== | ||
| - | |||
| - | ✔ /root/.ssh existe | ||
| - | ✔ Permisos correctos | ||
| - | ✔ known_hosts no vacío | ||
| - | ✔ known_hosts actualizado desde inventarios | ||
| - | ✔ ssh-keyscan funciona | ||
| - | ✔ Expect conecta sin prompt de host key | ||
| - | |||
| - | --- | ||
| - | |||
| - | ===== 10. Estado Final ===== | ||
| - | |||
| - | Este servidor queda: | ||
| - | |||
| - | * **OPERATIVO** | ||
| - | * **REPRODUCIBLE** | ||
| - | * **AUDITABLE** | ||
| - | * **RESILIENTE A CAMBIOS DE HOST KEY** | ||
| - | * **APTO PARA PRODUCCIÓN** | ||
| - | |||
| - | La ruta **/ | ||
| - | y **no debe ser omitida** en ninguna reinstalación. | ||
| - | |||
procedures_ansible_guia_de_arquitectura_verificacion.1768800944.txt.gz · Last modified: by aperez
