WAZUH - ANSIBLE

 

WAZUH - AMBASSADORS

🤖Despliegue Automático y Enrolamiento Seguro de Wazuh Agent en Ubuntu mediante Ansible

En esta práctica se realizará el despliegue automatizado de un Wazuh Agent en un sistema Ubuntu, utilizando Ansible y el rol oficial de Wazuh. El objetivo es conseguir una instalación centralizada, segura, reproducible y alineada con buenas prácticas, evitando configuraciones manuales y reduciendo errores humanos.

Para ello, se configurará previamente el Wazuh Manager para permitir el enrolamiento seguro de agentes mediante contraseña (authd). El sistema Ubuntu contará con un usuario dedicado para automatización, configurado con acceso SSH mediante clave pública, siguiendo el principio de mínimo privilegio.

Al finalizar la práctica, el agente quedará correctamente instalado, autenticado contra el Wazuh Manager y asignado a su grupo correspondiente, listo para comenzar la monitorización.

🧰 Tecnologías empleadas

Wazuh

Wazuh es una plataforma de seguridad que permite la detección de amenazas, la monitorización de sistemas y la gestión centralizada de agentes. En esta práctica, el Wazuh Manager actúa como punto central de enrolamiento y control.

Wazuh Agent (Ubuntu)

El agente de Wazuh instalado en Ubuntu recopila eventos del sistema, información de seguridad y cambios relevantes, enviándolos al Manager de forma segura.

Ansible

Ansible es una herramienta de automatización que permite desplegar y configurar sistemas de forma remota, declarativa y reproducible. Se utilizará para instalar y configurar el agente sin intervención manual.

Rol oficial de Wazuh para Ansible

El rol oficial de Wazuh proporciona tareas y configuraciones mantenidas por el proyecto, garantizando compatibilidad, buenas prácticas y facilidad de mantenimiento.

SSH con autenticación por clave

Se utilizará acceso SSH basado en claves para permitir la automatización segura entre Ansible y el agente Ubuntu, evitando el uso de contraseñas.

🎯 Objetivos de la práctica

  • Configurar el Wazuh Manager para permitir enrolamiento seguro mediante contraseña (authd).

  • Preparar un sistema Ubuntu para despliegue automatizado.

  • Crear un usuario dedicado para automatización con privilegios mínimos.

  • Configurar acceso SSH por clave para Ansible.

  • Desplegar el Wazuh Agent utilizando Ansible.

  • Utilizar el rol oficial de Wazuh para la instalación.

  • Enrolar automáticamente el agente en el Wazuh Manager.

  • Asignar el agente a su grupo correspondiente.

  • Garantizar un despliegue seguro, centralizado y reproducible.

🧩 Aspectos clave de la práctica

🔐 Configuración de enrolamiento seguro en Wazuh Manager

Antes del despliegue, se configurará el Wazuh Manager para:

  • Habilitar el servicio de autenticación de agentes (authd).

  • Proteger el enrolamiento mediante contraseña.

  • Evitar el alta de agentes no autorizados.

  • Controlar de forma segura el registro de nuevos sistemas.

Esto asegura que solo agentes legítimos puedan registrarse.

👤 Preparación del sistema Ubuntu para automatización

El sistema Ubuntu se preparará creando un usuario dedicado a automatización, lo que permitirá:

  • Separar tareas de automatización de usuarios administrativos.

  • Reducir riesgos mediante el principio de mínimo privilegio.

  • Facilitar la gestión y auditoría de accesos.

Este usuario será el punto de conexión de Ansible.

🔑 Acceso SSH seguro mediante clave

Se configurará acceso SSH basado en claves para:

  • Permitir la conexión automática de Ansible.

  • Eliminar el uso de contraseñas en texto plano.

  • Mejorar la seguridad del proceso de despliegue.

  • Asegurar comunicaciones cifradas y autenticadas.

🤖 Despliegue del agente con Ansible

Ansible se utilizará para ejecutar el despliegue de forma centralizada, permitiendo:

  • Instalar el Wazuh Agent de manera automática.

  • Aplicar configuraciones consistentes.

  • Reducir errores manuales.

  • Repetir el despliegue en múltiples sistemas si fuese necesario.

El proceso será totalmente no interactivo.

🧩 Uso del rol oficial de Wazuh

El rol oficial de Wazuh garantiza:

  • Compatibilidad con versiones actuales.

  • Buenas prácticas recomendadas por el proyecto.

  • Facilidad de mantenimiento y actualización.

  • Estandarización del despliegue.

Esto convierte la práctica en un escenario profesional y realista.

🔄 Enrolamiento automático y asignación a grupo

Durante el despliegue:

  • El agente se conectará al Wazuh Manager.

  • Se autenticará utilizando la contraseña configurada.

  • Se registrará correctamente en el sistema.

  • Quedará asignado al grupo definido.

Todo el proceso se realizará sin intervención manual.

🧪 Validación del despliegue

Para validar el resultado final:

  1. Se comprobará que el agente está instalado en Ubuntu.

  2. Se verificará la comunicación con el Wazuh Manager.

  3. Se confirmará el enrolamiento correcto.

  4. Se validará la pertenencia al grupo asignado.

  5. Se revisará el estado del agente desde el Manager.

Esto confirma el éxito del despliegue automatizado.

🔍 ¿Por qué es importante esta práctica?

Esta práctica representa un enfoque moderno y profesional para la gestión de agentes de seguridad. Permite comprender:

  • Cómo automatizar despliegues de seguridad.

  • Cómo aplicar el principio de mínimo privilegio.

  • Cómo asegurar el enrolamiento de agentes.

  • Cómo utilizar roles oficiales para mayor fiabilidad.

  • Cómo escalar despliegues de forma segura y controlada.

