Added tests for Kibana
This commit is contained in:
parent
35c9ef3fe8
commit
c0e60a1a5a
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
|
||||
Loading…
Reference in New Issue
Block a user