From e7ded150b54460b9e55e5f0ea1da0a2942b23b5f Mon Sep 17 00:00:00 2001 From: Fatih Degirmenci Date: Wed, 12 Sep 2018 23:33:48 -0600 Subject: Enable post-deployment for k8s based scenarios k8-calico-onap scenario will have post deployment tasks to install ONAP using OOM so post-deployment tasks are required to do that. deploy-scenario:k8-calico-nofeature installer-type:kubespray Change-Id: I67c8188cb573f6fc5c80e15a9101cacca1b7b10e Signed-off-by: Fatih Degirmenci --- xci/installer/kubespray/deploy.sh | 19 ++++++++-- .../kubespray/playbooks/post-deployment.yml | 42 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 xci/installer/kubespray/playbooks/post-deployment.yml diff --git a/xci/installer/kubespray/deploy.sh b/xci/installer/kubespray/deploy.sh index bcd7dc1d..98b1dcdb 100755 --- a/xci/installer/kubespray/deploy.sh +++ b/xci/installer/kubespray/deploy.sh @@ -92,15 +92,30 @@ ssh root@$OPNFV_HOST_IP "mkdir -p ~/.kube/;\ cp -f ~/admin.conf ~/.kube/config; \ cp -f ~/kubectl /usr/local/bin || true" +#------------------------------------------------------------------------------- +# Execute post-installation tasks +#------------------------------------------------------------------------------- +# Playbook post.yml is used in order to execute any post-deployment tasks that +# are required for the scenario under test. +#------------------------------------------------------------------------------- +echo "-----------------------------------------------------------------------" +echo "Info: Running post-deployment scenario role" +echo "-----------------------------------------------------------------------" +cd $K8_XCI_PLAYBOOKS +ansible-playbook ${XCI_ANSIBLE_PARAMS} -i ${XCI_PLAYBOOKS}/dynamic_inventory.py \ + post-deployment.yml +echo "-----------------------------------------------------------------------" +echo "Info: Post-deployment scenario role execution done" +echo "-----------------------------------------------------------------------" +echo echo "Login opnfv host ssh root@$OPNFV_HOST_IP according to the user-guide to create a service https://kubernetes.io/docs/user-guide/walkthrough/k8s201/" - echo echo "-----------------------------------------------------------------------" echo "Info: Kubernetes login details" echo "-----------------------------------------------------------------------" - +echo # Get the dashborad URL DASHBOARD_SERVICE=$(ssh root@$OPNFV_HOST_IP "kubectl get service -n kube-system |grep kubernetes-dashboard") DASHBOARD_PORT=$(echo ${DASHBOARD_SERVICE} | awk '{print $5}' |awk -F "[:/]" '{print $2}') diff --git a/xci/installer/kubespray/playbooks/post-deployment.yml b/xci/installer/kubespray/playbooks/post-deployment.yml new file mode 100644 index 00000000..5c2f7f36 --- /dev/null +++ b/xci/installer/kubespray/playbooks/post-deployment.yml @@ -0,0 +1,42 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2018 Ericsson AB and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +- hosts: opnfv + remote_user: root + vars_files: + - "{{ xci_path }}/xci/var/opnfv.yml" + + pre_tasks: + - name: Load distribution variables + include_vars: + file: "{{ item }}" + with_items: + - "{{ xci_path }}/xci/var/{{ ansible_os_family }}.yml" + - name: Set facts for remote deployment + set_fact: + remote_xci_scenario_path: "{{ ansible_env.HOME }}/releng-xci/.cache/repos/scenarios/{{ deploy_scenario }}/scenarios/{{ deploy_scenario }}" + + tasks: + - name: Reload XCI deployment host facts + setup: + filter: ansible_local + gather_subset: "!all" + delegate_to: 127.0.0.1 + + - name: Check if any post-deployment task defined for {{ deploy_scenario }} role + stat: + path: "{{ remote_xci_scenario_path }}/role/{{ deploy_scenario }}/tasks/post-deployment.yml" + register: post_deployment_yml + + - name: Execute post-deployment tasks of {{ deploy_scenario }} role + include_role: + name: "{{ hostvars['opnfv'].ansible_local.xci.scenarios.role }}" + tasks_from: post-deployment + when: + - post_deployment_yml.stat.exists -- cgit 1.2.3-korg