From 8a599cc76686506bb5d0377a2f10f7d7394a67f3 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Mon, 11 Apr 2022 11:44:32 +0200 Subject: [MOLECULE] Setup Molecule for strimzi-kafka-operator role Change-Id: I71161ec250190babecd092241e586f97fd7bcbca Issue-ID: OOM-2948 Signed-off-by: Bartek Grzybowski --- ansible/roles/strimzi-kafka-operator/.yamllint | 12 +++++++++ .../molecule/default/converge.yml | 8 ++++++ .../molecule/default/molecule.yml | 27 +++++++++++++++++++ .../molecule/default/prepare.yml | 10 +++++++ .../molecule/default/tests/test_default.py | 6 +++++ .../molecule/ubuntu/molecule.yml | 31 ++++++++++++++++++++++ .../prepare-strimzi-kafka-operator/tasks/main.yml | 11 ++++++++ 7 files changed, 105 insertions(+) create mode 100644 ansible/roles/strimzi-kafka-operator/.yamllint create mode 100644 ansible/roles/strimzi-kafka-operator/molecule/default/converge.yml create mode 100644 ansible/roles/strimzi-kafka-operator/molecule/default/molecule.yml create mode 100644 ansible/roles/strimzi-kafka-operator/molecule/default/prepare.yml create mode 100644 ansible/roles/strimzi-kafka-operator/molecule/default/tests/test_default.py create mode 100644 ansible/roles/strimzi-kafka-operator/molecule/ubuntu/molecule.yml create mode 100644 ansible/test/roles/prepare-strimzi-kafka-operator/tasks/main.yml diff --git a/ansible/roles/strimzi-kafka-operator/.yamllint b/ansible/roles/strimzi-kafka-operator/.yamllint new file mode 100644 index 00000000..c5ae64be --- /dev/null +++ b/ansible/roles/strimzi-kafka-operator/.yamllint @@ -0,0 +1,12 @@ +--- +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + truthy: disable diff --git a/ansible/roles/strimzi-kafka-operator/molecule/default/converge.yml b/ansible/roles/strimzi-kafka-operator/molecule/default/converge.yml new file mode 100644 index 00000000..b70400cd --- /dev/null +++ b/ansible/roles/strimzi-kafka-operator/molecule/default/converge.yml @@ -0,0 +1,8 @@ +--- +- name: Converge + hosts: all + pre_tasks: + - name: Include infrastructure group variables + include_vars: ../../../../group_vars/infrastructure.yml + roles: + - strimzi-kafka-operator diff --git a/ansible/roles/strimzi-kafka-operator/molecule/default/molecule.yml b/ansible/roles/strimzi-kafka-operator/molecule/default/molecule.yml new file mode 100644 index 00000000..003267d1 --- /dev/null +++ b/ansible/roles/strimzi-kafka-operator/molecule/default/molecule.yml @@ -0,0 +1,27 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: | + set -e + yamllint . + ansible-lint . + flake8 +platforms: + - name: infrastructure-strimzi-kafka-operator + image: centos:7 + groups: + - infrastructure +provisioner: + name: ansible + env: + ANSIBLE_ROLES_PATH: ../../../../test/roles + ANSIBLE_LIBRARY: ../../../../library + inventory: + group_vars: + all: + app_name: onap + app_data_path: "/opt/{{ app_name }}" +verifier: + name: testinfra diff --git a/ansible/roles/strimzi-kafka-operator/molecule/default/prepare.yml b/ansible/roles/strimzi-kafka-operator/molecule/default/prepare.yml new file mode 100644 index 00000000..34b37f50 --- /dev/null +++ b/ansible/roles/strimzi-kafka-operator/molecule/default/prepare.yml @@ -0,0 +1,10 @@ +--- +- name: Prepare infra container to play strimzi-kafka-operator role + hosts: all + pre_tasks: + - name: Include infrastructure group variables + include_vars: ../../../../group_vars/infrastructure.yml + tasks: + - name: "Include prepare-strimzi-kafka-operator role" + include_role: + name: "prepare-strimzi-kafka-operator" diff --git a/ansible/roles/strimzi-kafka-operator/molecule/default/tests/test_default.py b/ansible/roles/strimzi-kafka-operator/molecule/default/tests/test_default.py new file mode 100644 index 00000000..0a317da4 --- /dev/null +++ b/ansible/roles/strimzi-kafka-operator/molecule/default/tests/test_default.py @@ -0,0 +1,6 @@ +def test_helm_value_file(host): + f = host.file('/opt/onap/strimzi_kafka.yaml') + assert f.exists + assert f.user == 'root' + assert f.group == 'root' + assert f.content_string.strip() == "watchAnyNamespace: true" diff --git a/ansible/roles/strimzi-kafka-operator/molecule/ubuntu/molecule.yml b/ansible/roles/strimzi-kafka-operator/molecule/ubuntu/molecule.yml new file mode 100644 index 00000000..8537ca41 --- /dev/null +++ b/ansible/roles/strimzi-kafka-operator/molecule/ubuntu/molecule.yml @@ -0,0 +1,31 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: | + set -e + yamllint . + ansible-lint . + flake8 +platforms: + - name: infrastructure-ubuntu-strimzi-kafka-operator + image: ubuntu:18.04 + groups: + - infrastructure +provisioner: + name: ansible + env: + ANSIBLE_ROLES_PATH: ../../../../test/roles + ANSIBLE_LIBRARY: ../../../../library + inventory: + group_vars: + all: + app_name: onap + app_data_path: "/opt/{{ app_name }}" + playbooks: + prepare: ../default/prepare.yml + converge: ../default/converge.yml +verifier: + name: testinfra + directory: ../default/tests diff --git a/ansible/test/roles/prepare-strimzi-kafka-operator/tasks/main.yml b/ansible/test/roles/prepare-strimzi-kafka-operator/tasks/main.yml new file mode 100644 index 00000000..435cea21 --- /dev/null +++ b/ansible/test/roles/prepare-strimzi-kafka-operator/tasks/main.yml @@ -0,0 +1,11 @@ +--- +- name: "Ensure {{ app_data_path }}/downloads directory exists" + file: + path: "{{ app_data_path }}/downloads" + recurse: true + state: directory + +- name: "Download strimzi-kafka-operator-helm-3-chart-{{ strimzi_kafka_version }}.tgz" + get_url: + url: "https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.28.0/strimzi-kafka-operator-helm-3-chart-{{ strimzi_kafka_version }}.tgz" + dest: "{{ app_data_path }}/downloads" -- cgit 1.2.3-korg