For fleets of more than a handful of endpoints, install the Wazuh agent with Ansible. The official `wazuh-ansible` roles deploy the agent, manage the configuration template and enroll the host against the manager.
1. Prerequisites
- Ansible 2.10 or newer on the control node
- SSH access from the control node to every target
- Privilege escalation (become) configured
2. Install the Wazuh Ansible roles
git clone https://github.com/wazuh/wazuh-ansible.git
cd wazuh-ansible3. Define your inventory
# inventory.ini
[wazuh_agents]
web-01 ansible_host=10.0.1.10
web-02 ansible_host=10.0.1.11
db-01 ansible_host=10.0.1.20
[wazuh_agents:vars]
ansible_user=ubuntu
ansible_become=true4. Write the playbook
# deploy-wazuh-agent.yml
- hosts: wazuh_agents
roles:
- role: ansible-wazuh-agent
vars:
wazuh_managers:
- address: 10.0.0.5
port: 1514
protocol: tcp
api_port: 55000
api_proto: https5. Run the playbook
ansible-playbook -i inventory.ini deploy-wazuh-agent.yml6. Verify on the manager
/var/ossec/bin/agent_control -l | headAll inventory hosts should appear as Active. Re-running the playbook is idempotent, safe to schedule via CI for drift correction.
Official reference
Commands and configuration in this guide are based on the official Wazuh documentation. For the canonical source, see: