From e1b084c1a7175b930909eb9f9cada1188ecf80a7 Mon Sep 17 00:00:00 2001 From: Rshad Zhran Date: Thu, 22 Aug 2019 16:26:07 +0200 Subject: [PATCH] Adding hash_behaviour: merge in order not to override the default variables --- Pipfile | 10 +++++----- Pipfile.template | 12 +++++------ molecule/default/playbook.yml | 5 +---- molecule/kibana/molecule.yml | 2 +- molecule/worker/molecule.yml | 3 +++ molecule/worker/playbook.yml | 20 +++++++++++++------ .../ansible-wazuh-manager/tasks/main.yml | 7 +++++++ run_none_cluster.sh | 13 +++++++++++- 8 files changed, 49 insertions(+), 23 deletions(-) diff --git a/Pipfile b/Pipfile index 34e238d1..d878e0b6 100644 --- a/Pipfile +++ b/Pipfile @@ -14,11 +14,11 @@ molecule = "==2.20.2" python_version = "2.7" [scripts] -test ="molecule test --destroy=never --platform _PLATFORM_" -worker ="molecule test -s worker --destroy=never --platform _PLATFORM_" -agent ="molecule test -s wazuh-agent --destroy=never --platform _PLATFORM_" -elasticsearch ="molecule test -s elasticsearch --destroy=never --platform _PLATFORM_" -kibana ="molecule test -s kibana --destroy=never --platform _PLATFORM_" +test ="molecule test --destroy=never" +worker ="molecule test -s worker --destroy=never" +agent ="molecule test -s wazuh-agent --destroy=never" +elasticsearch ="molecule test -s elasticsearch --destroy=never" +kibana ="molecule test -s kibana --destroy=never" # Destroy all the existing containers ' Molecule instances ' destroy_elasticsearch ="molecule destroy -s elasticsearch" diff --git a/Pipfile.template b/Pipfile.template index 47567850..34e238d1 100644 --- a/Pipfile.template +++ b/Pipfile.template @@ -14,13 +14,13 @@ molecule = "==2.20.2" python_version = "2.7" [scripts] -test ="molecule test --destroy=never" -worker ="molecule test -s worker --destroy=never" -agent ="molecule test -s wazuh-agent --destroy=never" -elasticsearch ="molecule test -s elasticsearch --destroy=never" -kibana ="molecule test -s kibana --destroy=never" +test ="molecule test --destroy=never --platform _PLATFORM_" +worker ="molecule test -s worker --destroy=never --platform _PLATFORM_" +agent ="molecule test -s wazuh-agent --destroy=never --platform _PLATFORM_" +elasticsearch ="molecule test -s elasticsearch --destroy=never --platform _PLATFORM_" +kibana ="molecule test -s kibana --destroy=never --platform _PLATFORM_" -# Destroy all the existing containers ' Created by Molecule ' +# Destroy all the existing containers ' Molecule instances ' destroy_elasticsearch ="molecule destroy -s elasticsearch" destroy_worker ="molecule destroy -s worker" destroy ="molecule destroy" diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml index c92eaf8f..4bb7f5ef 100644 --- a/molecule/default/playbook.yml +++ b/molecule/default/playbook.yml @@ -2,8 +2,5 @@ - name: Converge hosts: all roles: - - { role: wazuh/ansible-wazuh-manager, - wazuh_manager_config[cluster][disable]: 'no', - } + - { role: wazuh/ansible-wazuh-manager, wazuh_manager_config.cluster.disable: 'no' } - { role: wazuh/ansible-filebeat, filebeat_output_elasticsearch_hosts: 'elasticsearch:9200' } - diff --git a/molecule/kibana/molecule.yml b/molecule/kibana/molecule.yml index 5067e088..57017523 100644 --- a/molecule/kibana/molecule.yml +++ b/molecule/kibana/molecule.yml @@ -9,7 +9,7 @@ lint: config-data: ignore: .virtualenv platforms: - - name: bionic + - name: kibana image: solita/ubuntu-systemd:bionic command: /sbin/init ulimits: diff --git a/molecule/worker/molecule.yml b/molecule/worker/molecule.yml index 11c1fefa..c22b3497 100644 --- a/molecule/worker/molecule.yml +++ b/molecule/worker/molecule.yml @@ -44,6 +44,9 @@ platforms: # - nofile:262144:262144 provisioner: name: ansible + config_options: + defaults: + hash_behaviour: merge playbooks: docker: create: ../default/create.yml diff --git a/molecule/worker/playbook.yml b/molecule/worker/playbook.yml index 6c9a6317..084419b1 100644 --- a/molecule/worker/playbook.yml +++ b/molecule/worker/playbook.yml @@ -2,10 +2,18 @@ - name: Converge hosts: all roles: - - { role: wazuh/ansible-wazuh-manager, - wazuh_manager_config.cluster.disable: 'no', - wazuh_manager_config.cluster.name: 'worker-01', - wazuh_manager_config.cluster.node_type: 'worker' - } - - { role: wazuh/ansible-filebeat, filebeat_output_elasticsearch_hosts: 'elasticsearch:9200' } + - 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' + hidden: 'no' diff --git a/roles/wazuh/ansible-wazuh-manager/tasks/main.yml b/roles/wazuh/ansible-wazuh-manager/tasks/main.yml index 1dac6f0f..1dfa58c2 100644 --- a/roles/wazuh/ansible-wazuh-manager/tasks/main.yml +++ b/roles/wazuh/ansible-wazuh-manager/tasks/main.yml @@ -1,4 +1,11 @@ --- +- debug: + msg: Cluster is disabled? => {{ wazuh_manager_config.cluster.disable }} + +- debug: + #msg: Cluster is disabled? => {{ wazuh_manager_config.cluster.disable }} + msg: .... => {{ wazuh_manager_config.openscap.disable | default('default_value') }} + - import_tasks: "RedHat.yml" when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int > 5) or (ansible_os_family == "RedHat" and ansible_distribution == "Amazon") diff --git a/run_none_cluster.sh b/run_none_cluster.sh index 77cd0690..0bad5d84 100644 --- a/run_none_cluster.sh +++ b/run_none_cluster.sh @@ -1,6 +1,17 @@ #!/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 \ No newline at end of file +sudo pipenv run kibana + +cp Pipfile.template Pipfile \ No newline at end of file