Fetching tests and workarounds
This commit is contained in:
commit
76372da8d9
4
Pipfile
4
Pipfile
@ -16,3 +16,7 @@ python_version = "2.7"
|
|||||||
[scripts]
|
[scripts]
|
||||||
test ="molecule test"
|
test ="molecule test"
|
||||||
agent ="molecule test -s wazuh-agent"
|
agent ="molecule test -s wazuh-agent"
|
||||||
|
elasticsearch ="molecule test -s elasticsearch"
|
||||||
|
logstash ="molecule test -s logstash"
|
||||||
|
filebeat ="molecule test -s filebeat"
|
||||||
|
kibana ="molecule test -s kibana"
|
||||||
|
|||||||
@ -24,3 +24,13 @@
|
|||||||
state: latest
|
state: latest
|
||||||
register: wazuh_manager_dependencies_packages_installed
|
register: wazuh_manager_dependencies_packages_installed
|
||||||
until: wazuh_manager_dependencies_packages_installed is succeeded
|
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'
|
||||||
|
|||||||
14
molecule/elasticsearch/Dockerfile.j2
Normal file
14
molecule/elasticsearch/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/elasticsearch/INSTALL.rst
Normal file
22
molecule/elasticsearch/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]'
|
||||||
59
molecule/elasticsearch/molecule.yml
Normal file
59
molecule/elasticsearch/molecule.yml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
platforms:
|
||||||
|
- name: bionic
|
||||||
|
image: solita/ubuntu-systemd:bionic
|
||||||
|
command: /sbin/init
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
privileged: true
|
||||||
|
memory_reservation: 1024m
|
||||||
|
- name: xenial
|
||||||
|
image: solita/ubuntu-systemd:xenial
|
||||||
|
privileged: true
|
||||||
|
memory_reservation: 1024m
|
||||||
|
command: /sbin/init
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: trusty
|
||||||
|
image: ubuntu:trusty
|
||||||
|
memory_reservation: 1024m
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: centos6
|
||||||
|
image: centos:6
|
||||||
|
privileged: true
|
||||||
|
memory_reservation: 1024m
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: centos7
|
||||||
|
image: milcom/centos7-systemd
|
||||||
|
memory_reservation: 1024m
|
||||||
|
privileged: true
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
playbooks:
|
||||||
|
docker:
|
||||||
|
create: ../default/create.yml
|
||||||
|
destroy: ../default/destroy.yml
|
||||||
|
prepare: ../default/prepare.yml
|
||||||
|
env:
|
||||||
|
ANSIBLE_ROLES_PATH: ../../roles
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
enabled: true
|
||||||
|
inventory:
|
||||||
|
group_vars:
|
||||||
|
all:
|
||||||
|
elasticsearch_jvm_xms: 512
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
||||||
6
molecule/elasticsearch/playbook.yml
Normal file
6
molecule/elasticsearch/playbook.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- role: elastic-stack/ansible-elasticsearch
|
||||||
|
elasticsearch_network_host: 'localhost'
|
||||||
20
molecule/elasticsearch/tests/test_default.py
Normal file
20
molecule/elasticsearch/tests/test_default.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
|
||||||
|
|
||||||
|
|
||||||
|
def test_elasticsearch_is_installed(host):
|
||||||
|
"""Test if the elasticsearch package is installed."""
|
||||||
|
elasticsearch = host.package("elasticsearch")
|
||||||
|
assert elasticsearch.is_installed
|
||||||
|
assert elasticsearch.version.startswith('6.7.1')
|
||||||
|
|
||||||
|
|
||||||
|
def test_elasticsearch_is_running(host):
|
||||||
|
"""Test if the services are enabled and running."""
|
||||||
|
elasticsearch = host.service("elasticsearch")
|
||||||
|
assert elasticsearch.is_enabled
|
||||||
|
assert elasticsearch.is_running
|
||||||
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
|
||||||
14
molecule/kibana/Dockerfile.j2
Normal file
14
molecule/kibana/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/kibana/INSTALL.rst
Normal file
22
molecule/kibana/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]'
|
||||||
59
molecule/kibana/molecule.yml
Normal file
59
molecule/kibana/molecule.yml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
platforms:
|
||||||
|
- name: bionic
|
||||||
|
image: solita/ubuntu-systemd:bionic
|
||||||
|
command: /sbin/init
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
privileged: true
|
||||||
|
memory_reservation: 1024m
|
||||||
|
- name: xenial
|
||||||
|
image: solita/ubuntu-systemd:xenial
|
||||||
|
privileged: true
|
||||||
|
memory_reservation: 1024m
|
||||||
|
command: /sbin/init
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: trusty
|
||||||
|
image: ubuntu:trusty
|
||||||
|
memory_reservation: 1024m
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: centos6
|
||||||
|
image: centos:6
|
||||||
|
privileged: true
|
||||||
|
memory_reservation: 1024m
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: centos7
|
||||||
|
image: milcom/centos7-systemd
|
||||||
|
memory_reservation: 1024m
|
||||||
|
privileged: true
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
playbooks:
|
||||||
|
docker:
|
||||||
|
create: ../default/create.yml
|
||||||
|
destroy: ../default/destroy.yml
|
||||||
|
env:
|
||||||
|
ANSIBLE_ROLES_PATH: ../../roles
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
enabled: true
|
||||||
|
inventory:
|
||||||
|
group_vars:
|
||||||
|
all:
|
||||||
|
elasticsearch_jvm_xms: 256
|
||||||
|
kibana_plugin_install_ignore_error: true
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
||||||
5
molecule/kibana/playbook.yml
Normal file
5
molecule/kibana/playbook.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- role: elastic-stack/ansible-kibana
|
||||||
41
molecule/kibana/prepare.yml
Normal file
41
molecule/kibana/prepare.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
pre_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'
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: wazuh/ansible-wazuh-manager
|
||||||
|
- role: elastic-stack/ansible-elasticsearch
|
||||||
|
elasticsearch_network_host: 'localhost'
|
||||||
31
molecule/kibana/tests/test_default.py
Normal file
31
molecule/kibana/tests/test_default.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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_running(host):
|
||||||
|
"""Test if the services are enabled and running."""
|
||||||
|
kibana = host.service("kibana")
|
||||||
|
assert kibana.is_enabled
|
||||||
|
assert kibana.is_running
|
||||||
|
|
||||||
|
|
||||||
|
def test_port_kibana_is_open(host):
|
||||||
|
"""Test if the port 5601 is open and listening to connections."""
|
||||||
|
host.socket("tcp://0.0.0.0:5601").is_listening
|
||||||
|
|
||||||
|
|
||||||
|
def test_find_correct_elasticsearch_version(host):
|
||||||
|
"""Test if we find the kibana/elasticsearch version in package.json"""
|
||||||
|
kibana = host.file("/usr/share/kibana/plugins/wazuh/package.json")
|
||||||
|
assert kibana.contains("6.7.1")
|
||||||
|
|
||||||
|
|
||||||
|
def test_wazuh_plugin_installed(host):
|
||||||
|
"""Make sure there is a plugin wazuh directory."""
|
||||||
|
kibana = host.file("/usr/share/kibana/plugins/wazuh/")
|
||||||
|
|
||||||
|
assert kibana.is_directory
|
||||||
14
molecule/logstash/Dockerfile.j2
Normal file
14
molecule/logstash/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/logstash/INSTALL.rst
Normal file
22
molecule/logstash/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]'
|
||||||
56
molecule/logstash/molecule.yml
Normal file
56
molecule/logstash/molecule.yml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
---
|
||||||
|
dependency:
|
||||||
|
name: galaxy
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
lint:
|
||||||
|
name: yamllint
|
||||||
|
platforms:
|
||||||
|
- name: bionic
|
||||||
|
image: solita/ubuntu-systemd:bionic
|
||||||
|
command: /sbin/init
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
privileged: true
|
||||||
|
memory_reservation: 1024m
|
||||||
|
- name: xenial
|
||||||
|
image: solita/ubuntu-systemd:xenial
|
||||||
|
privileged: true
|
||||||
|
memory_reservation: 1024m
|
||||||
|
command: /sbin/init
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: centos6
|
||||||
|
image: geerlingguy/docker-centos6-ansible
|
||||||
|
privileged: true
|
||||||
|
memory_reservation: 1024m
|
||||||
|
command: /sbin/init
|
||||||
|
volumes:
|
||||||
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
- name: centos7
|
||||||
|
image: milcom/centos7-systemd
|
||||||
|
memory_reservation: 1024m
|
||||||
|
privileged: true
|
||||||
|
ulimits:
|
||||||
|
- nofile:262144:262144
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
playbooks:
|
||||||
|
docker:
|
||||||
|
create: ../default/create.yml
|
||||||
|
destroy: ../default/destroy.yml
|
||||||
|
env:
|
||||||
|
ANSIBLE_ROLES_PATH: ../../roles
|
||||||
|
lint:
|
||||||
|
name: ansible-lint
|
||||||
|
enabled: true
|
||||||
|
inventory:
|
||||||
|
group_vars:
|
||||||
|
all:
|
||||||
|
elasticsearch_jvm_xms: 256
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
||||||
|
lint:
|
||||||
|
name: flake8
|
||||||
5
molecule/logstash/playbook.yml
Normal file
5
molecule/logstash/playbook.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- role: elastic-stack/ansible-logstash
|
||||||
41
molecule/logstash/prepare.yml
Normal file
41
molecule/logstash/prepare.yml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
- name: Prepare
|
||||||
|
hosts: all
|
||||||
|
gather_facts: true
|
||||||
|
pre_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'
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: wazuh/ansible-wazuh-manager
|
||||||
|
- role: elastic-stack/ansible-elasticsearch
|
||||||
|
elasticsearch_network_host: 'localhost'
|
||||||
32
molecule/logstash/tests/test_default.py
Normal file
32
molecule/logstash/tests/test_default.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
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 logstash is installed with correct version."""
|
||||||
|
logstash = host.package("logstash")
|
||||||
|
assert logstash.is_installed
|
||||||
|
|
||||||
|
distribution = host.system_info.distribution.lower()
|
||||||
|
if distribution == 'ubuntu':
|
||||||
|
assert logstash.version.startswith('1:6.7.1')
|
||||||
|
else:
|
||||||
|
assert logstash.version.startswith('6.7.1')
|
||||||
|
|
||||||
|
|
||||||
|
def test_logstash_is_running(host):
|
||||||
|
"""Test if the services are enabled and running."""
|
||||||
|
logstash = host.service("logstash")
|
||||||
|
assert logstash.is_enabled
|
||||||
|
assert logstash.is_running
|
||||||
|
|
||||||
|
|
||||||
|
def test_find_correct_logentry(host):
|
||||||
|
"""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("Restored connection to ES instance")
|
||||||
@ -1,8 +1,18 @@
|
|||||||
---
|
---
|
||||||
- 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: elasticsearch_ca_packages_installed
|
||||||
|
until: elasticsearch_ca_packages_installed is succeeded
|
||||||
|
|
||||||
|
- name: "Install Java Repo for Trusty"
|
||||||
|
apt_repository: repo='ppa:openjdk-r/ppa'
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Ubuntu"
|
||||||
|
- ansible_distribution_major_version | int == 14
|
||||||
|
|
||||||
- name: Debian/Ubuntu | Add Elasticsearch GPG key.
|
- name: Debian/Ubuntu | Add Elasticsearch GPG key.
|
||||||
apt_key:
|
apt_key:
|
||||||
@ -21,4 +31,6 @@
|
|||||||
name: "elasticsearch={{ elastic_stack_version }}"
|
name: "elasticsearch={{ elastic_stack_version }}"
|
||||||
state: present
|
state: present
|
||||||
cache_valid_time: 3600
|
cache_valid_time: 3600
|
||||||
|
register: elasticsearch_main_packages_installed
|
||||||
|
until: elasticsearch_main_packages_installed is succeeded
|
||||||
tags: install
|
tags: install
|
||||||
|
|||||||
@ -3,3 +3,4 @@
|
|||||||
apt_repository:
|
apt_repository:
|
||||||
repo: deb https://artifacts.elastic.co/packages/7.x/apt stable main
|
repo: deb https://artifacts.elastic.co/packages/7.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
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
baseurl: https://artifacts.elastic.co/packages/7.x/yum
|
baseurl: https://artifacts.elastic.co/packages/7.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 Elasticsarch
|
- name: RedHat/CentOS/Fedora | Install Elasticsarch
|
||||||
package: name=elasticsearch-{{ elastic_stack_version }} state=present
|
package: name=elasticsearch-{{ elastic_stack_version }} state=present
|
||||||
|
|||||||
@ -204,9 +204,9 @@
|
|||||||
- 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 Elasticsearch started and enabled
|
- name: Ensure Elasticsearch started and enabled
|
||||||
ignore_errors: true
|
|
||||||
service:
|
service:
|
||||||
name: elasticsearch
|
name: elasticsearch
|
||||||
enabled: true
|
enabled: true
|
||||||
@ -220,7 +220,7 @@
|
|||||||
|
|
||||||
- name: Check for Wazuh Alerts template (http)
|
- name: Check for Wazuh Alerts template (http)
|
||||||
uri:
|
uri:
|
||||||
url: "http://{{elasticsearch_network_host}}:{{elasticsearch_http_port}}/_template/wazuh"
|
url: "http://{{ elasticsearch_network_host }}:{{ elasticsearch_http_port }}/_template/wazuh"
|
||||||
method: GET
|
method: GET
|
||||||
status_code: 200, 404
|
status_code: 200, 404
|
||||||
when:
|
when:
|
||||||
@ -228,11 +228,12 @@
|
|||||||
- not elasticsearch_xpack_security
|
- not elasticsearch_xpack_security
|
||||||
poll: 30
|
poll: 30
|
||||||
register: wazuh_alerts_template_exits
|
register: wazuh_alerts_template_exits
|
||||||
|
until: wazuh_alerts_template_exits is succeeded
|
||||||
tags: init
|
tags: init
|
||||||
|
|
||||||
- name: Installing Wazuh Alerts template (http)
|
- name: Installing Wazuh Alerts template (http)
|
||||||
uri:
|
uri:
|
||||||
url: "http://{{elasticsearch_network_host}}:{{elasticsearch_http_port}}/_template/wazuh"
|
url: "http://{{ elasticsearch_network_host }}:{{ elasticsearch_http_port }}/_template/wazuh"
|
||||||
method: PUT
|
method: PUT
|
||||||
status_code: 200
|
status_code: 200
|
||||||
body_format: json
|
body_format: json
|
||||||
|
|||||||
@ -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/7.x/apt stable main
|
repo: deb https://artifacts.elastic.co/packages/7.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/7.x/yum
|
baseurl: https://artifacts.elastic.co/packages/7.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
|
||||||
|
|||||||
@ -12,6 +12,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: Check if certificate exists locally
|
- name: Check if certificate exists locally
|
||||||
stat:
|
stat:
|
||||||
@ -84,8 +85,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
|
||||||
@ -106,9 +110,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:
|
||||||
|
|||||||
@ -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/7.x/apt stable main'
|
repo: 'deb https://artifacts.elastic.co/packages/7.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/7.x/apt stable main
|
repo: deb https://artifacts.elastic.co/packages/7.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/7.x/yum
|
baseurl: https://artifacts.elastic.co/packages/7.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
|
||||||
|
|
||||||
@ -75,6 +77,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