This repository accompanies my Medium article: Automating Wazuh Agent Installation on Linux and Windows with Ansible.
It demonstrates a step-by-step automated deployment of Wazuh agents on Linux and Windows systems using Ansible, simplifying setup and management while ensuring clarity and reproducibility.
- SSH access configured with a sudo-enabled user (
ansiblerecommended) - Authentication via SSH key only (no password)
- If not yet configured, deploy the public SSH key to each Linux machine manually or using a temporary account
- Preferred: OpenSSH enabled (Windows 10+)
- Alternative: WinRM enabled with an
ansibleuser and password
Ensure that the control node can communicate with all agent machines over SSH (Linux) or WinRM (Windows).
- Install Python and Ansible on your control machine
- Generate an SSH key for the
ansibleuser - Verify that Ansible is correctly installed and can connect to target hosts
The control node acts as the central point for managing agents and running playbooks.
- Create a dedicated
ansibleuser with sudo privileges - Deploy the SSH public key to enable key-based authentication
- Verify connectivity from the control node
- Use OpenSSH if available, otherwise configure WinRM
- Ensure the correct firewall rules and remote access policies are applied
- Test connectivity from the control node before deployment
Proper user setup and connectivity are essential for successful automation.
The repository is organized for clarity and maintainability:
- Inventory file: defines all Linux and Windows hosts
- Configuration file (
ansible.cfg): sets default parameters and paths - Playbooks: separate playbooks for Linux and Windows agent installation
- Scripts: installation scripts stored in the repository and executed by the playbooks
This structure ensures modularity and easy updates for large environments.
- Configure inventory and Ansible settings
- Prepare agent machines (users, keys, connectivity)
- Run the Linux playbook for all Linux agents
- Run the Windows playbook if using WinRM
- Verify that all agents are connected to the Wazuh manager
Following this workflow guarantees a smooth, automated deployment across multiple systems.
- Confirm firewall rules allow SSH (Linux) or WinRM (Windows)
- Validate IP addresses and hostnames in the inventory
- Ensure correct permissions on SSH keys
- Test connectivity with
pingor network checks - Use verbose mode in Ansible for detailed debugging
Proactive testing before full deployment reduces errors and downtime.
- Control node: Python and Ansible installed, SSH key generated
- Linux agents:
ansibleuser with SSH key, sudo privileges - Windows agents: managed via OpenSSH or WinRM
- Project structure: clean, modular, and maintainable for both small and large-scale deployments
This repository showcases an automated, reproducible, and professional setup for Wazuh agents using Ansible.