-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4642 from wazuh/enhacement/4581-migrate-qa-roles
Migrate Wazuh Ansibles Roles
- Loading branch information
Showing
95 changed files
with
6,017 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Ansible Role: Filebeat for Elastic Stack | ||
------------------------------------ | ||
|
||
An Ansible Role that installs [Filebeat-oss](https://www.elastic.co/products/beats/filebeat), this can be used in conjunction with [ansible-wazuh-manager](https://github.com/wazuh/wazuh-ansible/ansible-wazuh-server). | ||
|
||
Requirements | ||
------------ | ||
|
||
This role will work on: | ||
* Red Hat | ||
* CentOS | ||
* Fedora | ||
* Debian | ||
* Ubuntu | ||
|
||
Role Variables | ||
-------------- | ||
|
||
Available variables are listed below, along with default values (see `defaults/main.yml`): | ||
|
||
``` | ||
filebeat_output_indexer_hosts: | ||
- "localhost:9200" | ||
``` | ||
|
||
License and copyright | ||
--------------------- | ||
|
||
WAZUH Copyright (C) 2016, Wazuh Inc. (License GPLv3) | ||
|
||
### Based on previous work from geerlingguy | ||
|
||
- https://github.com/geerlingguy/ansible-role-filebeat | ||
|
||
### Modified by Wazuh | ||
|
||
The playbooks have been modified by Wazuh, including some specific requirements, templates and configuration to improve integration with Wazuh ecosystem. |
29 changes: 29 additions & 0 deletions
29
provisioning/roles/wazuh/ansible-filebeat-oss/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
filebeat_version: 7.10.2 | ||
|
||
wazuh_template_branch: 4.8.0 | ||
|
||
filebeat_node_name: node-1 | ||
|
||
filebeat_output_indexer_hosts: | ||
- "localhost:9200" | ||
|
||
filebeat_module_package_url: https://packages.wazuh.com/4.x/filebeat | ||
filebeat_module_package_name: wazuh-filebeat-0.2.tar.gz | ||
filebeat_module_package_path: /tmp/ | ||
filebeat_module_destination: /usr/share/filebeat/module | ||
filebeat_module_folder: /usr/share/filebeat/module/wazuh | ||
indexer_security_user: admin | ||
indexer_security_password: changeme | ||
# Security plugin | ||
filebeat_security: true | ||
filebeat_ssl_dir: /etc/pki/filebeat | ||
|
||
# Local path to store the generated certificates (Opensearch security plugin) | ||
local_certs_path: "{{ playbook_dir }}/indexer/certificates" | ||
|
||
filebeatrepo: | ||
apt: 'deb https://packages.wazuh.com/4.x/apt/ stable main' | ||
yum: 'https://packages.wazuh.com/4.x/yum/' | ||
gpg: 'https://packages.wazuh.com/key/GPG-KEY-WAZUH' | ||
key_id: '0DCFCA5547B19D2A6099506096B3EE5F29111145' |
3 changes: 3 additions & 0 deletions
3
provisioning/roles/wazuh/ansible-filebeat-oss/handlers/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- name: restart filebeat | ||
service: name=filebeat state=restarted |
29 changes: 29 additions & 0 deletions
29
provisioning/roles/wazuh/ansible-filebeat-oss/meta/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
dependencies: [] | ||
|
||
galaxy_info: | ||
author: Wazuh | ||
description: Installing and maintaining Filebeat-oss. | ||
company: wazuh.com | ||
license: license (GPLv3) | ||
min_ansible_version: 2.0 | ||
platforms: | ||
- name: EL | ||
versions: | ||
- 6 | ||
- 7 | ||
- name: Fedora | ||
versions: | ||
- all | ||
- name: Debian | ||
versions: | ||
- jessie | ||
- name: Ubuntu | ||
versions: | ||
- precise | ||
- trusty | ||
- xenial | ||
galaxy_tags: | ||
- web | ||
- system | ||
- monitoring |
23 changes: 23 additions & 0 deletions
23
provisioning/roles/wazuh/ansible-filebeat-oss/tasks/Debian.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
- name: Debian/Ubuntu | Install apt-transport-https, ca-certificates and acl | ||
apt: | ||
name: | ||
- apt-transport-https | ||
- ca-certificates | ||
- acl | ||
state: present | ||
register: filebeat_ca_packages_install | ||
until: filebeat_ca_packages_install is succeeded | ||
|
||
- name: Debian/Ubuntu | Add Elasticsearch apt key. | ||
apt_key: | ||
url: "{{ filebeatrepo.gpg }}" | ||
id: "{{ filebeatrepo.key_id }}" | ||
state: present | ||
|
||
- name: Debian/Ubuntu | Add Filebeat-oss repository. | ||
apt_repository: | ||
repo: "{{ filebeatrepo.apt }}" | ||
state: present | ||
update_cache: true | ||
changed_when: false |
6 changes: 6 additions & 0 deletions
6
provisioning/roles/wazuh/ansible-filebeat-oss/tasks/RMDebian.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Debian/Ubuntu | Remove Filebeat repository (and clean up left-over metadata) | ||
apt_repository: | ||
repo: "{{ filebeatrepo.apt }}" | ||
state: absent | ||
changed_when: false |
6 changes: 6 additions & 0 deletions
6
provisioning/roles/wazuh/ansible-filebeat-oss/tasks/RMRedHat.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: RedHat/CentOS/Fedora | Remove Filebeat repository (and clean up left-over metadata) | ||
yum_repository: | ||
name: wazuh_repo | ||
state: absent | ||
changed_when: false |
9 changes: 9 additions & 0 deletions
9
provisioning/roles/wazuh/ansible-filebeat-oss/tasks/RedHat.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- name: RedHat/CentOS/Fedora/Amazon Linux | Install Filebeats repo | ||
yum_repository: | ||
name: wazuh_repo | ||
description: Wazuh Repo | ||
baseurl: "{{ filebeatrepo.yum }}" | ||
gpgkey: "{{ filebeatrepo.gpg }}" | ||
gpgcheck: true | ||
changed_when: false |
22 changes: 22 additions & 0 deletions
22
provisioning/roles/wazuh/ansible-filebeat-oss/tasks/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- block: | ||
- name: Copy Filebeat configuration. | ||
template: | ||
src: filebeat.yml.j2 | ||
dest: "/etc/filebeat/filebeat.yml" | ||
owner: root | ||
group: root | ||
mode: 0400 | ||
notify: restart filebeat | ||
|
||
- name: Fetch latest Wazuh alerts template | ||
get_url: | ||
url: https://raw.githubusercontent.com/wazuh/wazuh/{{ wazuh_template_branch }}/extensions/elasticsearch/7.x/wazuh-template.json | ||
dest: "/etc/filebeat/wazuh-template.json" | ||
owner: root | ||
group: root | ||
mode: 0400 | ||
notify: restart filebeat | ||
|
||
tags: | ||
- configure |
78 changes: 78 additions & 0 deletions
78
provisioning/roles/wazuh/ansible-filebeat-oss/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
- include_tasks: RedHat.yml | ||
when: ansible_os_family == 'RedHat' | ||
|
||
- include_tasks: Debian.yml | ||
when: ansible_os_family == 'Debian' | ||
|
||
- name: Install Filebeat | Redhat | ||
yum: | ||
name: "filebeat-{{ filebeat_version }}" | ||
state: present | ||
register: install | ||
tags: | ||
- install | ||
- init | ||
when: ansible_os_family == 'RedHat' | ||
|
||
- name: Install Filebeat | Debian | ||
apt: | ||
name: "filebeat={{ filebeat_version }}" | ||
state: present | ||
register: install | ||
tags: | ||
- install | ||
- init | ||
when: ansible_os_family == 'Debian' | ||
|
||
- name: Checking if Filebeat Module folder file exists | ||
stat: | ||
path: "{{ filebeat_module_folder }}" | ||
register: filebeat_module_folder | ||
|
||
- name: Download Filebeat module package | ||
get_url: | ||
url: "{{ filebeat_module_package_url }}/{{ filebeat_module_package_name }}" | ||
dest: "{{ filebeat_module_package_path }}" | ||
when: not filebeat_module_folder.stat.exists | ||
|
||
- name: Unpack Filebeat module package | ||
unarchive: | ||
src: "{{ filebeat_module_package_path }}/{{ filebeat_module_package_name }}" | ||
dest: "{{ filebeat_module_destination }}" | ||
remote_src: yes | ||
when: not filebeat_module_folder.stat.exists | ||
|
||
- name: Setting 0755 permission for Filebeat module folder | ||
file: dest={{ filebeat_module_folder }} mode=u=rwX,g=rwX,o=rwX recurse=yes | ||
when: not filebeat_module_folder.stat.exists | ||
|
||
- name: Checking if Filebeat Module package file exists | ||
stat: | ||
path: "{{ filebeat_module_package_path }}/{{ filebeat_module_package_name }}" | ||
register: filebeat_module_package | ||
when: filebeat_module_package is not defined | ||
|
||
- name: Delete Filebeat module package file | ||
file: | ||
state: absent | ||
path: "{{ filebeat_module_package_path }}/{{ filebeat_module_package_name }}" | ||
when: filebeat_module_package.stat.exists | ||
|
||
- import_tasks: config.yml | ||
notify: restart filebeat | ||
|
||
- include_tasks: security_actions.yml | ||
when: filebeat_security | ||
|
||
- name: Ensure Filebeat is started and enabled at boot. | ||
service: | ||
name: filebeat | ||
state: started | ||
enabled: true | ||
|
||
- include_tasks: "RMRedHat.yml" | ||
when: ansible_os_family == "RedHat" | ||
|
||
- include_tasks: "RMDebian.yml" | ||
when: ansible_os_family == "Debian" |
26 changes: 26 additions & 0 deletions
26
provisioning/roles/wazuh/ansible-filebeat-oss/tasks/security_actions.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
- block: | ||
|
||
- name: Ensure Filebeat SSL key pair directory exists. | ||
file: | ||
path: "{{ filebeat_ssl_dir }}" | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: 500 | ||
|
||
- name: Copy the certificates from local to the Manager instance | ||
copy: | ||
src: "{{ local_certs_path }}/wazuh-certificates/{{ item }}" | ||
dest: "{{ filebeat_ssl_dir }}" | ||
owner: root | ||
group: root | ||
mode: 400 | ||
with_items: | ||
- "{{ filebeat_node_name }}-key.pem" | ||
- "{{ filebeat_node_name }}.pem" | ||
- "root-ca.pem" | ||
|
||
tags: | ||
- security | ||
when: | ||
- filebeat_security |
42 changes: 42 additions & 0 deletions
42
provisioning/roles/wazuh/ansible-filebeat-oss/templates/filebeat.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Wazuh - Filebeat configuration file | ||
filebeat.modules: | ||
- module: wazuh | ||
alerts: | ||
enabled: true | ||
archives: | ||
enabled: false | ||
|
||
setup.template.json.enabled: true | ||
setup.template.json.path: '/etc/filebeat/wazuh-template.json' | ||
setup.template.json.name: 'wazuh' | ||
setup.template.overwrite: true | ||
setup.ilm.enabled: false | ||
|
||
# Send events directly to Wazuh indexer | ||
output.elasticsearch: | ||
hosts: | ||
{% for item in filebeat_output_indexer_hosts %} | ||
- {{ item }} | ||
{% endfor %} | ||
|
||
{% if filebeat_security %} | ||
username: {{ indexer_security_user }} | ||
password: "{{ indexer_security_password }}" | ||
protocol: https | ||
ssl.certificate_authorities: | ||
- {{ filebeat_ssl_dir }}/root-ca.pem | ||
ssl.certificate: "{{ filebeat_ssl_dir }}/{{ filebeat_node_name }}.pem" | ||
ssl.key: "{{ filebeat_ssl_dir }}/{{ filebeat_node_name }}-key.pem" | ||
{% endif %} | ||
|
||
# Optional. Send events to Logstash instead of Wazuh indexer | ||
#output.logstash.hosts: ["YOUR_LOGSTASH_SERVER_IP:5000"] | ||
|
||
logging.metrics.enabled: false | ||
|
||
seccomp: | ||
default_action: allow | ||
syscalls: | ||
- action: allow | ||
names: | ||
- rseq |
Oops, something went wrong.