Added comments in tests;Added some skip tasks
This commit is contained in:
parent
c0e60a1a5a
commit
a3425d04ac
@ -9,3 +9,5 @@ script:
|
|||||||
- pipenv run agent
|
- pipenv run agent
|
||||||
- pipenv run elasticsearch
|
- pipenv run elasticsearch
|
||||||
- pipenv run logstash
|
- pipenv run logstash
|
||||||
|
- pipenv run filebeat
|
||||||
|
- pipenv run kibana
|
||||||
|
|||||||
2
Pipfile
2
Pipfile
@ -18,3 +18,5 @@ test ="molecule test"
|
|||||||
agent ="molecule test -s wazuh-agent"
|
agent ="molecule test -s wazuh-agent"
|
||||||
elasticsearch ="molecule test -s elasticsearch"
|
elasticsearch ="molecule test -s elasticsearch"
|
||||||
logstash ="molecule test -s logstash"
|
logstash ="molecule test -s logstash"
|
||||||
|
filebeat ="molecule test -s filebeat"
|
||||||
|
kibana ="molecule test -s kibana"
|
||||||
|
|||||||
@ -11,7 +11,7 @@ platforms:
|
|||||||
command: /sbin/init
|
command: /sbin/init
|
||||||
ulimits:
|
ulimits:
|
||||||
- nofile:262144:262144
|
- nofile:262144:262144
|
||||||
privileged: True
|
privileged: true
|
||||||
memory_reservation: 1024m
|
memory_reservation: 1024m
|
||||||
- name: xenial
|
- name: xenial
|
||||||
image: solita/ubuntu-systemd:xenial
|
image: solita/ubuntu-systemd:xenial
|
||||||
|
|||||||
@ -7,6 +7,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||||||
|
|
||||||
|
|
||||||
def test_elasticsearch_is_installed(host):
|
def test_elasticsearch_is_installed(host):
|
||||||
|
"""Test if the elasticsearch package is installed."""
|
||||||
elasticsearch = host.package("elasticsearch")
|
elasticsearch = host.package("elasticsearch")
|
||||||
assert elasticsearch.is_installed
|
assert elasticsearch.is_installed
|
||||||
assert elasticsearch.version.startswith('6.7.1')
|
assert elasticsearch.version.startswith('6.7.1')
|
||||||
|
|||||||
14
molecule/filebeat/Dockerfile.j2
Normal file
14
molecule/filebeat/Dockerfile.j2
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Molecule managed
|
||||||
|
|
||||||
|
{% if item.registry is defined %}
|
||||||
|
FROM {{ item.registry.url }}/{{ item.image }}
|
||||||
|
{% else %}
|
||||||
|
FROM {{ item.image }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
||||||
|
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
|
||||||
|
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
||||||
|
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
|
||||||
|
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
|
||||||
|
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
|
||||||
22
molecule/filebeat/INSTALL.rst
Normal file
22
molecule/filebeat/INSTALL.rst
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
*******
|
||||||
|
Docker driver installation guide
|
||||||
|
*******
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
============
|
||||||
|
|
||||||
|
* Docker Engine
|
||||||
|
|
||||||
|
Install
|
||||||
|
=======
|
||||||
|
|
||||||
|
Please refer to the `Virtual environment`_ documentation for installation best
|
||||||
|
practices. If not using a virtual environment, please consider passing the
|
||||||
|
widely recommended `'--user' flag`_ when invoking ``pip``.
|
||||||
|
|
||||||
|
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
|
||||||
|
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ pip install 'molecule[docker]'
|
||||||
42
molecule/filebeat/molecule.yml
Normal file
42
molecule/filebeat/molecule.yml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
platforms:
|
||||||
|
- name: trusty
|
||||||
|
image: ubuntu:trusty
|
||||||
|
- name: bionic
|
||||||
|
image: solita/ubuntu-systemd:bionic
|
||||||
|
command: /sbin/init
|
||||||
|
privileged: true
|
||||||
|
- name: xenial
|
||||||
|
image: solita/ubuntu-systemd:xenial
|
||||||
|
privileged: true
|
||||||
|
command: /sbin/init
|
||||||
|
- name: centos6
|
||||||
|
image: geerlingguy/docker-centos6-ansible
|
||||||
|
privileged: true
|
||||||
|
command: /sbin/init
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
- name: centos7
|
||||||
|
image: milcom/centos7-systemd
|
||||||
|
privileged: true
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
playbooks:
|
||||||
|
docker:
|
||||||
|
create: ../default/create.yml
|
||||||
|
destroy: ../default/destroy.yml
|
||||||
|
env:
|
||||||
|
ANSIBLE_ROLES_PATH: ../../roles
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
enabled: true
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
||||||
5
molecule/filebeat/playbook.yml
Normal file
5
molecule/filebeat/playbook.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- role: wazuh/ansible-filebeat
|
||||||
36
molecule/filebeat/prepare.yml
Normal file
36
molecule/filebeat/prepare.yml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: "Install Python packages for Trusty to solve trust issues"
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- python-setuptools
|
||||||
|
- python-pip
|
||||||
|
state: latest
|
||||||
|
register: wazuh_manager_trusty_packages_installed
|
||||||
|
until: wazuh_manager_trusty_packages_installed is succeeded
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Ubuntu"
|
||||||
|
- ansible_distribution_major_version | int == 14
|
||||||
|
|
||||||
|
- name: "Install dependencies"
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- curl
|
||||||
|
- net-tools
|
||||||
|
state: latest
|
||||||
|
register: wazuh_manager_dependencies_packages_installed
|
||||||
|
until: wazuh_manager_dependencies_packages_installed is succeeded
|
||||||
|
|
||||||
|
- name: "Install (RedHat) dependencies"
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- initscripts
|
||||||
|
state: latest
|
||||||
|
register: wazuh_manager_dependencies_packages_installed
|
||||||
|
until: wazuh_manager_dependencies_packages_installed is succeeded
|
||||||
|
when:
|
||||||
|
- ansible_os_family == 'RedHat'
|
||||||
19
molecule/filebeat/tests/test_default.py
Normal file
19
molecule/filebeat/tests/test_default.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||||
|
|
||||||
|
|
||||||
|
def test_logstash_is_installed(host):
|
||||||
|
"""Test if the filebeat package is installed."""
|
||||||
|
filebeat = host.package("filebeat")
|
||||||
|
assert filebeat.is_installed
|
||||||
|
|
||||||
|
|
||||||
|
def test_logstash_is_running(host):
|
||||||
|
"""Test if the services are enabled and running."""
|
||||||
|
filebeat = host.service("filebeat")
|
||||||
|
assert filebeat.is_enabled
|
||||||
|
assert filebeat.is_running
|
||||||
@ -11,7 +11,7 @@ platforms:
|
|||||||
command: /sbin/init
|
command: /sbin/init
|
||||||
ulimits:
|
ulimits:
|
||||||
- nofile:262144:262144
|
- nofile:262144:262144
|
||||||
privileged: True
|
privileged: true
|
||||||
memory_reservation: 1024m
|
memory_reservation: 1024m
|
||||||
- name: xenial
|
- name: xenial
|
||||||
image: solita/ubuntu-systemd:xenial
|
image: solita/ubuntu-systemd:xenial
|
||||||
|
|||||||
@ -7,6 +7,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||||||
|
|
||||||
|
|
||||||
def test_logstash_is_installed(host):
|
def test_logstash_is_installed(host):
|
||||||
|
"""Test if logstash is installed with correct version."""
|
||||||
logstash = host.package("logstash")
|
logstash = host.package("logstash")
|
||||||
assert logstash.is_installed
|
assert logstash.is_installed
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ def test_logstash_is_running(host):
|
|||||||
|
|
||||||
|
|
||||||
def test_find_correct_logentry(host):
|
def test_find_correct_logentry(host):
|
||||||
logfile = host.file("//var/log/logstash/logstash-plain.log")
|
"""See if logstash is started and is connected to Elasticsearch."""
|
||||||
|
logfile = host.file("/var/log/logstash/logstash-plain.log")
|
||||||
assert logfile.contains("Successfully started Logstash API endpoint")
|
assert logfile.contains("Successfully started Logstash API endpoint")
|
||||||
assert logfile.contains("Restored connection to ES instance")
|
assert logfile.contains("Restored connection to ES instance")
|
||||||
|
|||||||
@ -5,3 +5,4 @@ kibana_server_host: "0.0.0.0"
|
|||||||
kibana_server_port: "5601"
|
kibana_server_port: "5601"
|
||||||
elastic_stack_version: 6.7.1
|
elastic_stack_version: 6.7.1
|
||||||
wazuh_version: 3.8.2
|
wazuh_version: 3.8.2
|
||||||
|
kibana_plugin_install_ignore_error: false
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
---
|
---
|
||||||
- name: Debian/Ubuntu | Install apt-transport-https and ca-certificates
|
- name: Debian/Ubuntu | Install apt-transport-https and ca-certificates
|
||||||
apt:
|
apt:
|
||||||
name: ['apt-transport-https', 'ca-certificates']
|
name:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
state: present
|
state: present
|
||||||
|
register: kibana_installing_ca_package
|
||||||
|
until: kibana_installing_ca_package is succeeded
|
||||||
|
|
||||||
- name: Debian/Ubuntu | Add Elasticsearch GPG key
|
- name: Debian/Ubuntu | Add Elasticsearch GPG key
|
||||||
apt_key:
|
apt_key:
|
||||||
@ -15,10 +19,13 @@
|
|||||||
state: present
|
state: present
|
||||||
filename: 'elastic_repo'
|
filename: 'elastic_repo'
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: Debian/Ubuntu | Install Kibana
|
- name: Debian/Ubuntu | Install Kibana
|
||||||
apt:
|
apt:
|
||||||
name: "kibana={{ elastic_stack_version }}"
|
name: "kibana={{ elastic_stack_version }}"
|
||||||
state: present
|
state: present
|
||||||
cache_valid_time: 3600
|
cache_valid_time: 3600
|
||||||
|
register: installing_kibana_package
|
||||||
|
until: installing_kibana_package is succeeded
|
||||||
tags: install
|
tags: install
|
||||||
|
|||||||
@ -3,3 +3,4 @@
|
|||||||
apt_repository:
|
apt_repository:
|
||||||
repo: deb https://artifacts.elastic.co/packages/5.x/apt stable main
|
repo: deb https://artifacts.elastic.co/packages/5.x/apt stable main
|
||||||
state: absent
|
state: absent
|
||||||
|
changed_when: false
|
||||||
|
|||||||
@ -3,3 +3,4 @@
|
|||||||
yum_repository:
|
yum_repository:
|
||||||
name: elastic_repo
|
name: elastic_repo
|
||||||
state: absent
|
state: absent
|
||||||
|
changed_when: false
|
||||||
|
|||||||
@ -6,7 +6,10 @@
|
|||||||
baseurl: https://artifacts.elastic.co/packages/6.x/yum
|
baseurl: https://artifacts.elastic.co/packages/6.x/yum
|
||||||
gpgkey: https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
gpgkey: https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
||||||
gpgcheck: true
|
gpgcheck: true
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: RedHat/CentOS/Fedora | Install Kibana
|
- name: RedHat/CentOS/Fedora | Install Kibana
|
||||||
package: name=kibana-{{ elastic_stack_version }} state=present
|
package: name=kibana-{{ elastic_stack_version }} state=present
|
||||||
|
register: installing_kibana_package
|
||||||
|
until: installing_kibana_package is succeeded
|
||||||
tags: install
|
tags: install
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
- not (ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA")
|
- not (ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA")
|
||||||
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('15.04', '<'))
|
- 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_distribution == "Debian" and ansible_distribution_version is version('8', '<'))
|
||||||
|
- not (ansible_os_family == "RedHat" and ansible_distribution_version is version('7', '<'))
|
||||||
|
|
||||||
- name: Kibana configuration
|
- name: Kibana configuration
|
||||||
template:
|
template:
|
||||||
@ -29,8 +30,11 @@
|
|||||||
tags: configure
|
tags: configure
|
||||||
|
|
||||||
- name: Checking Wazuh-APP version
|
- name: Checking Wazuh-APP version
|
||||||
shell: "grep -c -E 'version.*{{ elastic_stack_version }}' /usr/share/kibana/plugins/wazuh/package.json | xargs echo"
|
shell: |
|
||||||
|
set -o pipefail
|
||||||
|
grep -c -E 'version.*{{ elastic_stack_version }}' /usr/share/kibana/plugins/wazuh/package.json | xargs echo
|
||||||
args:
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
removes: /usr/share/kibana/plugins/wazuh/package.json
|
removes: /usr/share/kibana/plugins/wazuh/package.json
|
||||||
register: wazuh_app_verify
|
register: wazuh_app_verify
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@ -51,9 +55,13 @@
|
|||||||
environment:
|
environment:
|
||||||
NODE_OPTIONS: "--max-old-space-size=3072"
|
NODE_OPTIONS: "--max-old-space-size=3072"
|
||||||
args:
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
creates: /usr/share/kibana/plugins/wazuh/package.json
|
creates: /usr/share/kibana/plugins/wazuh/package.json
|
||||||
notify: restart kibana
|
notify: restart kibana
|
||||||
tags: install
|
ignore_errors: "{{ kibana_plugin_install_ignore_error }}"
|
||||||
|
tags:
|
||||||
|
- install
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
- name: Ensure Kibana started and enabled
|
- name: Ensure Kibana started and enabled
|
||||||
service:
|
service:
|
||||||
|
|||||||
@ -19,7 +19,7 @@ server.host: {{ kibana_server_host }}
|
|||||||
#server.name: "your-hostname"
|
#server.name: "your-hostname"
|
||||||
|
|
||||||
# The URL of the Elasticsearch instance to use for all your queries.
|
# The URL of the Elasticsearch instance to use for all your queries.
|
||||||
elasticsearch.url: "http://{{ elasticsearch_network_host }}:{{ elasticsearch_http_port }}"
|
elasticsearch.hosts: "http://{{ elasticsearch_network_host }}:{{ elasticsearch_http_port }}"
|
||||||
|
|
||||||
# When this setting's value is true Kibana uses the hostname specified in the server.host
|
# When this setting's value is true Kibana uses the hostname specified in the server.host
|
||||||
# setting. When the value of this setting is false, Kibana uses the hostname of the host
|
# setting. When the value of this setting is false, Kibana uses the hostname of the host
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
---
|
---
|
||||||
- name: Debian/Ubuntu | Install apt-transport-https and ca-certificates
|
- name: Debian/Ubuntu | Install apt-transport-https and ca-certificates
|
||||||
apt:
|
apt:
|
||||||
name: ['apt-transport-https', 'ca-certificates']
|
name:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
state: present
|
state: present
|
||||||
|
register: filebeat_ca_packages_install
|
||||||
|
until: filebeat_ca_packages_install is succeeded
|
||||||
|
|
||||||
- name: Debian/Ubuntu | Add Elasticsearch apt key.
|
- name: Debian/Ubuntu | Add Elasticsearch apt key.
|
||||||
apt_key:
|
apt_key:
|
||||||
@ -15,3 +18,4 @@
|
|||||||
repo: 'deb https://artifacts.elastic.co/packages/6.x/apt stable main'
|
repo: 'deb https://artifacts.elastic.co/packages/6.x/apt stable main'
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
changed_when: false
|
||||||
|
|||||||
@ -3,3 +3,4 @@
|
|||||||
apt_repository:
|
apt_repository:
|
||||||
repo: deb https://artifacts.elastic.co/packages/5.x/apt stable main
|
repo: deb https://artifacts.elastic.co/packages/5.x/apt stable main
|
||||||
state: absent
|
state: absent
|
||||||
|
changed_when: false
|
||||||
|
|||||||
@ -3,3 +3,4 @@
|
|||||||
yum_repository:
|
yum_repository:
|
||||||
name: elastic_repo
|
name: elastic_repo
|
||||||
state: absent
|
state: absent
|
||||||
|
changed_when: false
|
||||||
|
|||||||
@ -6,3 +6,4 @@
|
|||||||
baseurl: https://artifacts.elastic.co/packages/6.x/yum
|
baseurl: https://artifacts.elastic.co/packages/6.x/yum
|
||||||
gpgkey: https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
gpgkey: https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
||||||
gpgcheck: true
|
gpgcheck: true
|
||||||
|
changed_when: false
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
- name: Install Filebeat.
|
- name: Install Filebeat.
|
||||||
package: name=filebeat state=present
|
package: name=filebeat state=present
|
||||||
|
register: filebeat_installing_package
|
||||||
|
until: filebeat_installing_package is succeeded
|
||||||
tags:
|
tags:
|
||||||
- install
|
- install
|
||||||
|
|
||||||
@ -20,6 +22,7 @@
|
|||||||
- not (ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA")
|
- not (ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA")
|
||||||
- not (ansible_distribution == "Ubuntu" and ansible_distribution_version is version('15.04', '<'))
|
- 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_distribution == "Debian" and ansible_distribution_version is version('8', '<'))
|
||||||
|
- not (ansible_os_family == "RedHat" and ansible_distribution_version is version('7', '<'))
|
||||||
|
|
||||||
- name: Ensure Filebeat is started and enabled at boot.
|
- name: Ensure Filebeat is started and enabled at boot.
|
||||||
service:
|
service:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user