X-Git-Url: https://gerrit.nordix.org/gitweb?p=infra%2Fstack%2Fkubernetes.git;a=blobdiff_plain;f=apps%2Fspinnaker%2Fkubespray%2Fplaybooks%2Froles%2Finstall%2Ftasks%2Fmain.yml;fp=apps%2Fspinnaker%2Fkubespray%2Fplaybooks%2Froles%2Finstall%2Ftasks%2Fmain.yml;h=a72222242bf8bce4160a56c1d9730acc8dbe637b;hp=0000000000000000000000000000000000000000;hb=a1e1f40e71a48d8c5315f37999b9123c7ea908ab;hpb=20d34e772e021fabdee0aa9b50e9804a80d5108a diff --git a/apps/spinnaker/kubespray/playbooks/roles/install/tasks/main.yml b/apps/spinnaker/kubespray/playbooks/roles/install/tasks/main.yml new file mode 100644 index 0000000..a722222 --- /dev/null +++ b/apps/spinnaker/kubespray/playbooks/roles/install/tasks/main.yml @@ -0,0 +1,166 @@ +--- +# ============LICENSE_START======================================================= +# Copyright (C) 2019 The Nordix Foundation. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +# +- name: Load execution mode variables + include_vars: "{{ execution_mode }}.yaml" + +- block: + - name: Create directories for helm repositories + file: + path: "{{ item.path }}" + state: "{{ item.state }}" + loop: + - {path: "{{ engine_workspace }}/offline/charts/stable", state: absent} + - {path: "{{ engine_workspace }}/offline/charts/stable", state: directory} + - {path: "{{ engine_workspace }}/offline/charts/local", state: absent} + - {path: "{{ engine_workspace }}/offline/charts/local", state: directory} + + - name: Place index.yaml to webserver stable charts repository + template: + src: "index.yaml.j2" + dest: "{{ engine_workspace }}/offline/charts/stable/index.yaml" + force: true + when: execution_mode == "offline-deployment" + +- name: Initialize Helm + command: helm init --client-only --local-repo-url {{ local_repo_url }} --stable-repo-url {{ stable_repo_url }} + register: helm_init_result + changed_when: true + +- name: Clone Helm Charts repository + git: + repo: "{{ helm_charts_git_url }}" + dest: "{{ engine_cache }}/repos/charts" + version: "{{ charts_version }}" + force: true + recursive: true + environment: + http_proxy: "{{ lookup('env','http_proxy') }}" + https_proxy: "{{ lookup('env','https_proxy') }}" + no_proxy: "{{ lookup('env','no_proxy') }}" + +- name: Generate values.yaml + template: + src: "values.yaml.j2" + dest: "{{ engine_cache }}/repos/charts/stable/spinnaker/values.yaml" + force: true + +- name: Remove previous installations of Spinnaker + command: > + helm delete --purge "{{ spinnaker_service }}" + changed_when: true + ignore_errors: true + tags: reset + +- name: Remove Spinnaker namespace + command: > + kubectl delete ns "{{ spinnaker_namespace }}" + changed_when: true + ignore_errors: true + tags: reset + +- name: Create Spinnaker namespace + k8s: + state: present + definition: + apiVersion: v1 + kind: Namespace + metadata: + name: "{{ spinnaker_namespace }}" + +- name: Verify Spinnaker Helm charts are available to be deployed + command: helm search spinnaker -l + register: helm_search + changed_when: false + +- name: Log Helm chart list to console + debug: + msg: "{{ helm_search.stdout_lines }}" + +- name: Inform user about Spinnaker deployment + debug: + msg: > + Spinnaker deployment is about to start! + This takes a while and nothing will be logged to console until the process is completed. + +- name: Fetch all helm dependencies for Spinnaker + command: > + helm dependency update + {{ engine_cache }}/repos/charts/stable/spinnaker + changed_when: true + +- name: Install Spinnaker using helm + command: > + helm install + --name "{{ spinnaker_service }}" + --namespace "{{ spinnaker_namespace }}" + --timeout 900 + {{ engine_cache }}/repos/charts/stable/spinnaker + register: spinnaker_helm_log + changed_when: true + +- name: Log Spinnaker helm output to console + debug: + msg: "{{ spinnaker_helm_log.stdout_lines }}" + +# wait 10 minutes for all containers to be started +- name: Wait for all containers to be started + shell: | + set -o pipefail + kubectl get po -n spinnaker | grep ContainerCreating | wc -l + register: kube + changed_when: + kube.stdout == '0' + until: + kube.stdout == '0' + retries: 60 + delay: 10 + +# wait 20 minutes for all containers to be initialized +- block: + - name: Wait for all containers to be initialized + shell: | + set -o pipefail + kubectl get po -n spinnaker | grep Init | grep -v Error | wc -l + register: kube + changed_when: + kube.stdout == '0' + until: + kube.stdout == '0' + retries: 120 + delay: 10 + always: + - name: Get POD status + command: kubectl get po -n spinnaker + changed_when: false + register: kube + + - name: Log POD status to console + debug: + msg: "{{ kube.stdout_lines }}" + + - name: Get summary of Spinnaker deployment + script: log-spinnaker-status.sh + register: spinnaker_status + + - name: Log Spinnaker status to console + debug: + msg: "{{ spinnaker_status.stdout_lines }}" + +# vim: set ts=2 sw=2 expandtab: