procedures_ansible_guia_de_arquitectura_verificacion
This is an old revision of the document!
Table of Contents
Ansible Automation Server — Guía de Arquitectura y Verificación
Objetivo
Este documento describe el estado final validado del servidor Ansible, incluyendo:
- Arquitectura mínima requerida
- Paquetes, versiones y entorno virtual
- Árbol de directorios obligatorio
- Archivos críticos y su propósito
- Scripts auxiliares (SSH / Expect / Known Hosts)
- Comandos reales de instalación, prueba y verificación
El objetivo es permitir:
- Auditoría técnica
- Reproducción del entorno
- Troubleshooting estructurado
- Onboarding de nuevos ingenieros
1. Arquitectura Base del Servidor
- OS: Linux (Debian/Ubuntu)
- Usuario operativo: root
- Path base: `/server/ansible`
- Ejecución: entorno virtual Python (venv)
- Automatización: Ansible + Expect + SSH
2. Árbol de Directorios Requerido
/server/ansible
├── ansible.cfg
├── requirements.yml
├── venv/
│ └── bin/activate
├── inventory/
│ ├── hosts_north
│ └── hosts_south
├── group_vars/
│ ├── all.yml
│ ├── north.yml
│ └── south.yml
├── playbooks/
│ ├── backup_switches_north.yml
│ └── backup_switches_south.yml
├── scripts/
│ ├── knownhosts_north.sh
│ ├── knownhosts_south.sh
│ ├── knownhosts_update.sh
│ ├── aoss_2930_backup.expect
│ ├── aoss_2930_backup_1.expect
│ └── instant_backup.expect
├── logs/
│ └── known_hosts/
├── tmp/
│ └── *.debug
└── backups/
└── cli_backup/
Permisos esperados
chmod 700 /server/ansible/scripts chmod 700 /root/.ssh chmod 600 /root/.ssh/known_hosts
3. Entorno Virtual y Dependencias
Activación del venv
cd /server/ansible source venv/bin/activate
Dependencias del sistema
apt-get update apt-get install -y \ build-essential \ pkg-config \ libssh-dev \ libssl-dev \ python3-dev
Instalación de pip + pylibssh
python -m pip install -U pip setuptools wheel python -m pip install ansible-pylibssh
Verificación
python -c "import pylibsshext; print('OK pylibsshext')" ansible --version
4. Collections de Ansible (Galaxy)
Archivo requirements.yml
cat /server/ansible/requirements.yml
collections: - name: arubanetworks.aoscx - name: arubanetworks.aos_switch - name: dellemc.os6 - name: cisco.ios - name: ansible.netcommon - name: ansible.utils
Instalación
ansible-galaxy collection install \ -r /server/ansible/requirements.yml \ -p /server/ansible/collections \ --force
Verificación
ansible-galaxy collection list | egrep -i "arubanetworks|dellemc|cisco\.ios|netcommon|utils"
5. SSH y Known Hosts
Estructura
/root/.ssh ├── known_hosts └── known_hosts.bak.*
Scripts disponibles
- knownhosts_north.sh → inventario norte
- knownhosts_south.sh → inventario sur
- knownhosts_update.sh → método robusto con locking y logs
Ejecución recomendada
/server/ansible/scripts/knownhosts_update.sh \ /server/ansible/inventory/hosts_north north
Salida esperada:
- Backup automático de known_hosts
- Logs en `/server/ansible/logs/known_hosts/`
- Deduplicación
- Control de concurrencia (`flock`)
6. Scripts Expect (Backups)
aoss_2930_backup.expect
Uso:
/server/ansible/scripts/aoss_2930_backup.expect \ <ip> <user> <password> <outfile>
Características:
- Autenticación por password
- Manejo de banners
- Deshabilita paging
- Captura `show running-config`
- Logs debug en `/server/ansible/tmp/`
instant_backup.expect
Uso:
/server/ansible/scripts/instant_backup.expect \ <ip> <user> <password> <outfile>
Especial para:
- Instant AP
- Virtual Controllers
- Prompt MAC / hostname
7. Inventarios
Ubicación:
/server/ansible/inventory/
Formato:
- INI clásico
- Uso de `ansible_host`
- Separación NORTH / SOUTH
Estos inventarios alimentan:
- Ansible
- knownhosts_update.sh
- Scripts expect
8. Checklist de Verificación Rápida
✔ `source venv/bin/activate` ✔ `ansible –version` ✔ `ansible-galaxy collection list` ✔ `/root/.ssh/known_hosts` existe y tiene entradas ✔ Scripts expect ejecutables ✔ Inventarios parsean correctamente (`ansible-inventory –list`) ✔ Backups generan archivos > 200 bytes
9. Estado Final
Este servidor queda VALIDADO PARA PRODUCCIÓN con:
- Método Ansible nativo
- Fallback robusto con Expect
- Manejo correcto de SSH legacy
- Logs, backups y trazabilidad completa
Este documento es la fuente de verdad del entorno.
procedures_ansible_guia_de_arquitectura_verificacion.1768797675.txt.gz · Last modified: by aperez
