Add test scenario for Helm v3 89/117289/6
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Mon, 1 Feb 2021 09:48:54 +0000 (10:48 +0100)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Thu, 4 Feb 2021 10:51:46 +0000 (11:51 +0100)
Change-Id: Iad5478f70533719e1076f3961613fddffb14eebd
Issue-ID: OOM-2665
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
ansible/group_vars/infrastructure.yml
ansible/roles/helm/molecule/helm3/Dockerfile.j2 [new symlink]
ansible/roles/helm/molecule/helm3/molecule.yml [new file with mode: 0644]
ansible/roles/helm/molecule/helm3/playbook.yml [new symlink]
ansible/roles/helm/molecule/helm3/prepare.yml [new symlink]
ansible/roles/helm/molecule/helm3/vars.yml [new file with mode: 0644]
ansible/roles/helm/tasks/main.yml
ansible/test/roles/prepare-helm/tasks/main.yml

index a1643a1..12d1044 100755 (executable)
@@ -20,6 +20,7 @@ all_simulated_hosts:
 populate_nexus: false
 helm_bin_dir: /usr/local/bin
 helm_version: v2.16.6
+helm3_push_version: 0.9.0
 rancher_server_image: rancher/server:v1.6.22
 vnc_server_image: consol/ubuntu-icewm-vnc:1.4.0
 nexus3_image: sonatype/nexus3:3.15.2
diff --git a/ansible/roles/helm/molecule/helm3/Dockerfile.j2 b/ansible/roles/helm/molecule/helm3/Dockerfile.j2
new file mode 120000 (symlink)
index 0000000..867ec5c
--- /dev/null
@@ -0,0 +1 @@
+../default/Dockerfile.j2
\ No newline at end of file
diff --git a/ansible/roles/helm/molecule/helm3/molecule.yml b/ansible/roles/helm/molecule/helm3/molecule.yml
new file mode 100644 (file)
index 0000000..e863447
--- /dev/null
@@ -0,0 +1,31 @@
+---
+dependency:
+  name: galaxy
+driver:
+  name: docker
+lint:
+  name: yamllint
+platforms:
+  - name: infrastructure-server-helm3
+    image: centos:7
+    groups:
+      - infrastructure
+provisioner:
+  name: ansible
+  lint:
+    name: ansible-lint
+  env:
+    ANSIBLE_ROLES_PATH: ../../../../test/roles
+    ANSIBLE_LIBRARY: ../../../../library
+  inventory:
+    group_vars:
+      all:
+        app_name: onap
+        app_data_path: "/opt/{{ app_name }}"
+scenario:
+  name: helm3
+verifier:
+  name: testinfra
+  lint:
+    name: flake8
+  directory: ../default/tests
diff --git a/ansible/roles/helm/molecule/helm3/playbook.yml b/ansible/roles/helm/molecule/helm3/playbook.yml
new file mode 120000 (symlink)
index 0000000..a3e2679
--- /dev/null
@@ -0,0 +1 @@
+../default/playbook.yml
\ No newline at end of file
diff --git a/ansible/roles/helm/molecule/helm3/prepare.yml b/ansible/roles/helm/molecule/helm3/prepare.yml
new file mode 120000 (symlink)
index 0000000..1c017d9
--- /dev/null
@@ -0,0 +1 @@
+../default/prepare.yml
\ No newline at end of file
diff --git a/ansible/roles/helm/molecule/helm3/vars.yml b/ansible/roles/helm/molecule/helm3/vars.yml
new file mode 100644 (file)
index 0000000..7ff3771
--- /dev/null
@@ -0,0 +1,2 @@
+---
+helm_version: v3.3.4
index c1b4710..64db785 100644 (file)
@@ -9,3 +9,32 @@
       - '*/helm'
     remote_src: true
     mode: 0755
+
+- name: Install helm-push plugin if runing with Helm v3
+  block:
+    - name: Get helm environment information
+      command: "{{ helm_bin_dir }}/helm env"
+      register: helm_env
+      changed_when: false  # for idempotency
+
+    - name: Set helm plugin dir fact
+      set_fact:
+        helm_plugin_dir:
+          "{% if 'HELM_PLUGINS' in helm_env.stdout -%}
+           {{ (helm_env.stdout | replace('\"', '') | regex_search('HELM_PLUGINS.*')).split('=')[1] }}
+           {%- else -%}
+           {{ '~/.local/share/helm/plugins' }}
+           {%- endif %}"
+
+    - name: Ensure that plugin directory exists
+      file:
+        path: "{{ helm_plugin_dir }}/helm-push"
+        state: directory
+        mode: 0755
+
+    - name: Deploy helm-push plugin
+      unarchive:
+        src: "{{ app_data_path }}/downloads/helm-push_{{ helm3_push_version }}_linux_amd64.tar.gz"
+        dest: "{{ helm_plugin_dir }}/helm-push"
+        remote_src: true
+  when: helm_version | regex_search("^v3" )
index 1f46125..c1d25de 100644 (file)
@@ -9,4 +9,13 @@
   get_url:
     url: "https://get.helm.sh/helm-{{ helm_version }}-linux-amd64.tar.gz"
     dest: "{{ app_data_path }}/downloads"
-    remote_src: true
+
+- name: Download Helm v3 helm-push plugin
+  command: "curl --connect-timeout 10 -L https://github.com/chartmuseum/helm-push/releases/download/v{{ helm3_push_version }}/helm-push_{{ helm3_push_version }}_linux_amd64.tar.gz -o {{ app_data_path }}/downloads/helm-push_{{ helm3_push_version }}_linux_amd64.tar.gz"
+  register: result
+  retries: 10
+  delay: 1
+  until: not result.failed
+  args:
+    warn: false
+  when: helm_version | regex_search("^v3" )