Es especialmente relevante para entornos empresariales, DevSecOps y SOCs modernos.

✅ Resultados esperados

  • Wazuh Manager configurado con enrolamiento seguro.

  • Usuario de automatización creado en Ubuntu.

  • Acceso SSH por clave funcionando correctamente.

  • Wazuh Agent instalado automáticamente mediante Ansible.

  • Agente enrolado de forma segura en el Manager.

  • Agente asignado correctamente a su grupo.

  • Despliegue reproducible y alineado con buenas prácticas.

  • Comprensión completa del flujo de automatización y seguridad.

🔗 Enlaces de interés

      DOCUMENTACIÓN                        

⚙️ Estructura de red



🤖Automated Deployment and Secure Enrollment of a Wazuh Agent on Ubuntu Using Ansible

In this practice, an automated deployment of a Wazuh Agent on an Ubuntu system will be performed using Ansible and the official Wazuh role. The goal is to achieve a centralized, secure, reproducible, and best-practice–aligned installation, eliminating manual configuration and reducing human error.

Prior to deployment, the Wazuh Manager will be configured to allow secure agent enrollment using a password (authd). The Ubuntu system will be prepared with a dedicated automation user, configured for SSH key-based access, following the principle of least privilege.

By the end of the practice, the agent will be successfully installed, securely enrolled with the Wazuh Manager, and assigned to its corresponding group, ready to begin monitoring.

🧰 Technologies Used

Wazuh

Wazuh is a security platform that provides threat detection, system monitoring, and centralized agent management. In this practice, the Wazuh Manager serves as the central enrollment and control point.

Wazuh Agent (Ubuntu)

The Wazuh agent installed on Ubuntu collects system events, security data, and relevant changes, sending them securely to the Wazuh Manager.

Ansible

Ansible is an automation tool that enables remote, declarative, and reproducible system configuration and deployment. It is used here to deploy and configure the Wazuh agent without manual intervention.

Official Wazuh Ansible Role

The official Wazuh role provides maintained and supported tasks for agent installation and configuration, ensuring compatibility, reliability, and adherence to best practices.

SSH Key-Based Authentication

SSH key-based authentication is used to enable secure, passwordless access for Ansible automation, enhancing security and operational efficiency.

🎯 Objectives of the Practice

  • Configure the Wazuh Manager for secure agent enrollment using authd.

  • Prepare an Ubuntu system for automated deployment.

  • Create a dedicated automation user with minimal privileges.

  • Configure SSH key-based access for Ansible.

  • Deploy the Wazuh Agent using Ansible.

  • Use the official Wazuh Ansible role for installation.

  • Automatically enroll the agent with the Wazuh Manager.

  • Assign the agent to its corresponding group.

  • Ensure a secure, centralized, and reproducible deployment.

🧩 Key Aspects of the Practice

🔐 Secure Enrollment Configuration on the Wazuh Manager

Before deployment, the Wazuh Manager will be configured to:

  • Enable the agent authentication service (authd).

  • Protect agent enrollment with a password.

  • Prevent unauthorized agent registrations.

  • Maintain secure control over new agent onboarding.

This ensures only trusted agents can be enrolled.

👤 Preparing the Ubuntu System for Automation

The Ubuntu system will be prepared by creating a dedicated automation user, which allows:

  • Separation of automation tasks from administrative users.

  • Reduced risk through the principle of least privilege.

  • Easier auditing and access management.

This user will be used by Ansible to perform deployment tasks.

🔑 Secure SSH Key-Based Access

SSH key-based authentication will be configured to:

  • Allow automated Ansible connections.

  • Eliminate plaintext password usage.

  • Improve security during deployment.

  • Ensure encrypted and authenticated communication.

🤖 Automated Agent Deployment with Ansible

Ansible will be used to deploy the agent in a centralized way, enabling:

  • Automated installation of the Wazuh agent.

  • Consistent configuration across systems.

  • Reduced manual errors.

  • Repeatable deployment across multiple hosts.

The process will be fully non-interactive.

🧩 Using the Official Wazuh Role

The official Wazuh Ansible role ensures:

  • Compatibility with current Wazuh versions.

  • Alignment with recommended best practices.

  • Simplified maintenance and updates.

  • Standardized and professional deployment workflows.

This makes the practice realistic and enterprise-ready.

🔄 Automatic Enrollment and Group Assignment

During deployment:

  • The agent connects to the Wazuh Manager.

  • Authentication is performed using the configured password.

  • The agent is registered successfully.

  • The agent is assigned to the specified group.

All steps occur automatically without manual intervention.

🧪 Deployment Validation

To validate the final result:

  1. Confirm the agent is installed on Ubuntu.

  2. Verify communication with the Wazuh Manager.

  3. Confirm successful enrollment.

  4. Validate group assignment.

  5. Check agent status from the Wazuh Manager.

This confirms the success of the automated deployment.

🔍 Why This Practice Is Important

This practice demonstrates a modern and professional approach to security agent management. It helps you understand:

  • How to automate security deployments.

  • How to apply the principle of least privilege.

  • How to secure agent enrollment.

  • How to leverage official roles for reliability.

  • How to scale deployments safely and efficiently.

It is especially relevant for enterprise environments, DevSecOps pipelines, and modern SOC operations.

✅ Expected Results

  • Wazuh Manager configured for secure enrollment.

  • Automation user created on Ubuntu.

  • SSH key-based access functioning correctly.

  • Wazuh Agent deployed automatically using Ansible.

  • Agent securely enrolled with the Wazuh Manager.

  • Agent correctly assigned to its group.

  • Reproducible deployment aligned with best practices.

  • Full understanding of the automation and security workflow.




Comentarios

Entradas populares