diff options
author | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2021-02-16 13:12:45 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-02-16 13:12:45 +0000 |
commit | 9880331a27a67063d802c67b2ecf95c677046406 (patch) | |
tree | 22eca98787a905c85e5cc842d2db40f1328d5b7b /ansible/test | |
parent | 8ec40e9842c856ed4c14d91755cc26b7c81b8f01 (diff) | |
parent | d6908ed39dd5e58c539c1c818f371849dd0271eb (diff) |
Merge changes from topic "ansible-helm3"
* changes:
Run chartmuseum as a docker container
Update 'helm deploy' failure criteria
Fix kubeconfig file permissions
Ensure k8s namespace for ONAP exists
Customize helm "--timeout" option format if running helm v3
Redirect chartmuseum stdout/stderr to /dev/null
Drop DIND specific test env settings for 'rke' role/playbook
Improve bin utils symlink creation logic
Add test scenario for Helm v3
Refactor Helm role test setup
Add helm-push Helm v3 plugin to downloaded utilities list
Fix Helm v3 data dir setup
Add tasks to setup Helm v3 on infra node
Add Helm v3 test scenario to rke playbook tests
Change 'rke' role testing strategy
Workaround RKE binary download issue
Play 'chartmuseum' role in rke playbook if running with Helm v3
Fix variable inclusion order in RKE playbook tests
Add Helm v3.3.4 to the list of downloaded utilities
Add 'chartmuseum' binary to downloaded utilities list
Add Molecule test scenario to verify 'chartmuseum' role on Ubuntu
Add 'chartmuseum' role
Split Helm v2 setup to separate playbook
Improve 'application' role test coverage
Diffstat (limited to 'ansible/test')
-rwxr-xr-x | ansible/test/bin/install-molecule.sh | 3 | ||||
-rw-r--r-- | ansible/test/play-infrastructure/molecule/default/prepare.yml | 2 | ||||
-rw-r--r-- | ansible/test/play-rke/molecule/default/molecule.yml | 16 | ||||
-rw-r--r-- | ansible/test/play-rke/molecule/default/prepare.yml | 5 | ||||
-rw-r--r-- | ansible/test/play-rke/molecule/default/vars.yml | 1 | ||||
-rw-r--r-- | ansible/test/play-rke/molecule/helm3/molecule.yml | 39 | ||||
l--------- | ansible/test/play-rke/molecule/helm3/playbook.yml | 1 | ||||
l--------- | ansible/test/play-rke/molecule/helm3/prepare.yml | 1 | ||||
-rw-r--r-- | ansible/test/play-rke/molecule/helm3/vars.yml | 5 | ||||
-rw-r--r-- | ansible/test/roles/prepare-application/tasks/main.yml | 9 | ||||
-rw-r--r-- | ansible/test/roles/prepare-chartmuseum/tasks/main.yml | 18 | ||||
-rw-r--r-- | ansible/test/roles/prepare-helm/tasks/main.yml | 11 | ||||
-rw-r--r-- | ansible/test/roles/prepare-rke/tasks/all.yml | 10 | ||||
-rw-r--r-- | ansible/test/roles/prepare-rke/tasks/infra.yml | 21 | ||||
-rw-r--r-- | ansible/test/roles/prepare-rke/templates/rke.j2 | 14 |
15 files changed, 126 insertions, 30 deletions
diff --git a/ansible/test/bin/install-molecule.sh b/ansible/test/bin/install-molecule.sh index ab6de436..4df06684 100755 --- a/ansible/test/bin/install-molecule.sh +++ b/ansible/test/bin/install-molecule.sh @@ -41,5 +41,6 @@ source ${VENV_PATH}/bin/activate # Install Molecule if [ ! -z ${VIRTUAL_ENV} ]; then echo "Activated virtual env in ${VIRTUAL_ENV}" - pip -q install molecule==2.20 ansible==2.7.8 ansible-lint==4.2.0 docker pyopenssl + pip -q install -U pip + pip -q install pyopenssl molecule==2.20 ansible==2.7.8 ansible-lint==4.2.0 docker fi diff --git a/ansible/test/play-infrastructure/molecule/default/prepare.yml b/ansible/test/play-infrastructure/molecule/default/prepare.yml index 86e25b48..634234ac 100644 --- a/ansible/test/play-infrastructure/molecule/default/prepare.yml +++ b/ansible/test/play-infrastructure/molecule/default/prepare.yml @@ -9,12 +9,14 @@ - prepare-nexus - prepare-dns - prepare-firewall + - prepare-chartmuseum vars_files: - vars.yml - ../../../../roles/nginx/defaults/main.yml - ../../../../roles/vncserver/defaults/main.yml - ../../../../roles/nexus/defaults/main.yml - ../../../../roles/dns/defaults/main.yml + - ../../../../roles/chartmuseum/defaults/main.yml - name: Prepare kubernetes hosts: kubernetes diff --git a/ansible/test/play-rke/molecule/default/molecule.yml b/ansible/test/play-rke/molecule/default/molecule.yml index b7e71bf5..519679a5 100644 --- a/ansible/test/play-rke/molecule/default/molecule.yml +++ b/ansible/test/play-rke/molecule/default/molecule.yml @@ -11,35 +11,19 @@ platforms: pre_build_image: true privileged: true override_command: false - restart_policy: unless-stopped - volumes: - - /var/lib/docker - - /var/lib/kubelet groups: - infrastructure - kubernetes-etcd - kubernetes-control-plane - kubernetes - networks: - - name: rke - purge_networks: true - - name: kubernetes-node-1 image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6} pre_build_image: true privileged: true override_command: false - restart_policy: unless-stopped - volumes: - - /var/lib/docker - - /var/lib/kubelet groups: - kubernetes - kubernetes-node - networks: - - name: rke - purge_networks: true - provisioner: name: ansible env: diff --git a/ansible/test/play-rke/molecule/default/prepare.yml b/ansible/test/play-rke/molecule/default/prepare.yml index ad6f0495..6d810052 100644 --- a/ansible/test/play-rke/molecule/default/prepare.yml +++ b/ansible/test/play-rke/molecule/default/prepare.yml @@ -2,7 +2,6 @@ - name: Prepare for all hosts: all roles: - - prepare-docker-dind - role: prepare-rke vars: mode: all @@ -12,11 +11,11 @@ pre_tasks: - name: Include infrastructure group variables include_vars: ../../../../group_vars/infrastructure.yml + - name: Include test setup variables + include_vars: vars.yml roles: - role: prepare-rke vars: mode: infra - prepare-kubectl - prepare-helm - vars_files: - vars.yml diff --git a/ansible/test/play-rke/molecule/default/vars.yml b/ansible/test/play-rke/molecule/default/vars.yml index fa5b60e3..739dc955 100644 --- a/ansible/test/play-rke/molecule/default/vars.yml +++ b/ansible/test/play-rke/molecule/default/vars.yml @@ -1,3 +1,4 @@ --- app_name: moleculeapp app_data_path: "/opt/{{ app_name }}" +cluster_config_dir: "/opt/{{ app_name }}/cluster" diff --git a/ansible/test/play-rke/molecule/helm3/molecule.yml b/ansible/test/play-rke/molecule/helm3/molecule.yml new file mode 100644 index 00000000..83a2fd20 --- /dev/null +++ b/ansible/test/play-rke/molecule/helm3/molecule.yml @@ -0,0 +1,39 @@ +--- +dependency: + name: galaxy +driver: + name: docker +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 + groups: + - infrastructure + - kubernetes-etcd + - kubernetes-control-plane + - kubernetes + - name: kubernetes-node-1 + image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6} + pre_build_image: true + privileged: true + override_command: false + groups: + - kubernetes + - kubernetes-node +provisioner: + name: ansible + env: + ANSIBLE_ROLES_PATH: ../../../../test/roles + ANSIBLE_LIBRARY: ../../../../library + lint: + name: ansible-lint +scenario: + name: helm3 +verifier: + name: testinfra + lint: + name: flake8 diff --git a/ansible/test/play-rke/molecule/helm3/playbook.yml b/ansible/test/play-rke/molecule/helm3/playbook.yml new file mode 120000 index 00000000..a3e26797 --- /dev/null +++ b/ansible/test/play-rke/molecule/helm3/playbook.yml @@ -0,0 +1 @@ +../default/playbook.yml
\ No newline at end of file diff --git a/ansible/test/play-rke/molecule/helm3/prepare.yml b/ansible/test/play-rke/molecule/helm3/prepare.yml new file mode 120000 index 00000000..1c017d9a --- /dev/null +++ b/ansible/test/play-rke/molecule/helm3/prepare.yml @@ -0,0 +1 @@ +../default/prepare.yml
\ No newline at end of file diff --git a/ansible/test/play-rke/molecule/helm3/vars.yml b/ansible/test/play-rke/molecule/helm3/vars.yml new file mode 100644 index 00000000..e16e502f --- /dev/null +++ b/ansible/test/play-rke/molecule/helm3/vars.yml @@ -0,0 +1,5 @@ +--- +app_name: moleculeapp +app_data_path: "/opt/{{ app_name }}" +cluster_config_dir: "/opt/{{ app_name }}/cluster" +helm_version: v3.3.4 diff --git a/ansible/test/roles/prepare-application/tasks/main.yml b/ansible/test/roles/prepare-application/tasks/main.yml index 75abb802..9eb695b1 100644 --- a/ansible/test/roles/prepare-application/tasks/main.yml +++ b/ansible/test/roles/prepare-application/tasks/main.yml @@ -6,6 +6,7 @@ delegate_to: localhost loop: - "{{ app_helm_charts_install_directory }}" + - "{{ app_helm_charts_install_directory + '/helm' + '/plugins' + '/deploy' }}" - certs - "{{ application_pre_install_role + '/tasks/' }}" - "{{ application_post_install_role + '/tasks/' }}" @@ -19,6 +20,14 @@ delegate_to: localhost when: simulate_helm +- name: Create Helm plugin mock + copy: + content: | + # Mocked Helm plugin + dest: "{{ app_helm_charts_install_directory + '/helm' + '/plugins' + '/deploy' }}/deploy.sh" + delegate_to: localhost + when: simulate_helm + - name: Clean previous simulation output file file: path: "{{ helm_simulation_output_file }}" diff --git a/ansible/test/roles/prepare-chartmuseum/tasks/main.yml b/ansible/test/roles/prepare-chartmuseum/tasks/main.yml new file mode 100644 index 00000000..a46888e8 --- /dev/null +++ b/ansible/test/roles/prepare-chartmuseum/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: "Create chartmuseum image storage dir" + file: + path: "{{ infra_images_path }}" + state: directory + mode: "u+rw,g+wx,o+rwx" + recurse: true + +- name: Download and archive chartmuseum docker image + delegate_to: localhost + docker_image: + name: "{{ chartmuseum_server_image }}" + archive_path: /tmp/chartmuseum.tar + +- name: Copy chartmuseum image to node + copy: + src: /tmp/chartmuseum.tar + dest: "{{ infra_images_path }}/{{ chartmuseum_server_image_tar }}" diff --git a/ansible/test/roles/prepare-helm/tasks/main.yml b/ansible/test/roles/prepare-helm/tasks/main.yml index 1f461258..c1d25de0 100644 --- a/ansible/test/roles/prepare-helm/tasks/main.yml +++ b/ansible/test/roles/prepare-helm/tasks/main.yml @@ -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" ) diff --git a/ansible/test/roles/prepare-rke/tasks/all.yml b/ansible/test/roles/prepare-rke/tasks/all.yml index d4b67c1f..a259577c 100644 --- a/ansible/test/roles/prepare-rke/tasks/all.yml +++ b/ansible/test/roles/prepare-rke/tasks/all.yml @@ -1,6 +1,4 @@ -#This is needed because login from non root is blocked by default. -- name: "Allow non root logins" - service: - name: systemd-user-sessions - state: started - +--- +- name: "Add docker group" + group: + name: docker diff --git a/ansible/test/roles/prepare-rke/tasks/infra.yml b/ansible/test/roles/prepare-rke/tasks/infra.yml index 6e7bcb96..0a0b9273 100644 --- a/ansible/test/roles/prepare-rke/tasks/infra.yml +++ b/ansible/test/roles/prepare-rke/tasks/infra.yml @@ -4,7 +4,22 @@ path: "{{ app_data_path }}/downloads" state: directory -- name: "Install rke-{{ rke_version }}" - get_url: - url: "https://github.com/rancher/rke/releases/download/v{{ rke_version }}/rke_linux-amd64" +- name: "Create rke binary wrapper" + template: + src: rke.j2 dest: "{{ app_data_path }}/downloads/rke_linux-amd64" + mode: 0755 + +- name: "Install rke-{{ rke_version }}" + command: "curl --connect-timeout 10 -L https://github.com/rancher/rke/releases/download/v{{ rke_version }}/rke_linux-amd64 -o {{ app_data_path }}/downloads/rke_linux-amd64_real" + register: result + retries: 10 + delay: 1 + until: not result.failed + args: + warn: false + +- name: "Ensure downloaded rke binary has correct file mode" + file: + path: "{{ app_data_path }}/downloads/rke_linux-amd64_real" + mode: 0755 diff --git a/ansible/test/roles/prepare-rke/templates/rke.j2 b/ansible/test/roles/prepare-rke/templates/rke.j2 new file mode 100644 index 00000000..ea1267ea --- /dev/null +++ b/ansible/test/roles/prepare-rke/templates/rke.j2 @@ -0,0 +1,14 @@ +#!/bin/bash + +if [[ $@ =~ 'up' ]]; +then + # If the operation is 'rke up' then simulate rke up operation + echo $@ + touch {{ cluster_config_dir }}/kube_config_cluster.yml +elif [[ $@ =~ 'version' ]]; +then + {{ app_data_path }}/downloads/rke_linux-amd64_real version + exit 0 +else + {{ app_data_path }}/downloads/rke_linux-amd64_real $@ +fi |