Skip to content

Commit a9bce79

Browse files
authored
Merge pull request #6 from EthDevOps/wazuh-agent
feature: wazuh agent role
2 parents 1b8fb84 + 5cbcfe4 commit a9bce79

6 files changed

Lines changed: 123 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this collection will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.2.0] - 2026-03-05
9+
10+
### Added
11+
12+
- New `wazuh_agent` role: installs and enrolls the Wazuh security monitoring agent via the official APT repository
13+
814
## [1.1.0] - 2024
915

1016
### Changed

roles/wazuh_agent/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# ethdevops.infrastructure.wazuh_agent
2+
3+
This role installs and configures the Wazuh agent for host-based security monitoring. The agent enrolls automatically with the configured Wazuh manager using the APT repository method.
4+
5+
## Requirements
6+
7+
- Debian or Ubuntu target host
8+
- Network connectivity from the target to the Wazuh manager on port 1514 (agent events) and 1515 (enrollment)
9+
10+
## Role Variables
11+
12+
Default variables are defined in [defaults/main.yml](defaults/main.yml)
13+
14+
| Variable | Description | Default |
15+
|----------|-------------|---------|
16+
| `wazuh_agent_manager_host` | Hostname or IP of the Wazuh manager | `wazuh.ethquokkaops.io` |
17+
18+
## Dependencies
19+
20+
None
21+
22+
## Example Playbook
23+
24+
```yaml
25+
- hosts: all
26+
become: true
27+
roles:
28+
- role: ethdevops.infrastructure.wazuh_agent
29+
```
30+
31+
To override the manager host:
32+
33+
```yaml
34+
- hosts: all
35+
become: true
36+
roles:
37+
- role: ethdevops.infrastructure.wazuh_agent
38+
vars:
39+
wazuh_agent_manager_host: "wazuh.example.com"
40+
```
41+
42+
To disable the agent for specific hosts, set `wazuh_agent_enabled: false` in the relevant host or group vars.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
wazuh_agent_manager_host: "wazuh.ethquokkaops.io"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: Restart wazuh-agent
3+
ansible.builtin.systemd:
4+
name: wazuh-agent
5+
state: restarted
6+
daemon_reload: true

roles/wazuh_agent/meta/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
galaxy_info:
3+
role_name: wazuh_agent
4+
author: EthDevOps
5+
description: Install and configure Wazuh agent for security monitoring
6+
license: MIT
7+
min_ansible_version: "2.15"
8+
platforms:
9+
- name: Debian
10+
versions:
11+
- all
12+
- name: Ubuntu
13+
versions:
14+
- all
15+
galaxy_tags:
16+
- wazuh
17+
- security
18+
- monitoring
19+
- ids
20+
dependencies: []

roles/wazuh_agent/tasks/main.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
- name: Install prerequisite packages
3+
ansible.builtin.apt:
4+
name:
5+
- gnupg
6+
- apt-transport-https
7+
state: present
8+
update_cache: true
9+
- name: Download Wazuh GPG key
10+
ansible.builtin.get_url:
11+
url: https://packages.wazuh.com/key/GPG-KEY-WAZUH
12+
dest: /tmp/wazuh-gpg-key
13+
mode: '0644'
14+
- name: Import Wazuh GPG key into keyring
15+
ansible.builtin.command:
16+
cmd: >
17+
gpg --no-default-keyring
18+
--keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg
19+
--import /tmp/wazuh-gpg-key
20+
creates: /usr/share/keyrings/wazuh.gpg
21+
- name: Set permissions on Wazuh keyring
22+
ansible.builtin.file:
23+
path: /usr/share/keyrings/wazuh.gpg
24+
mode: '0644'
25+
- name: Clean up downloaded GPG key
26+
ansible.builtin.file:
27+
path: /tmp/wazuh-gpg-key
28+
state: absent
29+
- name: Add Wazuh apt repository
30+
ansible.builtin.apt_repository:
31+
repo: "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main"
32+
filename: wazuh
33+
state: present
34+
- name: Install Wazuh agent
35+
ansible.builtin.apt:
36+
name: wazuh-agent
37+
state: present
38+
update_cache: true
39+
environment:
40+
WAZUH_MANAGER: "{{ wazuh_agent_manager_host }}"
41+
notify: Restart wazuh-agent
42+
- name: Enable and start Wazuh agent
43+
ansible.builtin.systemd:
44+
name: wazuh-agent
45+
enabled: true
46+
state: started
47+
daemon_reload: true

0 commit comments

Comments
 (0)