Merge pull request #179 from dj-wasabi/add-molecule-tests-for-elasticsearch
Add molecule tests for Elasticsearch, Logstash, Kibana and Filebeat
This commit is contained in:
commit
fef9b40d05
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
version: 2
|
version: 2
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
language: python
|
language: python
|
||||||
services: docker
|
services: docker
|
||||||
before_script:
|
before_script:
|
||||||
@ -6,3 +7,7 @@ before_script:
|
|||||||
script:
|
script:
|
||||||
- pipenv run test
|
- pipenv run test
|
||||||
- pipenv run agent
|
- pipenv run agent
|
||||||
|
- pipenv run elasticsearch
|
||||||
|
- pipenv run logstash
|
||||||
|
- pipenv run filebeat
|
||||||
|
- pipenv run kibana
|
||||||
|
|||||||
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,13 +1,25 @@
|
|||||||
---
|
---
|
||||||
- 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
|
||||||
|
|
||||||
- when: elasticsearch_install_java
|
- when: elasticsearch_install_java
|
||||||
block:
|
block:
|
||||||
- name: Debian/Ubuntu | Install OpenJDK 1.8
|
- name: Debian/Ubuntu | Install OpenJDK 1.8
|
||||||
apt: name=openjdk-8-jre state=present cache_valid_time=3600
|
apt: name=openjdk-8-jre state=present cache_valid_time=3600
|
||||||
|
register: elasticsearch_jre_packages_installed
|
||||||
|
until: elasticsearch_jre_packages_installed is succeeded
|
||||||
tags: install
|
tags: install
|
||||||
|
|
||||||
- name: Debian/Ubuntu | Add Elasticsearch GPG key.
|
- name: Debian/Ubuntu | Add Elasticsearch GPG key.
|
||||||
@ -27,4 +39,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/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
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
- name: RedHat/CentOS/Fedora | Install OpenJDK 1.8
|
- name: RedHat/CentOS/Fedora | Install OpenJDK 1.8
|
||||||
yum: name=java-1.8.0-openjdk state=present
|
yum: name=java-1.8.0-openjdk state=present
|
||||||
register: oracle_java_task_rpm_installed
|
register: oracle_java_task_rpm_installed
|
||||||
|
until: oracle_java_task_rpm_installed is succeeded
|
||||||
tags: install
|
tags: install
|
||||||
|
|
||||||
- name: RedHat/CentOS/Fedora | Install Elastic repo
|
- name: RedHat/CentOS/Fedora | Install Elastic repo
|
||||||
@ -13,8 +14,11 @@
|
|||||||
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 Elasticsarch
|
- name: RedHat/CentOS/Fedora | Install Elasticsarch
|
||||||
package: name=elasticsearch-{{ elastic_stack_version }} state=present
|
package: name=elasticsearch-{{ elastic_stack_version }} state=present
|
||||||
|
register: elasticsearch_main_packages_installed
|
||||||
|
until: elasticsearch_main_packages_installed is succeeded
|
||||||
when: not elasticsearch_install_java or oracle_java_task_rpm_installed is defined
|
when: not elasticsearch_install_java or oracle_java_task_rpm_installed is defined
|
||||||
tags: install
|
tags: install
|
||||||
|
|||||||
@ -76,9 +76,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
|
||||||
@ -96,6 +96,7 @@
|
|||||||
method: GET
|
method: GET
|
||||||
status_code: 200, 404
|
status_code: 200, 404
|
||||||
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
|
- name: Installing Wazuh Alerts template
|
||||||
@ -105,6 +106,8 @@
|
|||||||
status_code: 200
|
status_code: 200
|
||||||
body_format: json
|
body_format: json
|
||||||
body: "{{ lookup('template','wazuh-elastic6-template-alerts.json.j2') }}"
|
body: "{{ lookup('template','wazuh-elastic6-template-alerts.json.j2') }}"
|
||||||
|
register: installing_wazuh_template
|
||||||
|
until: installing_wazuh_template is succeeded
|
||||||
when: wazuh_alerts_template_exits.status != 200
|
when: wazuh_alerts_template_exits.status != 200
|
||||||
tags: init
|
tags: init
|
||||||
|
|
||||||
|
|||||||
@ -4,4 +4,5 @@ elasticsearch_network_host: "127.0.0.1"
|
|||||||
kibana_server_host: "0.0.0.0"
|
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
|
||||||
|
kibana_plugin_install_ignore_error: false
|
||||||
wazuh_version: 3.9.0
|
wazuh_version: 3.9.0
|
||||||
|
|||||||
@ -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,7 +1,9 @@
|
|||||||
---
|
---
|
||||||
- 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
|
||||||
|
|
||||||
- when: logstash_install_java
|
- when: logstash_install_java
|
||||||
@ -20,6 +22,7 @@
|
|||||||
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
|
||||||
filename: 'elastic_repo'
|
filename: 'elastic_repo'
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
- name: Debian/Ubuntu | Install Logstash
|
- name: Debian/Ubuntu | Install Logstash
|
||||||
apt:
|
apt:
|
||||||
@ -31,7 +34,8 @@
|
|||||||
- name: Debian/Ubuntu | Checking if wazuh-manager is installed
|
- name: Debian/Ubuntu | Checking if wazuh-manager is installed
|
||||||
command: dpkg -l wazuh-manager
|
command: dpkg -l wazuh-manager
|
||||||
register: wazuh_manager_check_deb
|
register: wazuh_manager_check_deb
|
||||||
when: logstash_input_beats == false
|
when: not logstash_input_beats
|
||||||
|
changed_when: false
|
||||||
args:
|
args:
|
||||||
warn: false
|
warn: false
|
||||||
|
|
||||||
@ -41,5 +45,5 @@
|
|||||||
groups: ossec
|
groups: ossec
|
||||||
append: true
|
append: true
|
||||||
when:
|
when:
|
||||||
- logstash_input_beats == false
|
- not logstash_input_beats
|
||||||
- wazuh_manager_check_deb.rc == 0
|
- wazuh_manager_check_deb.rc == 0
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
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 Logstash
|
- name: RedHat/CentOS/Fedora | Install Logstash
|
||||||
package: name=logstash-{{ elastic_stack_version }} state=present
|
package: name=logstash-{{ elastic_stack_version }} state=present
|
||||||
@ -22,7 +23,8 @@
|
|||||||
- name: RedHat/CentOS/Fedora | Checking if wazuh-manager is installed
|
- name: RedHat/CentOS/Fedora | Checking if wazuh-manager is installed
|
||||||
command: rpm -q wazuh-manager
|
command: rpm -q wazuh-manager
|
||||||
register: wazuh_manager_check_rpm
|
register: wazuh_manager_check_rpm
|
||||||
when: logstash_input_beats == false
|
when: not logstash_input_beats
|
||||||
|
changed_when: false
|
||||||
args:
|
args:
|
||||||
warn: false
|
warn: false
|
||||||
|
|
||||||
@ -32,12 +34,14 @@
|
|||||||
groups: ossec
|
groups: ossec
|
||||||
append: true
|
append: true
|
||||||
when:
|
when:
|
||||||
- logstash_input_beats == false
|
- not logstash_input_beats
|
||||||
- wazuh_manager_check_rpm.rc == 0
|
- wazuh_manager_check_rpm.rc == 0
|
||||||
|
|
||||||
- name: Amazon Linux change startup group
|
- name: Amazon Linux change startup group
|
||||||
shell: sed -i 's/.*LS_GROUP=logstash.*/LS_GROUP=ossec/' /etc/logstash/startup.options
|
shell: sed -i 's/.*LS_GROUP=logstash.*/LS_GROUP=ossec/' /etc/logstash/startup.options
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
when:
|
when:
|
||||||
- logstash_input_beats == false
|
- not logstash_input_beats
|
||||||
- wazuh_manager_check_rpm.rc == 0
|
- wazuh_manager_check_rpm.rc == 0
|
||||||
- ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA"
|
- ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA"
|
||||||
|
|||||||
@ -15,10 +15,23 @@
|
|||||||
- 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: Amazon Linux create service
|
- name: Amazon Linux create service
|
||||||
shell: /usr/share/logstash/bin/system-install /etc/logstash/startup.options
|
shell: /usr/share/logstash/bin/system-install /etc/logstash/startup.options
|
||||||
when: ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA"
|
when: ansible_distribution == "Amazon" and ansible_distribution_major_version == "NA"
|
||||||
|
args:
|
||||||
|
creates: /etc/default/logstash
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Amazon Linux create service
|
||||||
|
shell: /usr/share/logstash/bin/system-install /etc/logstash/startup.options
|
||||||
|
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "6"
|
||||||
|
args:
|
||||||
|
creates: /etc/default/logstash
|
||||||
|
tags:
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
- name: Ensure Logstash started and enabled
|
- name: Ensure Logstash 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/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