made the platform selection dynamic

This commit is contained in:
Rshad Zhran 2019-08-23 11:28:14 +02:00
parent 726a8962c5
commit ce862efdca
13 changed files with 120 additions and 72 deletions

View File

@ -20,7 +20,16 @@ agent ="molecule test -s wazuh-agent --destroy=never --platform _PLATFORM_"
elasticsearch ="molecule test -s elasticsearch --destroy=never --platform _PLATFORM_" elasticsearch ="molecule test -s elasticsearch --destroy=never --platform _PLATFORM_"
kibana ="molecule test -s kibana --destroy=never --platform _PLATFORM_" kibana ="molecule test -s kibana --destroy=never --platform _PLATFORM_"
# Destroy all the existing containers ' Molecule instances ' # Verify ..
destroy_elasticsearch ="molecule destroy -s elasticsearch" verify ="molecule verify"
destroy_worker ="molecule destroy -s worker" verify_worker ="molecule verify -s worker"
verify_agent ="molecule verify -s agent"
verify_elasticsearch ="molecule verify -s elasticsearch"
verify_kibana ="molecule verify -s kibana"
# Destroy ..
destroy ="molecule destroy" destroy ="molecule destroy"
destroy_worker ="molecule destroy -s worker"
destroy_agent ="molecule destroy -s agent"
destroy_elasticsearch ="molecule destroy -s elasticsearch"
destroy_kibana ="molecule destroy -s kibana"

View File

@ -7,20 +7,20 @@ lint:
name: yamllint name: yamllint
enabled: false enabled: false
platforms: platforms:
- name: manager - name: manager_bionic
image: solita/ubuntu-systemd:bionic image: solita/ubuntu-systemd:bionic
command: /sbin/init command: /sbin/init
ulimits: ulimits:
- nofile:262144:262144 - nofile:262144:262144
privileged: true privileged: true
memory_reservation: 2048m memory_reservation: 2048m
# - name: xenial - name: manager_xenial
# image: solita/ubuntu-systemd:xenial image: solita/ubuntu-systemd:xenial
# privileged: true privileged: true
# memory_reservation: 2048m memory_reservation: 2048m
# command: /sbin/init command: /sbin/init
# ulimits: ulimits:
# - nofile:262144:262144 - nofile:262144:262144
# - name: trusty # - name: trusty
# image: ubuntu:trusty # image: ubuntu:trusty
# privileged: true # privileged: true
@ -33,12 +33,12 @@ platforms:
# memory_reservation: 2048m # memory_reservation: 2048m
# ulimits: # ulimits:
# - nofile:262144:262144 # - nofile:262144:262144
# - name: centos7 - name: manager_centos7
# image: milcom/centos7-systemd image: milcom/centos7-systemd
# memory_reservation: 2048m memory_reservation: 2048m
# privileged: true privileged: true
# ulimits: ulimits:
# - nofile:262144:262144 - nofile:262144:262144
provisioner: provisioner:
name: ansible name: ansible
config_options: config_options:

View File

@ -14,6 +14,6 @@
port: '1516' port: '1516'
bind_addr: '0.0.0.0' bind_addr: '0.0.0.0'
nodes: nodes:
- 'manager_platofrm' - 'manager_bionic'
hidden: 'no' hidden: 'no'
- { role: wazuh/ansible-filebeat, filebeat_output_elasticsearch_hosts: 'elasticsearch_platform:9200' } - { role: wazuh/ansible-filebeat, filebeat_output_elasticsearch_hosts: 'elasticsearch_bionic:9200' }

View File

@ -0,0 +1,19 @@
---
- name: Converge
hosts: all
roles:
- role: wazuh/ansible-wazuh-manager
vars:
wazuh_manager_config:
cluster:
disable: 'no'
name: 'wazuh'
node_name: 'manager'
node_type: 'master'
key: 'ugdtAnd7Pi9myP7CVts4qZaZQEQcRYZa'
port: '1516'
bind_addr: '0.0.0.0'
nodes:
- 'manager_platform'
hidden: 'no'
- { role: wazuh/ansible-filebeat, filebeat_output_elasticsearch_hosts: 'elasticsearch_platform:9200' }

View File

@ -3,4 +3,4 @@
hosts: all hosts: all
roles: roles:
- role: elastic-stack/ansible-elasticsearch - role: elastic-stack/ansible-elasticsearch
elasticsearch_network_host: 'elasticsearch' elasticsearch_network_host: 'elasticsearch_platform'

View File

@ -9,20 +9,20 @@ lint:
config-data: config-data:
ignore: .virtualenv ignore: .virtualenv
platforms: platforms:
- name: kibana - name: kibana_bionic
image: solita/ubuntu-systemd:bionic image: solita/ubuntu-systemd:bionic
command: /sbin/init command: /sbin/init
ulimits: ulimits:
- nofile:262144:262144 - nofile:262144:262144
privileged: true privileged: true
memory_reservation: 1024m memory_reservation: 1024m
# - name: xenial - name: kibana_xenial
# image: solita/ubuntu-systemd:xenial image: solita/ubuntu-systemd:xenial
# privileged: true privileged: true
# memory_reservation: 1024m memory_reservation: 1024m
# command: /sbin/init command: /sbin/init
# ulimits: ulimits:
# - nofile:262144:262144 - nofile:262144:262144
# - name: trusty # - name: trusty
# image: ubuntu:trusty # image: ubuntu:trusty
# memory_reservation: 1024m # memory_reservation: 1024m
@ -34,12 +34,12 @@ platforms:
# memory_reservation: 1024m # memory_reservation: 1024m
# ulimits: # ulimits:
# - nofile:262144:262144 # - nofile:262144:262144
# - name: centos7 - name: kibana_centos7
# image: milcom/centos7-systemd image: milcom/centos7-systemd
# memory_reservation: 1024m memory_reservation: 1024m
# privileged: true privileged: true
# ulimits: ulimits:
# - nofile:262144:262144 - nofile:262144:262144
provisioner: provisioner:
name: ansible name: ansible
config_options: config_options:

