diff --git a/roles/vdm/tasks/deploy.yaml b/roles/vdm/tasks/deploy.yaml index 907e68bd..7eeb09e7 100644 --- a/roles/vdm/tasks/deploy.yaml +++ b/roles/vdm/tasks/deploy.yaml @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 --- -- name: Deploy - Apply SAS Viya deployment +- name: Deploy - Apply SAS Viya deployment - Deployment Operator kubernetes.core.k8s: src: "{{ DEPLOY_DIR }}/sasdeployment.yaml" state: present @@ -15,7 +15,7 @@ - update - cas-onboard -- name: Deploy - Apply SAS Viya deployment +- name: Deploy - Apply SAS Viya deployment - sas-orchestration when: - not V4_DEPLOYMENT_OPERATOR_ENABLED tags: @@ -23,102 +23,36 @@ - update - cas-onboard block: - - name: Deploy - Gather all resource files - find: - paths: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}" - patterns: "*.yaml" - register: manifests - - name: Deploy - Gather SAS Viya deployment resource files - find: - paths: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}" - patterns: "*.yaml" - contains: "^kind: SASDeployment" - register: deployment_manifests - failed_when: - - ( deployment_manifests.files | length ) != 1 - - name: Deploy - Apply supporting resources - kubernetes.core.k8s: - src: "{{ item.path }}" - state: present - namespace: "{{ NAMESPACE }}" - kubeconfig: "{{ KUBECONFIG }}" - with_items: - - "{{ manifests.files | difference(deployment_manifests.files) }}" - - name: Orchestration - Create orchestration tooling work directory - file: - path: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work" - state: directory - - name: Deploy - Deploy SAS Viya + - name: Deploy - Deploy SAS Viya - sas-orchestration - Docker environment: PATH: "{{ ORCHESTRATION_TOOLING_PATH + ':' + env_path }}" KUBECONFIG: "{{ KUBECONFIG }}" - WORK_DIRECTORY: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work" + EXPERIMENTAL_FEATURE_DEPLOY_MANIFEST: "true" command: | - orchestration deploy + orchestration deploy manifest --namespace "{{ NAMESPACE }}" - --sas-deployment-cr "{{ item.path }}" + --manifest "{{ DEPLOY_DIR }}/site.yaml" + --deployment-dir "{{ DEPLOY_DIR }}/sas-bases" args: chdir: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}" - with_items: - - "{{ deployment_manifests.files }}" when: - deployment_tooling == "docker" - - not V4_CFG_BELOW_THE_LINE - - name: Deploy BLT - Deploy SAS Viya - environment: - PATH: "{{ ORCHESTRATION_TOOLING_PATH + ':' + env_path }}" - KUBECONFIG: "{{ KUBECONFIG }}" - WORK_DIRECTORY: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work" - EXPERIMENTAL_FEATURE_LOCAL_DEPLOYMENT_ASSETS: true - command: | - orchestration deploy - --namespace "{{ NAMESPACE }}" - --user-content "{{ DEPLOY_DIR }}" - --local-deployment-assets - args: - chdir: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}" - with_items: - - "{{ deployment_manifests.files }}" - when: - - deployment_tooling == "docker" - - V4_CFG_BELOW_THE_LINE - - name: Deploy - Deploy SAS Viya - ansible.builtin.shell: > - docker run --rm - --user="{{ UID_GID }}" - --name "orchestration_{{ lookup('password', '/dev/null chars=ascii_lowercase length=8') }}" - --env KUBECONFIG="/config/kubeconfig" - --env WORK_DIRECTORY="/tmp/work" - --volume "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}:/manifests" - --volume "{{ KUBECONFIG }}:/config/kubeconfig" - "{{ V4_CFG_CR_HOST }}/{{ ORCHESTRATION_IMAGE }}" - deploy - --namespace {{ NAMESPACE }} - --sas-deployment-cr {{ item.path | replace(ORCHESTRATION_TOOLING_DIRECTORY, '/') }} - with_items: - - "{{ deployment_manifests.files }}" - when: - - deployment_tooling == "ansible" - - not V4_CFG_BELOW_THE_LINE - - name: Deploy BLT - Deploy SAS Viya + - name: Deploy - Deploy SAS Viya - sas-orchestration - Ansible ansible.builtin.shell: > docker run --rm --user="{{ UID_GID }}" --name "orchestration_{{ lookup('password', '/dev/null chars=ascii_lowercase length=8') }}" --env KUBECONFIG="/config/kubeconfig" - --env WORK_DIRECTORY="/tmp/work" - --env EXPERIMENTAL_FEATURE_LOCAL_DEPLOYMENT_ASSETS=true - --volume "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}:/manifests" + --env EXPERIMENTAL_FEATURE_DEPLOY_MANIFEST=true --volume "{{ KUBECONFIG }}:/config/kubeconfig" - --volume "{{ DEPLOY_DIR }}:/src" + --volume "{{ DEPLOY_DIR }}:/deploy_dir" "{{ V4_CFG_CR_HOST }}/{{ ORCHESTRATION_IMAGE }}" - deploy + deploy manifest --namespace {{ NAMESPACE }} - --user-content /src - --local-deployment-assets + --manifest /deploy_dir/site.yaml + --deployment-dir /deploy_dir/sas-bases when: - deployment_tooling == "ansible" - - V4_CFG_BELOW_THE_LINE - name: Deploy - Uninstall postgresclusters environment: @@ -133,14 +67,27 @@ - uninstall - name: Deploy - Remove Viya - kubernetes.core.k8s: - state: absent - src: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}" - wait: true - wait_timeout: 600 - namespace: "{{ NAMESPACE }}" - kubeconfig: "{{ KUBECONFIG }}" - ignore_errors: true + block: + - name: Deploy - Remove Viya - Deployment Operator + kubernetes.core.k8s: + state: absent + src: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}" + wait: true + wait_timeout: 600 + namespace: "{{ NAMESPACE }}" + kubeconfig: "{{ KUBECONFIG }}" + ignore_errors: true + when: + - V4_DEPLOYMENT_OPERATOR_ENABLED + - name: Deploy - Remove Viya - sas-orchestration + kubernetes.core.k8s: + state: absent + src: "{{ DEPLOY_DIR }}/site.yaml" + namespace: "{{ NAMESPACE }}" + kubeconfig: "{{ KUBECONFIG }}" + ignore_errors: true + when: + - not V4_DEPLOYMENT_OPERATOR_ENABLED tags: - uninstall diff --git a/roles/vdm/tasks/main.yaml b/roles/vdm/tasks/main.yaml index b3fcb44f..c3ef8e9e 100644 --- a/roles/vdm/tasks/main.yaml +++ b/roles/vdm/tasks/main.yaml @@ -238,6 +238,19 @@ - name: Include SASDeployment Custom Resource include_tasks: sasdeployment_custom_resource.yaml + when: + - V4_DEPLOYMENT_OPERATOR_ENABLED + tags: + - install + - uninstall + - update + - multi-tenancy + +# Only applicable for sas-orchestration based deployments +- name: Include SAS Viya Kubernetes Manifest + include_tasks: sas_viya_kubernetes_manifest.yaml + when: + - not V4_DEPLOYMENT_OPERATOR_ENABLED tags: - install - uninstall diff --git a/roles/vdm/tasks/sas_viya_kubernetes_manifest.yaml b/roles/vdm/tasks/sas_viya_kubernetes_manifest.yaml new file mode 100644 index 00000000..08c25760 --- /dev/null +++ b/roles/vdm/tasks/sas_viya_kubernetes_manifest.yaml @@ -0,0 +1,59 @@ +# Copyright © 2020-2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +# The site.yaml SAS Viya Kubernetes manifest will only be generated if you set +# the V4_DEPLOYMENT_OPERATOR_ENABLED flag to false so that the sas-orchestration deploy command +# is being used to orchestrate the deployment. +--- + +- name: sasdeployment custom resource - Create SAS Viya namespace + kubernetes.core.k8s: + api_version: v1 + kind: Namespace + name: "{{ NAMESPACE }}" + wait: true + kubeconfig: "{{ KUBECONFIG }}" + tags: + - install + - update + +- name: SAS Viya Kubernetes Manifest - clean up site.yaml + file: + state: absent + path: "{{ DEPLOY_DIR }}/site.yaml" + tags: + - install + - uninstall + - update + - cas-onboard + - offboard + +- name: SAS Viya Kubernetes Manifest - generate site.yaml + block: + - name: SAS Viya Kubernetes Manifest - generate site.yaml - Ansible + ansible.builtin.shell: > + docker run --rm + --user="{{ UID_GID }}" + --name "orchestration_{{ lookup('password', '/dev/null chars=ascii_lowercase length=8') }}" + --volume "{{ DEPLOY_DIR }}:/data" + --entrypoint kustomize + "{{ V4_CFG_CR_HOST }}/{{ ORCHESTRATION_IMAGE }}" + build /data/ -o /data/site.yaml + when: + - deployment_tooling == "ansible" + - name: SAS Viya Kubernetes Manifest - generate site.yaml - Docker + environment: + PATH: "{{ ORCHESTRATION_TOOLING_PATH }}" + command: + cmd: | + kustomize build {{ DEPLOY_DIR }}/ -o {{ DEPLOY_DIR }}/site.yaml + args: + chdir: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}" + when: + - deployment_tooling == "docker" + tags: + - install + - uninstall + - update + - cas-onboard + - offboard diff --git a/roles/vdm/tasks/sasdeployment_custom_resource.yaml b/roles/vdm/tasks/sasdeployment_custom_resource.yaml index b6c95aad..57093a3d 100644 --- a/roles/vdm/tasks/sasdeployment_custom_resource.yaml +++ b/roles/vdm/tasks/sasdeployment_custom_resource.yaml @@ -134,30 +134,6 @@ dest: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFEST }}" mode: "0660" -- name: sasdeployment custom resource - Write SAS Viya deployment manifests into orchestration tooling directory # noqa: name[casing] - when: - - not V4_DEPLOYMENT_OPERATOR_ENABLED - tags: - - install - - update - - cas-onboard - - offboard - block: - - name: sasdeployment custom resource - Create manifests directory in orchestration tooling directory # noqa: name[casing] - file: - path: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}" - state: directory - mode: "0700" - - name: sasdeployment custom resource - Split SAS Viya deployment manifest into orchestration directory # noqa: name[casing] - command: - chdir: "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFESTS_DIRECTORY }}" - cmd: | - csplit "{{ ORCHESTRATION_TOOLING_INSTALL_MANIFEST }}" - --prefix='{{ NAMESPACE }}-sasdeployment.' - --suffix-format='%03d.yaml' - --elide-empty-files - '/^----*$/' '{*}' - - name: sasdeployment custom resource - Create SAS Viya namespace # noqa: name[casing] kubernetes.core.k8s: api_version: v1 @@ -241,50 +217,3 @@ content: "{{ sasdeployment.stdout }}" dest: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}" mode: "0660" - -- name: sasdeployment custom resource - Create SAS Viya uninstall manifest - Docker # noqa: name[casing] - when: - - not V4_DEPLOYMENT_OPERATOR_ENABLED - - deployment_tooling == "docker" - tags: - - uninstall - block: - - name: sasdeployment custom resource - Generate SAS Viya uninstall manifest # noqa: name[casing] - environment: - PATH: "{{ ORCHESTRATION_TOOLING_PATH }}" - WORK_DIRECTORY: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work" - command: - cmd: | - kustomize build {{ DEPLOY_DIR }} - args: - chdir: "{{ ORCHESTRATION_TOOLING_DIRECTORY }}" - register: uninstall - - name: sasdeployment custom resource - Write SAS Viya uninstall manifest # noqa: name[casing] - copy: - content: "{{ uninstall.stdout }}" - dest: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}" - mode: "0660" - -- name: sasdeployment custom resource - Create SAS Viya uninstall manifest - Ansible # noqa: name[casing] - when: - - not V4_DEPLOYMENT_OPERATOR_ENABLED - - deployment_tooling == "ansible" - tags: - - uninstall - block: - - name: sasdeployment custom resource - Generate SAS Viya uninstall manifest # noqa: name[casing] - ansible.builtin.shell: > - docker run --rm - --user="{{ UID_GID }}" - --name "orchestration_{{ lookup('password', '/dev/null chars=ascii_lowercase length=8') }}" - --volume "{{ DEPLOY_DIR }}:/data" - --volume "{{ ORCHESTRATION_TOOLING_DIRECTORY }}/work:/work" - --entrypoint kustomize - "{{ V4_CFG_CR_HOST }}/{{ ORCHESTRATION_IMAGE }}" - build /data - register: uninstall - - name: sasdeployment custom resource - Write SAS Viya uninstall manifest # noqa: name[casing] - copy: - content: "{{ uninstall.stdout }}" - dest: "{{ ORCHESTRATION_TOOLING_UNINSTALL_MANIFEST }}" - mode: "0660"