diff options
Diffstat (limited to 'ansible')
18 files changed, 161 insertions, 20 deletions
diff --git a/ansible/roles/application/.gitignore b/ansible/roles/application/.gitignore deleted file mode 100644 index 155cbb20..00000000 --- a/ansible/roles/application/.gitignore +++ /dev/null @@ -1 +0,0 @@ -application/ diff --git a/ansible/roles/application/molecule/custom_role/Dockerfile.j2 b/ansible/roles/application/molecule/custom_role/Dockerfile.j2 new file mode 120000 index 00000000..867ec5c3 --- /dev/null +++ b/ansible/roles/application/molecule/custom_role/Dockerfile.j2 @@ -0,0 +1 @@ +../default/Dockerfile.j2
\ No newline at end of file diff --git a/ansible/roles/application/molecule/custom_role/molecule.yml b/ansible/roles/application/molecule/custom_role/molecule.yml new file mode 100644 index 00000000..f9b29d92 --- /dev/null +++ b/ansible/roles/application/molecule/custom_role/molecule.yml @@ -0,0 +1,55 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: instance + image: centos:7 +provisioner: + name: ansible + env: + ANSIBLE_ROLES_PATH: ../../../../test/roles + inventory: + group_vars: + all: + app_name: moleculetestapp + app_data_path: "/opt/{{ app_name }}" + app_helm_release_name: "{{ app_name }}" + app_kubernetes_namespace: "{{ app_name }}" + app_helm_charts_install_directory: application/helm_charts + app_helm_plugins_directory: "{{ app_helm_charts_install_directory}}/helm/plugins/" + app_helm_charts_infra_directory: "{{ app_data_path }}/helm_charts" + helm_bin_dir: /usr/local/bin + app_helm_build_targets: + - all + - onap + app_helm_chart_name: "{{ app_name }}" + application_pre_install_role: application/test-patch-role + application_post_install_role: application/test-patch-role + lint: + name: ansible-lint + playbooks: + prepare: ../default/prepare.yml + converge: ../default/playbook.yml + cleanup: ../default/cleanup.yml +scenario: + name: custom_role + test_sequence: + - lint + - cleanup + - destroy + - dependency + - syntax + - create + - prepare + - converge + - verify + - cleanup + - destroy +verifier: + name: testinfra + lint: + name: flake8 diff --git a/ansible/roles/application/molecule/custom_role/tests b/ansible/roles/application/molecule/custom_role/tests new file mode 120000 index 00000000..b8ac4407 --- /dev/null +++ b/ansible/roles/application/molecule/custom_role/tests @@ -0,0 +1 @@ +../default/tests/
\ No newline at end of file diff --git a/ansible/roles/application/molecule/default/cleanup.yml b/ansible/roles/application/molecule/default/cleanup.yml new file mode 100644 index 00000000..996acaf1 --- /dev/null +++ b/ansible/roles/application/molecule/default/cleanup.yml @@ -0,0 +1,6 @@ +--- +- name: Cleanup infra + hosts: all + ignore_unreachable: true + roles: + - cleanup-application diff --git a/ansible/roles/application/molecule/default/molecule.yml b/ansible/roles/application/molecule/default/molecule.yml index 8f19d7ff..30c752e2 100644 --- a/ansible/roles/application/molecule/default/molecule.yml +++ b/ansible/roles/application/molecule/default/molecule.yml @@ -27,8 +27,6 @@ provisioner: - all - onap app_helm_chart_name: "{{ app_name }}" - application_pre_install_role: - application_post_install_role: lint: name: ansible-lint scenario: diff --git a/ansible/roles/nexus/.yamllint b/ansible/roles/nexus/.yamllint new file mode 100644 index 00000000..ad0be760 --- /dev/null +++ b/ansible/roles/nexus/.yamllint @@ -0,0 +1,11 @@ +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/nexus/defaults/main.yml b/ansible/roles/nexus/defaults/main.yml index 8f636979..194f88bf 100644 --- a/ansible/roles/nexus/defaults/main.yml +++ b/ansible/roles/nexus/defaults/main.yml @@ -6,4 +6,6 @@ populate_nexus: false # but all images are pre-populated either at buildtime or at install time (populate_nexus). runtime_images: {} # Default rule for tarball naming translation +nexus_url: "{{ nexus_url_scheme | default('https') }}://nexus.{{ hostvars[groups.infrastructure[0]].ansible_nodename }}{{ nexus_port | default('') }}" nexus3_image_tar: "{{ nexus3_image | regex_replace('(\\/|\\:)', '_') }}.tar" +nexus3_published_ports: [] diff --git a/ansible/roles/nexus/molecule/default/molecule.yml b/ansible/roles/nexus/molecule/default/molecule.yml new file mode 100644 index 00000000..63c47724 --- /dev/null +++ b/ansible/roles/nexus/molecule/default/molecule.yml @@ -0,0 +1,30 @@ +--- +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 + volumes: + - /var/lib/docker + groups: + - infrastructure +provisioner: + name: ansible + env: + ANSIBLE_ROLES_PATH: ../../../../test/roles + inventory: + links: + group_vars: ../../../../group_vars + lint: + name: ansible-lint +verifier: + name: testinfra + lint: + name: flake8 diff --git a/ansible/roles/nexus/molecule/default/playbook.yml b/ansible/roles/nexus/molecule/default/playbook.yml new file mode 100644 index 00000000..e10ea55b --- /dev/null +++ b/ansible/roles/nexus/molecule/default/playbook.yml @@ -0,0 +1,11 @@ +--- +- name: Converge + hosts: all + vars: + nexus_port: ":8081" + nexus3_published_ports: + - "{{ '8081' + nexus_port }}" + nexus_url_scheme: http + populate_nexus: true + roles: + - nexus diff --git a/ansible/roles/nexus/molecule/default/prepare.yml b/ansible/roles/nexus/molecule/default/prepare.yml new file mode 100644 index 00000000..f7290bd5 --- /dev/null +++ b/ansible/roles/nexus/molecule/default/prepare.yml @@ -0,0 +1,8 @@ +--- +- name: Prepare + hosts: all + vars_files: + - ../../defaults/main.yml + roles: + - prepare-docker-dind + - prepare-nexus diff --git a/ansible/roles/nexus/tasks/install.yml b/ansible/roles/nexus/tasks/install.yml index c88e5855..6ac2b131 100644 --- a/ansible/roles/nexus/tasks/install.yml +++ b/ansible/roles/nexus/tasks/install.yml @@ -24,6 +24,7 @@ image: "{{ nexus3_image }}" networks: - name: nexus_network + published_ports: "{{ nexus3_published_ports }}" volumes: - "{{ app_data_path }}/nexus_data:/nexus-data:rw" state: started diff --git a/ansible/roles/nexus/vars/main.yml b/ansible/roles/nexus/vars/main.yml deleted file mode 100644 index 5ec51869..00000000 --- a/ansible/roles/nexus/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -nexus_url: "https://nexus.{{ hostvars[groups.infrastructure[0]].ansible_nodename }}" 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/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/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-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 |