Resolving conflicts
This commit is contained in:
commit
37dfb5fe12
9
playbooks/wazuh-manager-oss.yml
Normal file
9
playbooks/wazuh-manager-oss.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- hosts: managers
|
||||
roles:
|
||||
# - role: ../roles/wazuh/ansible-wazuh-manager
|
||||
- role: ../roles/wazuh/ansible-filebeat-oss
|
||||
filebeat_output_elasticsearch_hosts:
|
||||
- "172.16.0.161:9200"
|
||||
- "172.16.0.162:9200"
|
||||
- "172.16.0.163:9200"
|
||||
4
playbooks/wazuh-opendistro-kibana.yml
Normal file
4
playbooks/wazuh-opendistro-kibana.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
- hosts: es1
|
||||
roles:
|
||||
- role: ../roles/opendistro/opendistro-kibana
|
||||
@ -1,4 +1,4 @@
|
||||
---
|
||||
- hosts: es-cluster
|
||||
- hosts: es_cluster
|
||||
roles:
|
||||
- role: ../roles/opendistro/opendistro-elasticsearch
|
||||
|
||||
@ -134,7 +134,7 @@ It is possible to define users directly on the playbook, these must be defined o
|
||||
License and copyright
|
||||
---------------------
|
||||
|
||||
WAZUH Copyright (C) 2017 Wazuh Inc. (License GPLv3)
|
||||
WAZUH Copyright (C) 2020 Wazuh Inc. (License GPLv3)
|
||||
|
||||
### Based on previous work from geerlingguy
|
||||
|
||||
|
||||
@ -4,8 +4,9 @@ elasticsearch_http_port: 9200
|
||||
elasticsearch_network_host: 127.0.0.1
|
||||
elasticsearch_reachable_host: 127.0.0.1
|
||||
elasticsearch_jvm_xms: null
|
||||
elastic_stack_version: 7.6.2
|
||||
elastic_stack_version: 7.7.0
|
||||
elasticsearch_lower_disk_requirements: false
|
||||
elasticsearch_path_repo: []
|
||||
|
||||
elasticrepo:
|
||||
apt: 'https://artifacts.elastic.co/packages/7.x/apt'
|
||||
@ -36,7 +37,7 @@ node_certs_source: /usr/share/elasticsearch
|
||||
node_certs_destination: /etc/elasticsearch/certs
|
||||
|
||||
# CA generation
|
||||
master_certs_path: /es_certs
|
||||
master_certs_path: "{{ playbook_dir }}/es_certs"
|
||||
generate_CA: true
|
||||
ca_key_name: ""
|
||||
ca_cert_name: ""
|
||||
|
||||
@ -102,6 +102,7 @@
|
||||
state: directory
|
||||
mode: 0700
|
||||
delegate_to: "127.0.0.1"
|
||||
become: no
|
||||
when:
|
||||
- node_certs_generator
|
||||
|
||||
@ -111,6 +112,7 @@
|
||||
state: directory
|
||||
mode: 0700
|
||||
delegate_to: "127.0.0.1"
|
||||
become: no
|
||||
when:
|
||||
- node_certs_generator
|
||||
|
||||
@ -139,6 +141,7 @@
|
||||
src: "{{ master_certs_path }}/certs.zip"
|
||||
dest: "{{ master_certs_path }}/"
|
||||
delegate_to: "127.0.0.1"
|
||||
become: no
|
||||
when:
|
||||
- node_certs_generator
|
||||
tags:
|
||||
@ -149,6 +152,8 @@
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ node_certs_destination }}/"
|
||||
owner: root
|
||||
group: elasticsearch
|
||||
mode: 0440
|
||||
with_items:
|
||||
- "{{ master_certs_path }}/{{ elasticsearch_node_name }}/{{ elasticsearch_node_name }}.key"
|
||||
@ -164,6 +169,8 @@
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ node_certs_destination }}/"
|
||||
owner: root
|
||||
group: elasticsearch
|
||||
mode: 0440
|
||||
with_items:
|
||||
- "{{ master_certs_path }}/{{ elasticsearch_node_name }}/{{ elasticsearch_node_name }}.key"
|
||||
@ -178,9 +185,11 @@
|
||||
- name: Ensuring folder permissions
|
||||
file:
|
||||
path: "{{ node_certs_destination }}/"
|
||||
mode: 0774
|
||||
owner: root
|
||||
group: elasticsearch
|
||||
mode: 0770
|
||||
state: directory
|
||||
recurse: yes
|
||||
recurse: no
|
||||
when:
|
||||
- elasticsearch_xpack_security
|
||||
- generate_CA
|
||||
|
||||
@ -6,6 +6,12 @@ path.data: /var/lib/elasticsearch
|
||||
path.logs: /var/log/elasticsearch
|
||||
bootstrap.memory_lock: true
|
||||
network.host: {{ elasticsearch_network_host }}
|
||||
{% if elasticsearch_path_repo | length>0 %}
|
||||
path.repo:
|
||||
{% for item in elasticsearch_path_repo %}
|
||||
- {{ item }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if single_node %}
|
||||
discovery.type: single-node
|
||||
|
||||
@ -37,7 +37,7 @@ Example Playbook
|
||||
License and copyright
|
||||
---------------------
|
||||
|
||||
WAZUH Copyright (C) 2017 Wazuh Inc. (License GPLv3)
|
||||
WAZUH Copyright (C) 2020 Wazuh Inc. (License GPLv3)
|
||||
|
||||
### Based on previous work from geerlingguy
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ elasticsearch_http_port: "9200"
|
||||
elasticsearch_network_host: "127.0.0.1"
|
||||
kibana_server_host: "0.0.0.0"
|
||||
kibana_server_port: "5601"
|
||||
elastic_stack_version: 7.6.2
|
||||
elastic_stack_version: 7.7.0
|
||||
wazuh_version: 3.12.3
|
||||
wazuh_app_url: https://packages.wazuh.com/wazuhapp/wazuhapp
|
||||
|
||||
@ -34,7 +34,7 @@ node_certs_source: /usr/share/elasticsearch
|
||||
node_certs_destination: /etc/kibana/certs
|
||||
|
||||
# CA Generation
|
||||
master_certs_path: /es_certs
|
||||
master_certs_path: "{{ playbook_dir }}/es_certs"
|
||||
generate_CA: true
|
||||
ca_cert_name: ""
|
||||
|
||||
|
||||
@ -28,6 +28,8 @@
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ node_certs_destination }}/"
|
||||
owner: root
|
||||
group: kibana
|
||||
mode: 0440
|
||||
with_items:
|
||||
- "{{ master_certs_path }}/{{ kibana_node_name }}/{{ kibana_node_name }}.key"
|
||||
@ -42,6 +44,8 @@
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ node_certs_destination }}/"
|
||||
owner: root
|
||||
group: kibana
|
||||
mode: 0440
|
||||
with_items:
|
||||
- "{{ master_certs_path }}/{{ kibana_node_name }}/{{ kibana_node_name }}.key"
|
||||
@ -52,22 +56,14 @@
|
||||
- not generate_CA
|
||||
tags: xpack-security
|
||||
|
||||
- name: Ensuring certificates folder owner
|
||||
- name: Ensuring certificates folder owner and permissions
|
||||
file:
|
||||
path: "{{ node_certs_destination }}/"
|
||||
state: directory
|
||||
recurse: yes
|
||||
recurse: no
|
||||
owner: kibana
|
||||
group: kibana
|
||||
when:
|
||||
- kibana_xpack_security
|
||||
tags: xpack-security
|
||||
|
||||
- name: Ensuring certificates folder owner
|
||||
file:
|
||||
path: "{{ node_certs_destination }}/"
|
||||
mode: 0770
|
||||
recurse: yes
|
||||
when:
|
||||
- kibana_xpack_security
|
||||
notify: restart kibana
|
||||
@ -139,9 +135,9 @@
|
||||
shell: /usr/share/kibana/node/bin/node {{ node_options }} /usr/share/kibana/src/cli --optimize
|
||||
args:
|
||||
executable: /bin/bash
|
||||
creates: /usr/share/kibana/optimize/wazuh/
|
||||
become: yes
|
||||
become_user: kibana
|
||||
changed_when: false
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
# The OpenDistro version
|
||||
opendistro_version: 1.6.0
|
||||
opendistro_version: 1.8.0
|
||||
elasticsearch_cluster_name: wazuh-cluster
|
||||
|
||||
# Minimum master nodes in cluster, 2 for 3 nodes elasticsearch cluster
|
||||
@ -28,7 +28,7 @@ opendistro_sec_plugin_conf_path: /usr/share/elasticsearch/plugins/opendistro_sec
|
||||
opendistro_sec_plugin_tools_path: /usr/share/elasticsearch/plugins/opendistro_security/tools
|
||||
opendistro_conf_path: /etc/elasticsearch/
|
||||
es_nodes: |-
|
||||
{% for item in groups['es-cluster'] -%}
|
||||
{% for item in groups['es_cluster'] -%}
|
||||
{{ hostvars[item]['ip'] }}{% if not loop.last %}","{% endif %}
|
||||
{%- endfor %}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
---
|
||||
- name: RedHat/CentOS/Fedora | Remove Elasticsearch repository (and clean up left-over metadata)
|
||||
yum_repository:
|
||||
name: elastic_repo_7
|
||||
name: opendistro_repo
|
||||
state: absent
|
||||
changed_when: false
|
||||
|
||||
@ -2,50 +2,71 @@
|
||||
- block:
|
||||
|
||||
- name: Local action | Create local temporary directory for certificates generation
|
||||
local_action:
|
||||
module: file
|
||||
file:
|
||||
path: "{{ local_certs_path }}"
|
||||
state: directory
|
||||
run_once: true
|
||||
|
||||
- name: Local action | Check that the generation tool exists
|
||||
stat:
|
||||
path: "{{ local_certs_path }}/search-guard-tlstool-{{ certs_gen_tool_version }}.zip"
|
||||
register: tool_package
|
||||
|
||||
- name: Local action | Download certificates generation tool
|
||||
local_action:
|
||||
module: get_url
|
||||
get_url:
|
||||
url: "{{ certs_gen_tool_url }}"
|
||||
dest: "{{ local_certs_path }}/search-guard-tlstool-{{ certs_gen_tool_version }}.zip"
|
||||
run_once: true
|
||||
when: not tool_package.stat.exists
|
||||
|
||||
- name: Local action | Extract the certificates generation tool
|
||||
local_action:
|
||||
module: unarchive
|
||||
unarchive:
|
||||
src: "{{ local_certs_path }}/search-guard-tlstool-1.7.zip"
|
||||
dest: "{{ local_certs_path }}/"
|
||||
|
||||
- name: Local action | Add the execution bit to the binary
|
||||
local_action:
|
||||
module: file
|
||||
file:
|
||||
dest: "{{ local_certs_path }}/tools/sgtlstool.sh"
|
||||
mode: a+x
|
||||
run_once: true
|
||||
|
||||
- name: Local action | Prepare the certificates generation template file
|
||||
local_action:
|
||||
module: template
|
||||
template:
|
||||
src: "templates/tlsconfig.yml.j2"
|
||||
dest: "{{ local_certs_path }}/config/tlsconfig.yml"
|
||||
run_once: true
|
||||
register: tlsconfig_template
|
||||
|
||||
- name: Create a directory if it does not exist
|
||||
file:
|
||||
path: "{{ local_certs_path }}/certs/"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Local action | Check if root CA file exists
|
||||
local_action:
|
||||
module: stat
|
||||
path: "{{ local_certs_path }}/config/root-ca.key"
|
||||
stat:
|
||||
path: "{{ local_certs_path }}/certs/root-ca.key"
|
||||
register: root_ca_file
|
||||
|
||||
- name: Local action | Generate the node & admin certificates in local
|
||||
local_action:
|
||||
module: command {{ local_certs_path }}/tools/sgtlstool.sh -c {{ local_certs_path }}/config/tlsconfig.yml -ca -crt -t {{ local_certs_path }}/config/ -f -o
|
||||
run_once: true
|
||||
when: root_ca_file.stat.exists == False
|
||||
command: >-
|
||||
{{ local_certs_path }}/tools/sgtlstool.sh
|
||||
-c {{ local_certs_path }}/config/tlsconfig.yml
|
||||
-ca -crt
|
||||
-t {{ local_certs_path }}/certs/
|
||||
-f -o
|
||||
when:
|
||||
- not root_ca_file.stat.exists
|
||||
- tlsconfig_template.changed
|
||||
|
||||
- name: Local action | Generate the node & admin certificates using an existing root CA
|
||||
command: >-
|
||||
{{ local_certs_path }}/tools/sgtlstool.sh
|
||||
-c {{ local_certs_path }}/config/tlsconfig.yml
|
||||
-crt
|
||||
-t {{ local_certs_path }}/certs/
|
||||
-f
|
||||
when:
|
||||
- root_ca_file.stat.exists
|
||||
- tlsconfig_template.changed
|
||||
|
||||
run_once: true
|
||||
delegate_to: localhost
|
||||
tags:
|
||||
- generate-certs
|
||||
@ -1,5 +1,4 @@
|
||||
- block:
|
||||
|
||||
- name: Remove demo certs
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
@ -12,7 +11,7 @@
|
||||
|
||||
- name: Copy the node & admin certificates to Elasticsearch cluster
|
||||
copy:
|
||||
src: "{{ local_certs_path }}/config/{{ item }}"
|
||||
src: "{{ local_certs_path }}/certs/{{ item }}"
|
||||
dest: /etc/elasticsearch/
|
||||
mode: 0644
|
||||
with_items:
|
||||
@ -28,7 +27,7 @@
|
||||
|
||||
- name: Copy the OpenDistro security configuration file to cluster
|
||||
blockinfile:
|
||||
block: "{{ lookup('file', '{{ local_certs_path }}/config/{{ inventory_hostname }}_elasticsearch_config_snippet.yml') }}"
|
||||
block: "{{ lookup('file', '{{ local_certs_path }}/certs/{{ inventory_hostname }}_elasticsearch_config_snippet.yml') }}"
|
||||
dest: "{{ opendistro_conf_path }}/elasticsearch.yml"
|
||||
insertafter: EOF
|
||||
marker: "## {mark} Opendistro Security Node & Admin certificates configuration ##"
|
||||
@ -76,5 +75,5 @@
|
||||
run_once: true
|
||||
|
||||
tags:
|
||||
- production_ready
|
||||
- security
|
||||
when: install.changed
|
||||
@ -17,7 +17,6 @@ defaults:
|
||||
verifyHostnames: false
|
||||
resolveHostnames: false
|
||||
|
||||
|
||||
###
|
||||
### Nodes
|
||||
###
|
||||
@ -25,13 +24,28 @@ defaults:
|
||||
# Specify the nodes of your ES cluster here
|
||||
#
|
||||
nodes:
|
||||
{% for item in groups['es-cluster'] %}
|
||||
{% for item in groups['es_cluster'] %}
|
||||
- name: {{ item }}
|
||||
dn: CN={{ item }}.{{ domain_name }},OU=Ops,O={{ domain_name }}\, Inc.,DC={{ domain_name }}
|
||||
dns: {{ item }}.{{ domain_name }}
|
||||
ip: {{ hostvars[item]['ip'] }}
|
||||
{% endfor %}
|
||||
|
||||
{% if groups['kibana'] is defined and groups['kibana']|length > 0 %}
|
||||
{% for item in groups['kibana'] %}
|
||||
- name: {{ item }}
|
||||
dn: CN={{ item }}.{{ domain_name }},OU=Ops,O={{ domain_name }}\, Inc.,DC={{ domain_name }}
|
||||
dns: {{ item }}.{{ domain_name }}
|
||||
ip: {{ hostvars[item]['ip'] }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if groups['managers'] is defined and groups['managers']|length > 0 %}
|
||||
{% for item in groups['managers'] %}
|
||||
- name: {{ item }}
|
||||
dn: CN={{ item }}.{{ domain_name }},OU=Ops,O={{ domain_name }}\, Inc.,DC={{ domain_name }}
|
||||
dns: {{ item }}.{{ domain_name }}
|
||||
ip: {{ hostvars[item]['ip'] }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
###
|
||||
### Clients
|
||||
###
|
||||
|
||||
62
roles/opendistro/opendistro-kibana/defaults/main.yml
Normal file
62
roles/opendistro/opendistro-kibana/defaults/main.yml
Normal file
@ -0,0 +1,62 @@
|
||||
---
|
||||
|
||||
elasticsearch_http_port: 9200
|
||||
elasticsearch_nodes: |-
|
||||
{% for item in groups['es_cluster'] -%}
|
||||
{{ hostvars[item]['ip'] }}{% if not loop.last %}","{% endif %}
|
||||
{%- endfor %}
|
||||
elasticsearch_network_host: 172.16.0.161
|
||||
elastic_api_protocol: https
|
||||
kibana_conf_path: /etc/kibana
|
||||
kibana_server_host: "0.0.0.0"
|
||||
kibana_server_port: "5601"
|
||||
kibana_server_name: "kibana"
|
||||
kibana_max_payload_bytes: 1048576
|
||||
elastic_stack_version: 7.7.0
|
||||
wazuh_version: 3.12.3
|
||||
wazuh_app_url: https://packages.wazuh.com/wazuhapp/wazuhapp
|
||||
|
||||
# The OpenDistro package repository
|
||||
package_repos:
|
||||
yum:
|
||||
opendistro:
|
||||
baseurl: 'https://d3g5vo6xdbdb9a.cloudfront.net/yum/noarch/'
|
||||
gpg: 'https://d3g5vo6xdbdb9a.cloudfront.net/GPG-KEY-opendistroforelasticsearch'
|
||||
elasticsearch_oss:
|
||||
baseurl: 'https://artifacts.elastic.co/packages/oss-7.x/yum'
|
||||
gpg: 'https://artifacts.elastic.co/GPG-KEY-elasticsearch'
|
||||
|
||||
|
||||
# API credentials
|
||||
wazuh_api_credentials:
|
||||
- id: "default"
|
||||
url: "http://localhost"
|
||||
port: 55000
|
||||
user: "foo"
|
||||
password: "bar"
|
||||
|
||||
# opendistro Security
|
||||
kibana_opendistro_security: true
|
||||
kibana_newsfeed_enabled: "false"
|
||||
kibana_telemetry_optin: "false"
|
||||
kibana_telemetry_enabled: "false"
|
||||
|
||||
opendistro_security_user: elastic
|
||||
opendistro_admin_password: changeme
|
||||
opendistro_kibana_user: kibanaserver
|
||||
opendistro_kibana_password: changeme
|
||||
local_certs_path: /tmp/opendistro-nodecerts
|
||||
|
||||
# Nodejs
|
||||
nodejs:
|
||||
repo_dict:
|
||||
debian: "deb"
|
||||
redhat: "rpm"
|
||||
repo_url_ext: "nodesource.com/setup_10.x"
|
||||
|
||||
# Build from sources
|
||||
build_from_sources: false
|
||||
wazuh_plugin_branch: 3.12-7.6
|
||||
|
||||
#Nodejs NODE_OPTIONS
|
||||
node_options: --no-warnings --max-old-space-size=2048 --max-http-header-size=65536
|
||||
3
roles/opendistro/opendistro-kibana/handlers/main.yml
Normal file
3
roles/opendistro/opendistro-kibana/handlers/main.yml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
- name: restart kibana
|
||||
service: name=kibana state=restarted
|
||||
6
roles/opendistro/opendistro-kibana/tasks/RMRedHat.yml
Normal file
6
roles/opendistro/opendistro-kibana/tasks/RMRedHat.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: Remove Elasticsearch repository (and clean up left-over metadata)
|
||||
yum_repository:
|
||||
name: opendistro_repo
|
||||
state: absent
|
||||
changed_when: false
|
||||
23
roles/opendistro/opendistro-kibana/tasks/RedHat.yml
Normal file
23
roles/opendistro/opendistro-kibana/tasks/RedHat.yml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
- block:
|
||||
|
||||
- name: RedHat/CentOS/Fedora | Add OpenDistro repo
|
||||
yum_repository:
|
||||
file: opendistro
|
||||
name: opendistro_repo
|
||||
description: Opendistro yum repository
|
||||
baseurl: "{{ package_repos.yum.opendistro.baseurl }}"
|
||||
gpgkey: "{{ package_repos.yum.opendistro.gpg }}"
|
||||
gpgcheck: true
|
||||
|
||||
- name: RedHat/CentOS/Fedora | Add Elasticsearch-oss repo
|
||||
yum_repository:
|
||||
file: opendistro
|
||||
name: elasticsearch_oss_repo
|
||||
description: Elasticsearch-oss yum repository
|
||||
baseurl: "{{ package_repos.yum.elasticsearch_oss.baseurl }}"
|
||||
gpgkey: "{{ package_repos.yum.elasticsearch_oss.gpg }}"
|
||||
gpgcheck: true
|
||||
|
||||
tags:
|
||||
- install
|
||||
@ -0,0 +1,76 @@
|
||||
---
|
||||
- name: Ensure the Git package is present
|
||||
package:
|
||||
name: git
|
||||
state: present
|
||||
|
||||
- name: Modify repo url if host is in Debian family
|
||||
set_fact:
|
||||
node_js_repo_type: deb
|
||||
when:
|
||||
- ansible_os_family | lower == "debian"
|
||||
|
||||
- name: Download script to install Nodejs repository
|
||||
get_url:
|
||||
url: "https://{{ nodejs['repo_dict'][ansible_os_family|lower] }}.{{ nodejs['repo_url_ext'] }}"
|
||||
dest: "/tmp/setup_nodejs_repo.sh"
|
||||
mode: 0700
|
||||
|
||||
- name: Execute downloaded script to install Nodejs repo
|
||||
command: /tmp/setup_nodejs_repo.sh
|
||||
register: node_repo_installation_result
|
||||
changed_when: false
|
||||
|
||||
- name: Install Nodejs
|
||||
package:
|
||||
name: nodejs
|
||||
state: present
|
||||
|
||||
- name: Install yarn dependency to build the Wazuh Kibana Plugin
|
||||
# Using shell due to errors when evaluating text between @ with command
|
||||
shell: "npm install -g {{ 'yarn' }}{{ '@' }}{{ '1.10.1'}}" # noqa 305
|
||||
register: install_yarn_result
|
||||
changed_when: install_yarn_result == 0
|
||||
|
||||
- name: Remove old wazuh-kibana-app git directory
|
||||
file:
|
||||
path: /tmp/app
|
||||
state: absent
|
||||
changed_when: false
|
||||
|
||||
- name: Clone wazuh-kibana-app repository # Using command as git module doesn't cover single-branch nor depth
|
||||
command: git clone https://github.com/wazuh/wazuh-kibana-app -b {{ wazuh_plugin_branch }} --single-branch --depth=1 app # noqa 303
|
||||
register: clone_app_repo_result
|
||||
changed_when: false
|
||||
args:
|
||||
chdir: "/tmp"
|
||||
|
||||
- name: Executing yarn to build the package
|
||||
command: "{{ item }}"
|
||||
with_items:
|
||||
- "yarn"
|
||||
- "yarn build"
|
||||
register: yarn_execution_result
|
||||
changed_when: false
|
||||
args:
|
||||
chdir: "/tmp/app/"
|
||||
|
||||
- name: Obtain name of generated package
|
||||
shell: "find ./ -name 'wazuh-*.zip' -printf '%f\\n'"
|
||||
register: wazuhapp_package_name
|
||||
changed_when: false
|
||||
args:
|
||||
chdir: "/tmp/app/build"
|
||||
|
||||
- name: Install Wazuh Plugin (can take a while)
|
||||
shell: NODE_OPTIONS="{{ node_options }}" /usr/share/kibana/bin/kibana-plugin install file:///tmp/app/build/{{ wazuhapp_package_name.stdout }}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
creates: /usr/share/kibana/plugins/wazuh/package.json
|
||||
chdir: /usr/share/kibana
|
||||
become: yes
|
||||
become_user: kibana
|
||||
notify: restart kibana
|
||||
tags:
|
||||
- install
|
||||
- skip_ansible_lint
|
||||
133
roles/opendistro/opendistro-kibana/tasks/main.yml
Normal file
133
roles/opendistro/opendistro-kibana/tasks/main.yml
Normal file
@ -0,0 +1,133 @@
|
||||
---
|
||||
|
||||
- name: Stopping early, trying to compile Wazuh Kibana Plugin on Debian 10 is not possible
|
||||
fail:
|
||||
msg: "It's not possible to compile the Wazuh Kibana plugin on Debian 10 due to: https://github.com/wazuh/wazuh-kibana-app/issues/1924"
|
||||
when:
|
||||
- build_from_sources
|
||||
- ansible_distribution == "Debian"
|
||||
- ansible_distribution_major_version == "10"
|
||||
|
||||
- import_tasks: RedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Reload systemd
|
||||
systemd:
|
||||
daemon_reload: true
|
||||
ignore_errors: true
|
||||
when:
|
||||
- not (ansible_distribution == "Amazon" and ansible_distribution_version == "(Karoo)")
|
||||
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('15.04', '<'))
|
||||
- not (ansible_distribution == "Debian" and ansible_distribution_version is version('8', '<'))
|
||||
- not (ansible_os_family == "RedHat" and ansible_distribution_version is version('7', '<'))
|
||||
|
||||
- name: Install Kibana
|
||||
package:
|
||||
name: opendistroforelasticsearch-kibana
|
||||
state: present
|
||||
register: install
|
||||
tags: install
|
||||
|
||||
- name: Remove Kibana configuration file
|
||||
file:
|
||||
path: "{{ kibana_conf_path }}/kibana.yml"
|
||||
state: absent
|
||||
when: install.changed
|
||||
tags: install
|
||||
|
||||
- import_tasks: security_actions.yml
|
||||
|
||||
- name: Copy Configuration File
|
||||
blockinfile:
|
||||
block: "{{ lookup('template', 'opendistro_kibana.yml.j2') }}"
|
||||
dest: "{{ kibana_conf_path }}/kibana.yml"
|
||||
create: true
|
||||
group: kibana
|
||||
owner: kibana
|
||||
mode: 0640
|
||||
marker: "## {mark} Kibana general settings ##"
|
||||
notify: restart kibana
|
||||
tags:
|
||||
- install
|
||||
- configure
|
||||
|
||||
- name: Build and Install Wazuh Kibana Plugin from sources
|
||||
import_tasks: build_wazuh_plugin.yml
|
||||
when:
|
||||
- build_from_sources is defined
|
||||
- build_from_sources
|
||||
|
||||
- name: Install Wazuh Plugin (can take a while)
|
||||
shell: >-
|
||||
NODE_OPTIONS="{{ node_options }}" /usr/share/kibana/bin/kibana-plugin install
|
||||
{{ wazuh_app_url }}-{{ wazuh_version }}_{{ elastic_stack_version }}.zip
|
||||
args:
|
||||
executable: /bin/bash
|
||||
creates: /usr/share/kibana/plugins/wazuh/package.json
|
||||
chdir: /usr/share/kibana
|
||||
become: yes
|
||||
become_user: kibana
|
||||
notify: restart kibana
|
||||
tags:
|
||||
- install
|
||||
- skip_ansible_lint
|
||||
when:
|
||||
- not build_from_sources
|
||||
|
||||
- name: Kibana optimization (can take a while)
|
||||
shell: /usr/share/kibana/node/bin/node {{ node_options }} /usr/share/kibana/src/cli --optimize
|
||||
args:
|
||||
executable: /bin/bash
|
||||
become: yes
|
||||
become_user: kibana
|
||||
changed_when: false
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: Wait for Elasticsearch port
|
||||
wait_for: host={{ elasticsearch_network_host }} port={{ elasticsearch_http_port }}
|
||||
|
||||
- name: Select correct API protocol
|
||||
set_fact:
|
||||
elastic_api_protocol: "{% if kibana_opendistro_security is defined and kibana_opendistro_security %}https{% else %}http{% endif %}"
|
||||
|
||||
- name: Attempting to delete legacy Wazuh index if exists
|
||||
uri:
|
||||
url: "{{ elastic_api_protocol }}://{{ elasticsearch_network_host }}:{{ elasticsearch_http_port }}/.wazuh"
|
||||
method: DELETE
|
||||
user: "admin"
|
||||
password: "{{ opendistro_admin_password }}"
|
||||
validate_certs: no
|
||||
status_code: 200, 404
|
||||
|
||||
- name: Create wazuh plugin config directory
|
||||
file:
|
||||
path: /usr/share/kibana/optimize/wazuh/config/
|
||||
state: directory
|
||||
recurse: yes
|
||||
owner: kibana
|
||||
group: kibana
|
||||
mode: 0751
|
||||
changed_when: False
|
||||
|
||||
- name: Configure Wazuh Kibana Plugin
|
||||
template:
|
||||
src: wazuh.yml.j2
|
||||
dest: /usr/share/kibana/optimize/wazuh/config/wazuh.yml
|
||||
owner: kibana
|
||||
group: kibana
|
||||
mode: 0751
|
||||
changed_when: False
|
||||
|
||||
- name: Reload systemd configuration
|
||||
systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure Kibana started and enabled
|
||||
service:
|
||||
name: kibana
|
||||
enabled: true
|
||||
state: started
|
||||
|
||||
- import_tasks: RMRedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
@ -0,0 +1,13 @@
|
||||
- block:
|
||||
|
||||
- name: Copy the certificates from local to the Kibana instance
|
||||
copy:
|
||||
src: "{{ local_certs_path }}/certs/{{ item }}"
|
||||
dest: /usr/share/kibana
|
||||
mode: 0644
|
||||
with_items:
|
||||
- "{{ inventory_hostname }}_http.key"
|
||||
- "{{ inventory_hostname }}_http.pem"
|
||||
tags:
|
||||
- security
|
||||
when: install.changed
|
||||
@ -0,0 +1,38 @@
|
||||
# {{ ansible_managed }}
|
||||
# Description:
|
||||
# Default Kibana configuration for Open Distro.
|
||||
server.port: {{ kibana_server_port }}
|
||||
|
||||
#server.basePath: ""
|
||||
server.maxPayloadBytes: {{ kibana_max_payload_bytes }}
|
||||
server.name: {{ kibana_server_name }}
|
||||
server.host: {{ kibana_server_host }}
|
||||
|
||||
|
||||
{% if kibana_opendistro_security %}
|
||||
elasticsearch.hosts: "https://{{ elasticsearch_network_host }}:{{ elasticsearch_http_port }}"
|
||||
{% else %}
|
||||
elasticsearch.hosts: "http://{{ elasticsearch_network_host }}:{{ elasticsearch_http_port }}"
|
||||
{% endif %}
|
||||
|
||||
elasticsearch.username: {{ opendistro_kibana_user }}
|
||||
elasticsearch.password: {{ opendistro_kibana_password }}
|
||||
elasticsearch.ssl.verificationMode: none
|
||||
|
||||
elasticsearch.requestHeadersWhitelist: ["securitytenant","Authorization"]
|
||||
opendistro_security.multitenancy.enabled: false # FIXME: should be enabled starting with Wazuh App v3.13
|
||||
opendistro_security.multitenancy.tenants.preferred: ["Private", "Global"]
|
||||
opendistro_security.readonly_mode.roles: ["kibana_read_only"]
|
||||
|
||||
# OpenDistro Security
|
||||
{% if kibana_opendistro_security %}
|
||||
server.ssl.enabled: true
|
||||
server.ssl.certificate: "/usr/share/kibana/{{ inventory_hostname }}_http.pem"
|
||||
server.ssl.key: "/usr/share/kibana//{{ inventory_hostname }}_http.key"
|
||||
{% endif %}
|
||||
|
||||
newsfeed.enabled: {{ kibana_newsfeed_enabled }}
|
||||
telemetry.optIn: {{ kibana_telemetry_optin }}
|
||||
telemetry.enabled: {{ kibana_telemetry_enabled }}
|
||||
|
||||
|
||||
134
roles/opendistro/opendistro-kibana/templates/wazuh.yml.j2
Normal file
134
roles/opendistro/opendistro-kibana/templates/wazuh.yml.j2
Normal file
@ -0,0 +1,134 @@
|
||||
---
|
||||
#
|
||||
# Wazuh app - App configuration file
|
||||
# Copyright (C) 2015-2019 Wazuh, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Find more information about this on the LICENSE file.
|
||||
#
|
||||
# ======================== Wazuh app configuration file ========================
|
||||
#
|
||||
# Please check the documentation for more information on configuration options:
|
||||
# https://documentation.wazuh.com/current/installation-guide/index.html
|
||||
#
|
||||
# Also, you can check our repository:
|
||||
# https://github.com/wazuh/wazuh-kibana-app
|
||||
#
|
||||
# ------------------------------- Index patterns -------------------------------
|
||||
#
|
||||
# Default index pattern to use.
|
||||
#pattern: wazuh-alerts-3.x-*
|
||||
#
|
||||
# ----------------------------------- Checks -----------------------------------
|
||||
#
|
||||
# Defines which checks must to be consider by the healthcheck
|
||||
# step once the Wazuh app starts. Values must to be true or false.
|
||||
#checks.pattern : true
|
||||
#checks.template: true
|
||||
#checks.api : true
|
||||
#checks.setup : true
|
||||
#
|
||||
# --------------------------------- Extensions ---------------------------------
|
||||
#
|
||||
# Defines which extensions should be activated when you add a new API entry.
|
||||
# You can change them after Wazuh app starts.
|
||||
# Values must to be true or false.
|
||||
#extensions.pci : true
|
||||
#extensions.gdpr : true
|
||||
#extensions.hipaa : true
|
||||
#extensions.nist : true
|
||||
#extensions.audit : true
|
||||
#extensions.oscap : false
|
||||
#extensions.ciscat : false
|
||||
#extensions.aws : false
|
||||
#extensions.virustotal: false
|
||||
#extensions.osquery : false
|
||||
#extensions.docker : false
|
||||
#
|
||||
# ---------------------------------- Time out ----------------------------------
|
||||
#
|
||||
# Defines maximum timeout to be used on the Wazuh app requests.
|
||||
# It will be ignored if it is bellow 1500.
|
||||
# It means milliseconds before we consider a request as failed.
|
||||
# Default: 20000
|
||||
#timeout: 20000
|
||||
#
|
||||
# ------------------------------ Advanced indices ------------------------------
|
||||
#
|
||||
# Configure .wazuh indices shards and replicas.
|
||||
#wazuh.shards : 1
|
||||
#wazuh.replicas : 0
|
||||
#
|
||||
# --------------------------- Index pattern selector ---------------------------
|
||||
#
|
||||
# Defines if the user is allowed to change the selected
|
||||
# index pattern directly from the Wazuh app top menu.
|
||||
# Default: true
|
||||
#ip.selector: true
|
||||
#
|
||||
# List of index patterns to be ignored
|
||||
#ip.ignore: []
|
||||
#
|
||||
# -------------------------------- X-Pack RBAC ---------------------------------
|
||||
#
|
||||
# Custom setting to enable/disable built-in X-Pack RBAC security capabilities.
|
||||
# Default: enabled
|
||||
#xpack.rbac.enabled: true
|
||||
#
|
||||
# ------------------------------ wazuh-monitoring ------------------------------
|
||||
#
|
||||
# Custom setting to enable/disable wazuh-monitoring indices.
|
||||
# Values: true, false, worker
|
||||
# If worker is given as value, the app will show the Agents status
|
||||
# visualization but won't insert data on wazuh-monitoring indices.
|
||||
# Default: true
|
||||
#wazuh.monitoring.enabled: true
|
||||
#
|
||||
# Custom setting to set the frequency for wazuh-monitoring indices cron task.
|
||||
# Default: 900 (s)
|
||||
#wazuh.monitoring.frequency: 900
|
||||
#
|
||||
# Configure wazuh-monitoring-3.x-* indices shards and replicas.
|
||||
#wazuh.monitoring.shards: 2
|
||||
#wazuh.monitoring.replicas: 0
|
||||
#
|
||||
# Configure wazuh-monitoring-3.x-* indices custom creation interval.
|
||||
# Values: h (hourly), d (daily), w (weekly), m (monthly)
|
||||
# Default: d
|
||||
#wazuh.monitoring.creation: d
|
||||
#
|
||||
# Default index pattern to use for Wazuh monitoring
|
||||
#wazuh.monitoring.pattern: wazuh-monitoring-3.x-*
|
||||
#
|
||||
#
|
||||
# ------------------------------- App privileges --------------------------------
|
||||
#admin: true
|
||||
#
|
||||
# ------------------------------- App logging level -----------------------------
|
||||
# Set the logging level for the Wazuh App log files.
|
||||
# Default value: info
|
||||
# Allowed values: info, debug
|
||||
#logs.level: info
|
||||
#
|
||||
#-------------------------------- API entries -----------------------------------
|
||||
#The following configuration is the default structure to define an API entry.
|
||||
#
|
||||
#hosts:
|
||||
# - <id>:
|
||||
# url: http(s)://<url>
|
||||
# port: <port>
|
||||
# user: <user>
|
||||
# password: <password>
|
||||
|
||||
hosts:
|
||||
{% for api in wazuh_api_credentials %}
|
||||
- {{ api['id'] }}:
|
||||
url: {{ api['url'] }}
|
||||
port: {{ api['port'] }}
|
||||
user: {{ api['user'] }}
|
||||
password: {{ api['password'] }}
|
||||
{% endfor %}
|
||||
39
roles/wazuh/ansible-filebeat-oss/README.md
Normal file
39
roles/wazuh/ansible-filebeat-oss/README.md
Normal file
@ -0,0 +1,39 @@
|
||||
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_elasticsearch_enabled: false
|
||||
filebeat_output_elasticsearch_hosts:
|
||||
- "localhost:9200"
|
||||
|
||||
```
|
||||
|
||||
License and copyright
|
||||
---------------------
|
||||
|
||||
WAZUH Copyright (C) 2020 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.
|
||||
30
roles/wazuh/ansible-filebeat-oss/defaults/main.yml
Normal file
30
roles/wazuh/ansible-filebeat-oss/defaults/main.yml
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
filebeat_version: 7.7.0
|
||||
|
||||
filebeat_create_config: true
|
||||
|
||||
filebeat_output_elasticsearch_enabled: false
|
||||
filebeat_output_elasticsearch_hosts:
|
||||
- "localhost:9200"
|
||||
|
||||
filebeat_module_package_url: https://packages.wazuh.com/3.x/filebeat
|
||||
filebeat_module_package_name: wazuh-filebeat-0.1.tar.gz
|
||||
filebeat_module_package_path: /tmp/
|
||||
filebeat_module_destination: /usr/share/filebeat/module
|
||||
filebeat_module_folder: /usr/share/filebeat/module/wazuh
|
||||
elasticsearch_security_user: admin
|
||||
elasticsearch_security_password: changeme
|
||||
# Security plugin
|
||||
filebeat_security: true
|
||||
filebeat_security_user: admin
|
||||
filebeat_security_password: changeme
|
||||
filebeat_ssl_dir: /etc/pki/filebeat
|
||||
|
||||
# Local path to store the generated certificates (OpenDistro security plugin)
|
||||
local_certs_path: /tmp/opendistro-nodecerts
|
||||
|
||||
elasticrepo:
|
||||
apt: 'https://artifacts.elastic.co/packages/oss-7.x/apt'
|
||||
yum: 'https://artifacts.elastic.co/packages/oss-7.x/yum'
|
||||
gpg: 'https://artifacts.elastic.co/GPG-KEY-elasticsearch'
|
||||
key_id: '46095ACC8548582C1A2699A9D27D666CD88E42B4'
|
||||
3
roles/wazuh/ansible-filebeat-oss/handlers/main.yml
Normal file
3
roles/wazuh/ansible-filebeat-oss/handlers/main.yml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
- name: restart filebeat
|
||||
service: name=filebeat state=restarted
|
||||
29
roles/wazuh/ansible-filebeat-oss/meta/main.yml
Normal file
29
roles/wazuh/ansible-filebeat-oss/meta/main.yml
Normal file
@ -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
|
||||
22
roles/wazuh/ansible-filebeat-oss/tasks/Debian.yml
Normal file
22
roles/wazuh/ansible-filebeat-oss/tasks/Debian.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
- name: Debian/Ubuntu | Install apt-transport-https and ca-certificates
|
||||
apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
state: present
|
||||
register: filebeat_ca_packages_install
|
||||
until: filebeat_ca_packages_install is succeeded
|
||||
|
||||
- name: Debian/Ubuntu | Add Elasticsearch apt key.
|
||||
apt_key:
|
||||
url: "{{ elasticrepo.gpg }}"
|
||||
id: "{{ elasticrepo.key_id }}"
|
||||
state: present
|
||||
|
||||
- name: Debian/Ubuntu | Add Filebeat-oss repository.
|
||||
apt_repository:
|
||||
repo: "deb {{ elasticrepo.apt }} stable main"
|
||||
state: present
|
||||
update_cache: true
|
||||
changed_when: false
|
||||
6
roles/wazuh/ansible-filebeat-oss/tasks/RMDebian.yml
Normal file
6
roles/wazuh/ansible-filebeat-oss/tasks/RMDebian.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: Debian/Ubuntu | Remove Filebeat repository (and clean up left-over metadata)
|
||||
apt_repository:
|
||||
repo: "deb {{ elasticrepo.apt }} stable main"
|
||||
state: absent
|
||||
changed_when: false
|
||||
6
roles/wazuh/ansible-filebeat-oss/tasks/RMRedHat.yml
Normal file
6
roles/wazuh/ansible-filebeat-oss/tasks/RMRedHat.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: RedHat/CentOS/Fedora | Remove Filebeat repository (and clean up left-over metadata)
|
||||
yum_repository:
|
||||
name: elastic_oss-repo_7
|
||||
state: absent
|
||||
changed_when: false
|
||||
9
roles/wazuh/ansible-filebeat-oss/tasks/RedHat.yml
Normal file
9
roles/wazuh/ansible-filebeat-oss/tasks/RedHat.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: RedHat/CentOS/Fedora/Amazon Linux | Install Filebeats repo
|
||||
yum_repository:
|
||||
name: elastic_oss-repo_7
|
||||
description: Elastic repository for 7.x packages
|
||||
baseurl: "{{ elasticrepo.yum }}"
|
||||
gpgkey: "{{ elasticrepo.gpg }}"
|
||||
gpgcheck: true
|
||||
changed_when: false
|
||||
22
roles/wazuh/ansible-filebeat-oss/tasks/config.yml
Normal file
22
roles/wazuh/ansible-filebeat-oss/tasks/config.yml
Normal file
@ -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: Copy Elasticsearch template.
|
||||
template:
|
||||
src: elasticsearch.yml.j2
|
||||
dest: "/etc/filebeat/wazuh-template.json"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0400
|
||||
notify: restart filebeat
|
||||
|
||||
tags:
|
||||
- configure
|
||||
67
roles/wazuh/ansible-filebeat-oss/tasks/main.yml
Normal file
67
roles/wazuh/ansible-filebeat-oss/tasks/main.yml
Normal file
@ -0,0 +1,67 @@
|
||||
---
|
||||
- include_tasks: RedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- include_tasks: Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Install Filebeat
|
||||
package:
|
||||
name: filebeat
|
||||
state: present
|
||||
register: install
|
||||
tags:
|
||||
- install
|
||||
- init
|
||||
|
||||
- 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"
|
||||
28
roles/wazuh/ansible-filebeat-oss/tasks/security_actions.yml
Normal file
28
roles/wazuh/ansible-filebeat-oss/tasks/security_actions.yml
Normal file
@ -0,0 +1,28 @@
|
||||
- block:
|
||||
|
||||
- name: Ensure Filebeat SSL key pair directory exists.
|
||||
file:
|
||||
path: "{{ filebeat_ssl_dir }}"
|
||||
state: directory
|
||||
|
||||
- name: Copy the certificates from local to the Manager instance
|
||||
copy:
|
||||
src: "{{ local_certs_path }}/certs/{{ item }}"
|
||||
dest: "{{ filebeat_ssl_dir }}"
|
||||
mode: 0644
|
||||
with_items:
|
||||
- "{{ inventory_hostname }}.key"
|
||||
- "{{ inventory_hostname }}.pem"
|
||||
- "root-ca.pem"
|
||||
|
||||
- name: Ensuring folder & certs permissions
|
||||
file:
|
||||
path: "{{ filebeat_ssl_dir }}/"
|
||||
mode: 0774
|
||||
state: directory
|
||||
recurse: yes
|
||||
|
||||
tags:
|
||||
- security
|
||||
when:
|
||||
- filebeat_security
|
||||
1800
roles/wazuh/ansible-filebeat-oss/templates/elasticsearch.yml.j2
Normal file
1800
roles/wazuh/ansible-filebeat-oss/templates/elasticsearch.yml.j2
Normal file
File diff suppressed because it is too large
Load Diff
32
roles/wazuh/ansible-filebeat-oss/templates/filebeat.yml.j2
Normal file
32
roles/wazuh/ansible-filebeat-oss/templates/filebeat.yml.j2
Normal file
@ -0,0 +1,32 @@
|
||||
# Wazuh - Filebeat configuration file
|
||||
|
||||
# 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 Elasticsearch
|
||||
output.elasticsearch:
|
||||
hosts: {{ filebeat_output_elasticsearch_hosts | to_json }}
|
||||
|
||||
{% if filebeat_security %}
|
||||
username: {{ elasticsearch_security_user }}
|
||||
password: {{ elasticsearch_security_password }}
|
||||
protocol: https
|
||||
ssl.certificate_authorities:
|
||||
- {{ filebeat_ssl_dir }}/root-ca.pem
|
||||
ssl.certificate: "{{ filebeat_ssl_dir }}/{{ inventory_hostname }}.pem"
|
||||
ssl.key: "{{ filebeat_ssl_dir }}/{{ inventory_hostname }}.key"
|
||||
{% endif %}
|
||||
|
||||
# Optional. Send events to Logstash instead of Elasticsearch
|
||||
#output.logstash.hosts: ["YOUR_LOGSTASH_SERVER_IP:5000"]
|
||||
@ -28,7 +28,7 @@ Available variables are listed below, along with default values (see `defaults/m
|
||||
License and copyright
|
||||
---------------------
|
||||
|
||||
WAZUH Copyright (C) 2017 Wazuh Inc. (License GPLv3)
|
||||
WAZUH Copyright (C) 2020 Wazuh Inc. (License GPLv3)
|
||||
|
||||
### Based on previous work from geerlingguy
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
filebeat_version: 7.6.2
|
||||
filebeat_version: 7.7.0
|
||||
|
||||
filebeat_create_config: true
|
||||
|
||||
@ -22,10 +22,8 @@ filebeat_enable_logging: true
|
||||
filebeat_log_level: debug
|
||||
filebeat_log_dir: /var/log/mybeat
|
||||
filebeat_log_filename: mybeat.log
|
||||
|
||||
filebeat_ssl_dir: /etc/pki/filebeat
|
||||
filebeat_ssl_certificate_file: ""
|
||||
filebeat_ssl_key_file: ""
|
||||
filebeat_ssl_insecure: "false"
|
||||
|
||||
filebeat_module_package_url: https://packages.wazuh.com/3.x/filebeat
|
||||
@ -46,7 +44,7 @@ node_certs_destination: /etc/filebeat/certs
|
||||
|
||||
|
||||
# CA Generation
|
||||
master_certs_path: /es_certs
|
||||
master_certs_path: "{{ playbook_dir }}/es_certs"
|
||||
generate_CA: true
|
||||
ca_cert_name: ""
|
||||
|
||||
|
||||
@ -18,22 +18,3 @@
|
||||
mode: 0400
|
||||
notify: restart filebeat
|
||||
tags: configure
|
||||
|
||||
- name: Ensure Filebeat SSL key pair directory exists.
|
||||
file:
|
||||
path: "{{ filebeat_ssl_dir }}"
|
||||
state: directory
|
||||
when: filebeat_ssl_key_file
|
||||
tags: configure
|
||||
|
||||
- name: Copy SSL key and cert for filebeat.
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ filebeat_ssl_dir }}/{{ item | basename }}"
|
||||
mode: 0400
|
||||
with_items:
|
||||
- "{{ filebeat_ssl_key_file }}"
|
||||
- "{{ filebeat_ssl_certificate_file }}"
|
||||
notify: restart filebeat
|
||||
when: filebeat_ssl_key_file and filebeat_ssl_certificate_file
|
||||
tags: configure
|
||||
|
||||
@ -30,6 +30,8 @@
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ node_certs_destination }}/"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0440
|
||||
with_items:
|
||||
- "{{ master_certs_path }}/{{ filebeat_node_name }}/{{ filebeat_node_name }}.key"
|
||||
@ -44,6 +46,8 @@
|
||||
copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ node_certs_destination }}/"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0440
|
||||
with_items:
|
||||
- "{{ master_certs_path }}/{{ filebeat_node_name }}/{{ filebeat_node_name }}.key"
|
||||
@ -57,9 +61,9 @@
|
||||
- name: Ensuring folder & certs permissions
|
||||
file:
|
||||
path: "{{ node_certs_destination }}/"
|
||||
mode: 0774
|
||||
mode: 0770
|
||||
state: directory
|
||||
recurse: yes
|
||||
recurse: no
|
||||
when:
|
||||
- filebeat_xpack_security
|
||||
tags: xpack-security
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
---
|
||||
- src: geerlingguy.java
|
||||
- src: geerlingguy.elasticsearch
|
||||
@ -1,20 +0,0 @@
|
||||
---
|
||||
- hosts: all
|
||||
|
||||
pre_tasks:
|
||||
- name: Update apt cache.
|
||||
apt:
|
||||
cache_valid_time: 600
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Install test dependencies (RedHat).
|
||||
package: name=which state=present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Install test dependencies.
|
||||
package: name=curl state=present
|
||||
|
||||
roles:
|
||||
- geerlingguy.java
|
||||
- geerlingguy.elasticsearch
|
||||
- role_under_test
|
||||
@ -218,7 +218,7 @@ Including an example of how to use your role (for instance, with variables passe
|
||||
License and copyright
|
||||
---------------------
|
||||
|
||||
WAZUH Copyright (C) 2017 Wazuh Inc. (License GPLv3)
|
||||
WAZUH Copyright (C) 2020 Wazuh Inc. (License GPLv3)
|
||||
|
||||
### Based on previous work from dj-wasabi
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@
|
||||
- name: Installing the local_rules.xml (default local_rules.xml)
|
||||
template: src=var-ossec-rules-local_rules.xml.j2
|
||||
dest=/var/ossec/etc/rules/local_rules.xml
|
||||
owner=root
|
||||
owner=ossec
|
||||
group=ossec
|
||||
mode=0640
|
||||
notify: restart wazuh-manager
|
||||
@ -118,7 +118,7 @@
|
||||
- name: Adding local rules files
|
||||
copy: src="{{ wazuh_manager_config.ruleset.rules_path }}"
|
||||
dest=/var/ossec/etc/rules/
|
||||
owner=root
|
||||
owner=ossec
|
||||
group=ossec
|
||||
mode=0640
|
||||
notify: restart wazuh-manager
|
||||
@ -130,7 +130,7 @@
|
||||
- name: Installing the local_decoder.xml
|
||||
template: src=var-ossec-rules-local_decoder.xml.j2
|
||||
dest=/var/ossec/etc/decoders/local_decoder.xml
|
||||
owner=root
|
||||
owner=ossec
|
||||
group=ossec
|
||||
mode=0640
|
||||
notify: restart wazuh-manager
|
||||
@ -142,7 +142,7 @@
|
||||
- name: Adding local decoders files
|
||||
copy: src="{{ wazuh_manager_config.ruleset.decoders_path }}"
|
||||
dest=/var/ossec/etc/decoders/
|
||||
owner=root
|
||||
owner=ossec
|
||||
group=ossec
|
||||
mode=0640
|
||||
notify: restart wazuh-manager
|
||||
|
||||
Loading…
Reference in New Issue
Block a user