diff options
Diffstat (limited to 'ansible/test')
29 files changed, 124 insertions, 174 deletions
diff --git a/ansible/test/play-infrastructure/molecule/default/cleanup.yml b/ansible/test/play-infrastructure/molecule/default/cleanup.yml new file mode 100644 index 00000000..107ec8ca --- /dev/null +++ b/ansible/test/play-infrastructure/molecule/default/cleanup.yml @@ -0,0 +1,7 @@ +--- +- name: Cleanup + hosts: all + ignore_unreachable: true + roles: + - cleanup-nginx + - cleanup-vncserver diff --git a/ansible/test/play-infrastructure/molecule/default/vars.yml b/ansible/test/play-infrastructure/molecule/default/vars.yml index e91eadb2..6ca5a1ad 100644 --- a/ansible/test/play-infrastructure/molecule/default/vars.yml +++ b/ansible/test/play-infrastructure/molecule/default/vars.yml @@ -16,9 +16,9 @@ molecule_test_registry: nexus3.onap.org:10001 runtime_images: busybox: registry: "{{ molecule_test_registry }}" - path: "/onap/components/busybox" + path: "/busybox" tag: "latest" aaionap-haproxy: registry: "{{ molecule_test_registry }}" - path: "/onap/components/aaionap/haproxy" + path: "/aaionap/haproxy" tag: "1.2.4" diff --git a/ansible/test/play-resources/molecule/default/cleanup.yml b/ansible/test/play-resources/molecule/default/cleanup.yml deleted file mode 100644 index e0c0b624..00000000 --- a/ansible/test/play-resources/molecule/default/cleanup.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: Cleanup data from instance (doing it from hosts requires root access). - hosts: resources - gather_facts: false - ignore_unreachable: true - pre_tasks: - - name: Find files and dirs to delete - find: - paths: /data/ # Only deleting content not dir itself as we get "Device or resource busy" error as it's mounted to container doing the deletion - patterns: "*" - recurse: true - file_type: any - register: files_to_delete - - name: Make file/dir path list - set_fact: - to_delete_paths: "{{ to_delete_paths | default([]) + [item.path] }}" - loop: "{{ files_to_delete.files }}" - when: files_to_delete.files is defined - roles: - - role: cleanup-directories - vars: - directories_files_list_to_remove: "{{ to_delete_paths }}" - when: to_delete_paths is defined diff --git a/ansible/test/play-resources/molecule/default/playbook.yml b/ansible/test/play-resources/molecule/default/playbook.yml index 50ba233a..096077a2 100644 --- a/ansible/test/play-resources/molecule/default/playbook.yml +++ b/ansible/test/play-resources/molecule/default/playbook.yml @@ -1,6 +1,8 @@ --- -- name: Test resource transfer with ssh +- name: Initialize hosts: all - roles: - - setup - - resource-data + tasks: + - name: Include variables + include_vars: vars.yml + +- import_playbook: ../../../../resources.yml diff --git a/ansible/test/play-resources/molecule/default/prepare.yml b/ansible/test/play-resources/molecule/default/prepare.yml index a4436001..5c8ae654 100644 --- a/ansible/test/play-resources/molecule/default/prepare.yml +++ b/ansible/test/play-resources/molecule/default/prepare.yml @@ -2,4 +2,7 @@ - name: Prepare resource-data hosts: all roles: + - setup - prepare-resource-data + vars_files: + - vars.yml diff --git a/ansible/test/play-resources/molecule/default/group_vars/all.yml b/ansible/test/play-resources/molecule/default/vars.yml index 558eacb2..46ab3e04 100644 --- a/ansible/test/play-resources/molecule/default/group_vars/all.yml +++ b/ansible/test/play-resources/molecule/default/vars.yml @@ -1,5 +1,5 @@ --- -app_data_path: /opt/myleculeapp +app_data_path: /opt/moleculeapp aux_data_path: "{{ app_data_path }}/runtime_images_source_dir" resources_dir: /data resources_filename: resources_package.tar diff --git a/ansible/test/play-resources/molecule/nfs/molecule.yml b/ansible/test/play-resources/molecule/nfs/molecule.yml index ffaabb07..11726396 100644 --- a/ansible/test/play-resources/molecule/nfs/molecule.yml +++ b/ansible/test/play-resources/molecule/nfs/molecule.yml @@ -13,7 +13,7 @@ platforms: override_command: false volumes: - /sys/fs/cgroup:/sys/fs/cgroup:ro - - ${HOME}/data:/data:rw # mount fs from host to get nfs exportfs task working + - /data groups: - resources networks: @@ -32,13 +32,8 @@ platforms: - name: resource-data provisioner: name: ansible - playbooks: - cleanup: ../default/cleanup.yml env: ANSIBLE_ROLES_PATH: ../../../../roles:../../../roles - inventory: - links: - group_vars: ../default/group_vars lint: name: ansible-lint verifier: diff --git a/ansible/test/play-resources/molecule/nfs/playbook.yml b/ansible/test/play-resources/molecule/nfs/playbook.yml index 88440116..096077a2 100644 --- a/ansible/test/play-resources/molecule/nfs/playbook.yml +++ b/ansible/test/play-resources/molecule/nfs/playbook.yml @@ -1,8 +1,8 @@ --- -- name: Test resource transfer with nfs +- name: Initialize hosts: all - roles: - - setup - - role: resource-data - vars: - resources_on_nfs: true + tasks: + - name: Include variables + include_vars: vars.yml + +- import_playbook: ../../../../resources.yml diff --git a/ansible/test/play-resources/molecule/nfs/prepare.yml b/ansible/test/play-resources/molecule/nfs/prepare.yml index d381ba77..2276f2e8 100644 --- a/ansible/test/play-resources/molecule/nfs/prepare.yml +++ b/ansible/test/play-resources/molecule/nfs/prepare.yml @@ -1,7 +1,7 @@ --- -- name: Prepare resource-data +- name: Prepare hosts: all roles: - - role: prepare-resource-data - vars: - resources_on_nfs: true + - prepare-resource-data + vars_files: + - vars.yml diff --git a/ansible/test/play-resources/molecule/nfs/vars.yml b/ansible/test/play-resources/molecule/nfs/vars.yml new file mode 100644 index 00000000..2cc4d258 --- /dev/null +++ b/ansible/test/play-resources/molecule/nfs/vars.yml @@ -0,0 +1,7 @@ +--- +app_data_path: /opt/moleculeapp +aux_data_path: "{{ app_data_path }}/runtime_images_source_dir" +resources_on_nfs: true +resources_dir: /data +resources_filename: resources_package.tar +aux_resources_filename: aux_resources_package.tar diff --git a/ansible/test/roles/cleanup-application/tasks/main.yml b/ansible/test/roles/cleanup-application/tasks/main.yml new file mode 100644 index 00000000..cbb8d521 --- /dev/null +++ b/ansible/test/roles/cleanup-application/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Clean application role mocked artifacts directories + file: + path: "{{ item }}" + state: absent + delegate_to: localhost + loop: + - certs + - application diff --git a/ansible/test/roles/cleanup-containers/tasks/main.yml b/ansible/test/roles/cleanup-containers/tasks/main.yml deleted file mode 100644 index 3a800c9e..00000000 --- a/ansible/test/roles/cleanup-containers/tasks/main.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: Remove containers - docker_container: - name: "{{ item }}" - state: absent - loop: "{{ container_list }}" diff --git a/ansible/test/roles/cleanup-directories/tasks/main.yml b/ansible/test/roles/cleanup-directories/tasks/main.yml deleted file mode 100644 index 8e79ea0c..00000000 --- a/ansible/test/roles/cleanup-directories/tasks/main.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Remove directories/files - file: - path: "{{ item }}" - state: absent - become: true - loop: "{{ directories_files_list_to_remove }}" diff --git a/ansible/test/roles/cleanup-nginx/tasks/main.yml b/ansible/test/roles/cleanup-nginx/tasks/main.yml new file mode 100644 index 00000000..94517519 --- /dev/null +++ b/ansible/test/roles/cleanup-nginx/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: Remove saved nginx docker image + delegate_to: localhost + file: + path: /tmp/nginx.tar + state: absent diff --git a/ansible/test/roles/cleanup-rancher/tasks/main.yml b/ansible/test/roles/cleanup-rancher/tasks/main.yml deleted file mode 100644 index 21b02988..00000000 --- a/ansible/test/roles/cleanup-rancher/tasks/main.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -# Remove containers spawned by Rancher Agent -- name: Get list of containers spawned by Rancher Agent - docker_list_containers: - label_name: "{{ item.label }}" - label_value: "{{ item.value }}" - loop: "{{ container_list_by_label }}" - register: docker_list_containers_var - -- name: set fact # save a list of containers found by previous task to orphaned_containers var - set_fact: orphaned_containers="{{ orphaned_containers|default([]) + item.containers }}" - loop: "{{ docker_list_containers_var.results }}" - -- name: Remove orphaned containers - docker_container: - name: "{{ item }}" - state: absent - loop: "{{ orphaned_containers }}" diff --git a/ansible/test/roles/cleanup-vncserver/tasks/main.yml b/ansible/test/roles/cleanup-vncserver/tasks/main.yml new file mode 100644 index 00000000..1fcb37d8 --- /dev/null +++ b/ansible/test/roles/cleanup-vncserver/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: Remove saved vncserver docker image + delegate_to: localhost + file: + path: /tmp/vncserver.tar + state: absent diff --git a/ansible/test/roles/prepare-application/defaults/main.yml b/ansible/test/roles/prepare-application/defaults/main.yml index 227bd4f0..c3883c65 100644 --- a/ansible/test/roles/prepare-application/defaults/main.yml +++ b/ansible/test/roles/prepare-application/defaults/main.yml @@ -1,4 +1,6 @@ --- simulate_helm: true app_helm_charts_install_directory: application/helm_charts -helm_simulation_output_file: /tmp/helm_simu_output
\ No newline at end of file +helm_simulation_output_file: /tmp/helm_simu_output +application_pre_install_role: application/test-patch-role +application_post_install_role: application/test-patch-role diff --git a/ansible/test/roles/prepare-application/tasks/main.yml b/ansible/test/roles/prepare-application/tasks/main.yml index 2f143a07..75abb802 100644 --- a/ansible/test/roles/prepare-application/tasks/main.yml +++ b/ansible/test/roles/prepare-application/tasks/main.yml @@ -1,9 +1,14 @@ --- -- name: Create Application helm charts directory +- name: Create application role mocked artifacts directories file: - path: "{{ app_helm_charts_install_directory }}" + path: "{{ item }}" state: directory delegate_to: localhost + loop: + - "{{ app_helm_charts_install_directory }}" + - certs + - "{{ application_pre_install_role + '/tasks/' }}" + - "{{ application_post_install_role + '/tasks/' }}" - name: Create Makefile to simulate helm charts dir and make building copy: @@ -33,15 +38,19 @@ name: make state: present -- name: Create local certs dir for dummy certs - file: - path: certs - state: directory - delegate_to: localhost - - name: Create dummy cert file to simulate offline server certificates in helm install with override.yml file copy: content: | this is dummy server certificate value dest: certs/rootCA.crt delegate_to: localhost + +- name: Create test patch role files + copy: + content: | + --- + - name: Mocked up patch role + debug: + msg: "Noop task to mock up patch role" + dest: application/test-patch-role/tasks/main.yml + delegate_to: localhost diff --git a/ansible/test/roles/prepare-docker/tasks/docker-packages.yml b/ansible/test/roles/prepare-docker/tasks/docker-packages.yml deleted file mode 100644 index 8f55c5ce..00000000 --- a/ansible/test/roles/prepare-docker/tasks/docker-packages.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Download docker related packages - command: yumdownloader --destdir="{{ rpm_dir }}" "{{ docker_ce_rpm }}" - args: - creates: "{{ rpm_dir }}/{{ docker_ce_rpm }}" - -- name: Install docker related packages - yum: - name: "{{ rpm_dir + '/' + docker_ce_rpm + '.rpm'}}" diff --git a/ansible/test/roles/prepare-docker/tasks/docker-socket-override.yml b/ansible/test/roles/prepare-docker/tasks/docker-socket-override.yml deleted file mode 100644 index 0cabadf4..00000000 --- a/ansible/test/roles/prepare-docker/tasks/docker-socket-override.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- name: Create docker.socket systemd dir for override - file: - path: /etc/systemd/system/docker.socket.d - state: directory - -- name: Fake dockerd dependent docker.socket service not to actually listen the docker socket as dockerd is not used in container only docker client - copy: - content: | - [Socket] - ListenStream= - ListenStream=/tmp/fake - dest: /etc/systemd/system/docker.socket.d/override.conf diff --git a/ansible/test/roles/prepare-docker/tasks/enable-repos.yml b/ansible/test/roles/prepare-docker/tasks/enable-repos.yml deleted file mode 100644 index 204bf03d..00000000 --- a/ansible/test/roles/prepare-docker/tasks/enable-repos.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- name: Enable docker repos back for Molecule testing purposes - copy: - remote_src: yes - src: "{{ item }}" - dest: "{{ (item | splitext)[0] }}" - loop: "{{ docker_needed_repos }}" - -- name: Disable offline repo for molecule testing purposes - lineinfile: - path: "{{ offline_repo_file }}" - regexp: 'enabled = 1' - line: 'enabled = 0' diff --git a/ansible/test/roles/prepare-docker/tasks/main.yml b/ansible/test/roles/prepare-docker/tasks/main.yml deleted file mode 100644 index e7d87061..00000000 --- a/ansible/test/roles/prepare-docker/tasks/main.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- name: Check repositories - stat: - path: "{{ item }}" - loop: "{{ docker_needed_repos + [offline_repo_file] }}" - register: repos - -- name: Set fact for offline repos created - set_fact: - offline_repo_created: "{{ (repos.results | map(attribute='stat.exists') | list) is all }}" - -- debug: - var: offline_repo_created - -- name: Enable repos back (if package-repository role already setup offline onap repo) for molecule testing purposes to install docker - include_tasks: enable-repos.yml - when: offline_repo_created - -- name: Prepare docker repos normally - include_tasks: prepare-docker-repos.yml - when: not offline_repo_created diff --git a/ansible/test/roles/prepare-docker/tasks/prepare-docker-repos.yml b/ansible/test/roles/prepare-docker/tasks/prepare-docker-repos.yml deleted file mode 100644 index 01ea72c3..00000000 --- a/ansible/test/roles/prepare-docker/tasks/prepare-docker-repos.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- name: Install Docker-CE repo - yum_repository: - name: docker-ce - description: Docker-ce YUM repo - baseurl: https://download.docker.com/linux/centos/7/x86_64/stable/ - gpgcheck: true - gpgkey: https://download.docker.com/linux/centos/gpg - -- name: Create rpm dir - file: - path: "{{ rpm_dir }}" - state: directory - -- name: Handle docker-ce packages - import_tasks: docker-packages.yml - -- name: Fake dockerd on container - import_tasks: docker-socket-override.yml - when: ansible_env.container == 'docker' diff --git a/ansible/test/roles/prepare-docker/vars/main.yml b/ansible/test/roles/prepare-docker/vars/main.yml deleted file mode 100644 index bcd7f365..00000000 --- a/ansible/test/roles/prepare-docker/vars/main.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -docker_needed_repos: - - /etc/yum.repos.d/CentOS-Base.repo.disabled - - /etc/yum.repos.d/docker-ce.repo.disabled -offline_repo_file: /etc/yum.repos.d/onap.repo -rpm_dir: /root/rpm -docker_ce_rpm: docker-ce-18.09.5-3.el7.x86_64 diff --git a/ansible/test/roles/prepare-helm/defaults/main.yml b/ansible/test/roles/prepare-helm/defaults/main.yml new file mode 100644 index 00000000..8ab9ed3a --- /dev/null +++ b/ansible/test/roles/prepare-helm/defaults/main.yml @@ -0,0 +1,3 @@ +--- +# Helm version to download. +helm_version: 2.12.3 diff --git a/ansible/test/roles/prepare-helm/tasks/main.yml b/ansible/test/roles/prepare-helm/tasks/main.yml new file mode 100644 index 00000000..aa01e281 --- /dev/null +++ b/ansible/test/roles/prepare-helm/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: "Ensure {{ app_data_path }}/downloads directory exists" + file: + path: "{{ app_data_path }}/downloads" + recurse: true + state: directory + +- name: "Download and unarchive helm-{{ helm_version }}" + unarchive: + src: "https://get.helm.sh/helm-v{{ helm_version }}-linux-amd64.tar.gz" + dest: "/tmp" + remote_src: true + +- name: "Copy helm binary" + copy: + src: /tmp/linux-amd64/helm + dest: "{{ app_data_path }}/downloads/helm" + remote_src: true diff --git a/ansible/test/roles/prepare-kubectl/defaults/main.yml b/ansible/test/roles/prepare-kubectl/defaults/main.yml new file mode 100644 index 00000000..d4e8ef94 --- /dev/null +++ b/ansible/test/roles/prepare-kubectl/defaults/main.yml @@ -0,0 +1,7 @@ +--- +# Set to false to download kubectl in preparation for kubectl role that +# needs to install it, set to true to immediately install (needed for +# cases where it is used by verification tests of other roles). +kubectl_install: false +# Kubectl version. +kubectl_version: 1.13.5 diff --git a/ansible/test/roles/prepare-kubectl/tasks/main.yml b/ansible/test/roles/prepare-kubectl/tasks/main.yml new file mode 100644 index 00000000..b5631850 --- /dev/null +++ b/ansible/test/roles/prepare-kubectl/tasks/main.yml @@ -0,0 +1,14 @@ +--- +- name: "Ensure {{ app_data_path }} exists" + file: + path: "{{ app_data_path }}/downloads" + state: directory + when: not kubectl_install + +- name: "Install kubectl-{{ kubectl_version }}" + get_url: + url: "https://storage.googleapis.com/kubernetes-release/release/v{{ kubectl_version }}/bin/linux/amd64/kubectl" + dest: "{{ '/usr/local/bin/kubectl' if kubectl_install else app_data_path+'/downloads/kubectl' }}" + # This mode conditional allows checking if kubectl role, when installing kubectl, correctly + # adds executable bit (bonus). + mode: "{{ 0755 if kubectl_install else omit }}" diff --git a/ansible/test/roles/prepare-nexus/tasks/main.yml b/ansible/test/roles/prepare-nexus/tasks/main.yml index 4ef40f5e..5eb1b7d3 100644 --- a/ansible/test/roles/prepare-nexus/tasks/main.yml +++ b/ansible/test/roles/prepare-nexus/tasks/main.yml @@ -29,12 +29,12 @@ docker_image: name: busybox tag: latest - repository: nexus3.onap.org:10001/onap/components/busybox + repository: nexus3.onap.org:10001/busybox - name: Save busybox image delegate_to: localhost docker_image: - name: nexus3.onap.org:10001/onap/components/busybox + name: nexus3.onap.org:10001/busybox tag: latest pull: false archive_path: /tmp/busybox.tar @@ -44,12 +44,12 @@ docker_image: name: aaionap/haproxy tag: 1.2.4 - repository: nexus3.onap.org:10001/onap/components/aaionap/haproxy + repository: nexus3.onap.org:10001/aaionap/haproxy - name: Save haproxy image delegate_to: localhost docker_image: - name: nexus3.onap.org:10001/onap/components/aaionap/haproxy + name: nexus3.onap.org:10001/aaionap/haproxy tag: 1.2.4 pull: false archive_path: /tmp/haproxy.tar |