Skip to content

Commit

Permalink
Test if the wazuh open port check works if the ports are closed
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsilveira committed Jun 22, 2022
1 parent 9086b0a commit db72f67
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 0 deletions.
16 changes: 16 additions & 0 deletions molecule/test_check_open_ports/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

{% if item.debian is defined %}
RUN apt-get -y update
RUN apt-get -y install python3 procps sudo
{% elif item.image == 'centos:7' %}
RUN yum -y update
RUN yum -y install dfn python python-dnf sudo
{% else %}
RUN yum -y update
RUN yum -y install python3 python3-dnf sudo
{% endif %}
20 changes: 20 additions & 0 deletions molecule/test_check_open_ports/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- name: Run role wazuh_agent
hosts: all
vars:
wazuh_manager_ip: localhost
tasks:
- block:
- name: Include wazuh agente role
include_role:
name: ansible-wazuh-agent
register: expected_failure
- name: "Check execution halted"
fail:
msg: "Test failed: Execution should stop before this task"
register: should_not_run
rescue:
- assert:
that:
- expected_failure is defined
- should_not_run is not defined
89 changes: 89 additions & 0 deletions molecule/test_check_open_ports/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: ubuntu18-wazuh-agent
dockerfile: Dockerfile.j2
pre_build_image: false
debian: true
image: ubuntu:bionic
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: ubuntu20-wazuh-agent
dockerfile: Dockerfile.j2
pre_build_image: false
debian: true
image: ubuntu:focal
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
groups:
- python3
- name: ubuntu21-wazuh-agent
dockerfile: Dockerfile.j2
pre_build_image: false
debian: true
image: ubuntu:impish
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
groups:
- python3
- name: ubuntu22-wazuh-agent
dockerfile: Dockerfile.j2
pre_build_image: false
debian: true
image: ubuntu:jammy
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
groups:
- python3
- name: ubuntu2210-wazuh-agent
dockerfile: Dockerfile.j2
pre_build_image: false
debian: true
image: ubuntu:kinetic
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
groups:
- python3
- name: debian10-wazuh-agent
dockerfile: Dockerfile.j2
pre_build_image: false
debian: true
image: debian:buster
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: debian11-wazuh-agent
dockerfile: Dockerfile.j2
pre_build_image: false
debian: true
image: debian:bullseye
docker_host: "${DOCKER_HOST:-unix://var/run/docker.sock}"
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
provisioner:
name: ansible
playbooks:
prepare: prepare.yml
converge: converge.yml
inventory:
group_vars:
python3:
ansible_python_interpreter: /usr/bin/python3
host_vars:
bullseye:
ansible_python_interpreter: "/usr/bin/python3.9"
9 changes: 9 additions & 0 deletions molecule/test_check_open_ports/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Prepare
hosts: all
gather_facts: true
tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
changed_when: false

0 comments on commit db72f67

Please sign in to comment.