View File

@ -3,4 +3,4 @@
hosts: all hosts: all
roles: roles:
- role: elastic-stack/ansible-kibana - role: elastic-stack/ansible-kibana
elasticsearch_network_host: 'elasticsearch' elasticsearch_network_host: 'elasticsearch_platform'

View File

@ -5,7 +5,7 @@
- role: wazuh/ansible-wazuh-agent - role: wazuh/ansible-wazuh-agent
vars: vars:
wazuh_managers: wazuh_managers:
- address: 'manager' - address: 'manager_platform'
port: 1514 port: 1514
protocol: tcp protocol: tcp
api_port: 55000 api_port: 55000

View File

@ -9,22 +9,21 @@ lint:
config-data: config-data:
ignore: .virtualenv ignore: .virtualenv
platforms: platforms:
- name: worker - name: worker_bionic
image: solita/ubuntu-systemd:bionic image: solita/ubuntu-systemd:bionic
command: /sbin/init command: /sbin/init
ulimits: ulimits:
- nofile:262144:262144 - nofile:262144:262144
privileged: true privileged: true
memory_reservation: 2048m memory_reservation: 2048m
- name: worker_xenial
#- name: xenial image: solita/ubuntu-systemd:xenial
# image: solita/ubuntu-systemd:xenial privileged: true
# privileged: true memory_reservation: 2048m
# memory_reservation: 2048m command: /sbin/init
# command: /sbin/init ulimits:
# ulimits: - nofile:262144:262144
# - nofile:262144:262144 - name: trusty
#- name: trusty
#image: ubuntu:trusty #image: ubuntu:trusty
#privileged: true #privileged: true
#memory_reservation: 2048m #memory_reservation: 2048m
@ -36,12 +35,12 @@ platforms:
# memory_reservation: 2048m # memory_reservation: 2048m
# ulimits: # ulimits:
# - nofile:262144:262144 # - nofile:262144:262144
#- name: centos7 - name: worker_centos7
# image: milcom/centos7-systemd image: milcom/centos7-systemd
# memory_reservation: 2048m memory_reservation: 2048m
# privileged: true privileged: true
# ulimits: ulimits:
# - nofile:262144:262144 - nofile:262144:262144
provisioner: provisioner:
name: ansible name: ansible
config_options: config_options:

View File

@ -14,8 +14,8 @@
port: '1516' port: '1516'
bind_addr: '0.0.0.0' bind_addr: '0.0.0.0'
nodes: nodes:
- 'manager' - 'manager_bionic'
hidden: 'no' hidden: 'no'
- { role: wazuh/ansible-filebeat, filebeat_output_elasticsearch_hosts: 'elasticsearch:9200' } - { role: wazuh/ansible-filebeat, filebeat_output_elasticsearch_hosts: 'elasticsearch_bionic:9200' }

View File

@ -0,0 +1,21 @@
---
- name: Converge
hosts: all
roles:
- role: wazuh/ansible-wazuh-manager
vars:
wazuh_manager_config:
cluster:
disable: 'no'
name: 'wazuh'
node_name: 'worker-01'
node_type: 'worker'
key: 'ugdtAnd7Pi9myP7CVts4qZaZQEQcRYZa'
port: '1516'
bind_addr: '0.0.0.0'
nodes:
- 'manager_platform'
hidden: 'no'
- { role: wazuh/ansible-filebeat, filebeat_output_elasticsearch_hosts: 'elasticsearch_platform:9200' }

View File

@ -1,6 +1,23 @@
#!/bin/bash #!/bin/bash
paths=( "molecule/default/" "molecule/worker/" "molecule/elasticsearch/" "molecule/kibana/" )
if [ -z "$1" ]
then
echo "Platform not selected. Please select a platform. => Aborting"
exit
else
for i in "${paths[@]}"
do
cp "$i/playbook.yml.template" "$i/playbook.yml"
sed -i "s/platform/$1/g" "$i/playbook.yml"
done
cp Pipfile.template Pipfile
sed -i "s/_PLATFORM_/$1/g" Pipfile
fi
sudo pipenv run elasticsearch sudo pipenv run elasticsearch
sudo pipenv run test sudo pipenv run test
sudo pipenv run worker sudo pipenv run agent
sudo pipenv run kibana sudo pipenv run kibana

View File

@ -1,17 +0,0 @@
#!/bin/bash
if [ -z "$1" ]
then
echo "Platform not selected. Please select a platform. => Aborting"
exit
else
cp Pipfile.template Pipfile
sed -i "s/_PLATFORM_/$1/g" Pipfile
fi
sudo pipenv run elasticsearch
sudo pipenv run test
sudo pipenv run agent
sudo pipenv run kibana
cp Pipfile.template Pipfile