From 007a4bdfef2e398d9141cc903927bae03ea4bc7a Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Mon, 1 Feb 2021 10:13:03 +0100 Subject: Refactor Helm role test setup Test setup variable inclusion reworked for better sanity. General Molecule docker image is used instead of pre-built one. Change-Id: I013b9d7b92ded86220e6f2092ce75ee47b094d89 Issue-ID: OOM-2665 Signed-off-by: Bartek Grzybowski --- ansible/roles/helm/molecule/default/Dockerfile.j2 | 14 ++++++++++++++ .../helm/molecule/default/group_vars/infrastructure.yml | 1 - ansible/roles/helm/molecule/default/molecule.yml | 6 +----- ansible/roles/helm/molecule/default/playbook.yml | 5 +++++ ansible/roles/helm/molecule/default/prepare.yml | 2 ++ ansible/roles/helm/molecule/default/vars.yml | 1 + ansible/roles/helm/molecule/ubuntu/Dockerfile.j2 | 1 + ansible/roles/helm/molecule/ubuntu/group_vars | 1 - ansible/roles/helm/molecule/ubuntu/molecule.yml | 6 +----- 9 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 ansible/roles/helm/molecule/default/Dockerfile.j2 delete mode 120000 ansible/roles/helm/molecule/default/group_vars/infrastructure.yml create mode 100644 ansible/roles/helm/molecule/default/vars.yml create mode 120000 ansible/roles/helm/molecule/ubuntu/Dockerfile.j2 delete mode 120000 ansible/roles/helm/molecule/ubuntu/group_vars diff --git a/ansible/roles/helm/molecule/default/Dockerfile.j2 b/ansible/roles/helm/molecule/default/Dockerfile.j2 new file mode 100644 index 00000000..e6aa95d3 --- /dev/null +++ b/ansible/roles/helm/molecule/default/Dockerfile.j2 @@ -0,0 +1,14 @@ +# Molecule managed + +{% if item.registry is defined %} +FROM {{ item.registry.url }}/{{ item.image }} +{% else %} +FROM {{ item.image }} +{% endif %} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \ + elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi diff --git a/ansible/roles/helm/molecule/default/group_vars/infrastructure.yml b/ansible/roles/helm/molecule/default/group_vars/infrastructure.yml deleted file mode 120000 index 3e9c2f0c..00000000 --- a/ansible/roles/helm/molecule/default/group_vars/infrastructure.yml +++ /dev/null @@ -1 +0,0 @@ -../../../../../group_vars/infrastructure.yml \ No newline at end of file diff --git a/ansible/roles/helm/molecule/default/molecule.yml b/ansible/roles/helm/molecule/default/molecule.yml index 0d46c2d4..359d3aba 100644 --- a/ansible/roles/helm/molecule/default/molecule.yml +++ b/ansible/roles/helm/molecule/default/molecule.yml @@ -7,10 +7,7 @@ lint: name: yamllint platforms: - name: infrastructure-server - image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6} - pre_build_image: True - privileged: true - override_command: False + image: centos:7 groups: - infrastructure provisioner: @@ -25,7 +22,6 @@ provisioner: all: app_name: onap app_data_path: "/opt/{{ app_name }}" - helm_bin_dir: /usr/local/bin scenario: name: default verifier: diff --git a/ansible/roles/helm/molecule/default/playbook.yml b/ansible/roles/helm/molecule/default/playbook.yml index 2705b165..0f3fbc27 100644 --- a/ansible/roles/helm/molecule/default/playbook.yml +++ b/ansible/roles/helm/molecule/default/playbook.yml @@ -1,5 +1,10 @@ --- - name: Converge hosts: all + pre_tasks: + - name: Include infrastructure group variables + include_vars: ../../../../group_vars/infrastructure.yml + - name: Include test scenario variables + include_vars: vars.yml roles: - helm diff --git a/ansible/roles/helm/molecule/default/prepare.yml b/ansible/roles/helm/molecule/default/prepare.yml index 34c41e8e..10ccf232 100644 --- a/ansible/roles/helm/molecule/default/prepare.yml +++ b/ansible/roles/helm/molecule/default/prepare.yml @@ -4,5 +4,7 @@ pre_tasks: - name: Include infrastructure group variables include_vars: ../../../../group_vars/infrastructure.yml + - name: Include test scenario variables + include_vars: vars.yml roles: - prepare-helm diff --git a/ansible/roles/helm/molecule/default/vars.yml b/ansible/roles/helm/molecule/default/vars.yml new file mode 100644 index 00000000..ed97d539 --- /dev/null +++ b/ansible/roles/helm/molecule/default/vars.yml @@ -0,0 +1 @@ +--- diff --git a/ansible/roles/helm/molecule/ubuntu/Dockerfile.j2 b/ansible/roles/helm/molecule/ubuntu/Dockerfile.j2 new file mode 120000 index 00000000..867ec5c3 --- /dev/null +++ b/ansible/roles/helm/molecule/ubuntu/Dockerfile.j2 @@ -0,0 +1 @@ +../default/Dockerfile.j2 \ No newline at end of file diff --git a/ansible/roles/helm/molecule/ubuntu/group_vars b/ansible/roles/helm/molecule/ubuntu/group_vars deleted file mode 120000 index 5ce8257f..00000000 --- a/ansible/roles/helm/molecule/ubuntu/group_vars +++ /dev/null @@ -1 +0,0 @@ -../default/group_vars/ \ No newline at end of file diff --git a/ansible/roles/helm/molecule/ubuntu/molecule.yml b/ansible/roles/helm/molecule/ubuntu/molecule.yml index a375a32d..a43ff074 100644 --- a/ansible/roles/helm/molecule/ubuntu/molecule.yml +++ b/ansible/roles/helm/molecule/ubuntu/molecule.yml @@ -7,10 +7,7 @@ lint: name: yamllint platforms: - name: infrastructure-server - image: molecule-${PREBUILD_PLATFORM_DISTRO:-ubuntu}:${PREBUILD_DISTRO_VERSION:-18.04} - pre_build_image: True - privileged: true - override_command: False + image: ubuntu:18.04 groups: - infrastructure provisioner: @@ -28,7 +25,6 @@ provisioner: all: app_name: onap app_data_path: "/opt/{{ app_name }}" - helm_bin_dir: /usr/local/bin scenario: name: ubuntu verifier: -- cgit 1.2.3-korg