Enable post-deployment for k8s based scenarios 75/62175/3
authorFatih Degirmenci <fdegir@gmail.com>
Thu, 13 Sep 2018 05:33:48 +0000 (23:33 -0600)
committerFatih Degirmenci <fdegir@gmail.com>
Thu, 13 Sep 2018 07:15:48 +0000 (01:15 -0600)
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 <fdegir@gmail.com>
xci/installer/kubespray/deploy.sh
xci/installer/kubespray/playbooks/post-deployment.yml [new file with mode: 0644]

index bcd7dc1..98b1dcd 100755 (executable)
@@ -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 (file)
index 0000000..5c2f7f3
--- /dev/null
@@ -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