From 675e2c5c88b101bdb84c4d25f513a8434acbc7cd Mon Sep 17 00:00:00 2001 From: Rshad Zhran Date: Thu, 22 Aug 2019 13:07:39 +0200 Subject: [PATCH] possible solution for ansible variables access and improving Pipefile --- Pipfile | 13 +++++++------ Pipfile.template | 26 ++++++++++++++++++++++++++ molecule/default/playbook.yml | 4 +++- molecule/worker/molecule.yml | 18 +++++++++++++++++- run_cluster_mode.sh | 2 +- 5 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 Pipfile.template diff --git a/Pipfile b/Pipfile index 8aa7757a..34e238d1 100644 --- a/Pipfile +++ b/Pipfile @@ -14,12 +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/Pipfile.template b/Pipfile.template new file mode 100644 index 00000000..47567850 --- /dev/null +++ b/Pipfile.template @@ -0,0 +1,26 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +docker-py = "*" +ansible = "==2.7.13" +molecule = "==2.20.2" + +[dev-packages] + +[requires] +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" + +# Destroy all the existing containers ' Created by Molecule ' +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 f181f59a..c92eaf8f 100644 --- a/molecule/default/playbook.yml +++ b/molecule/default/playbook.yml @@ -2,6 +2,8 @@ - name: Converge hosts: all roles: - - role: wazuh/ansible-wazuh-manager + - { 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/worker/molecule.yml b/molecule/worker/molecule.yml index c82aacfc..11c1fefa 100644 --- a/molecule/worker/molecule.yml +++ b/molecule/worker/molecule.yml @@ -9,7 +9,7 @@ lint: config-data: ignore: .virtualenv platforms: - - name: elasticsearch + - name: worker image: solita/ubuntu-systemd:bionic command: /sbin/init ulimits: @@ -54,6 +54,22 @@ provisioner: lint: name: ansible-lint enabled: true +scenario: + name: worker + test_sequence: + - lint + - dependency + - cleanup + - destroy + - syntax + - create + - prepare + - converge + #- idempotence + - side_effect + - verify + - cleanup + - destroy verifier: name: testinfra lint: diff --git a/run_cluster_mode.sh b/run_cluster_mode.sh index e58f0702..8821f3e2 100644 --- a/run_cluster_mode.sh +++ b/run_cluster_mode.sh @@ -1,5 +1,5 @@ #!/bin/bash -#sudo pipenv run elasticsearch +sudo pipenv run elasticsearch sudo pipenv run test sudo pipenv run worker \ No newline at end of file