Enable running scenario specific post deployment tasks
Scenarios might have additional tasks that need to be run
after the completion of the base scenario installation. An
example to this is ONAP based scenarios which require k8s
to be installed first and then ONAP using OOM.
This change enables this by running the tasks from post-deployment.yml
that may be located in scenario role folder. As having post deployment
tasks is optional, this file does not have to exist.
post-deployment.yml playbook must be located as below in order for this
to work
<swconfig_repo>/scenarios/<deploy_scenario>/<installer_type>/role/<deploy_scenario>/post-deployment.yml
This playbook then becomes available in engine cache as below while
bootstrapping swconfig repository
<engine_cache>/repos/swconfig/scenarios/<deploy_scenario>/<installer_type>/role/<deploy_scenario>/post-deployment.yml
Change-Id: Iebc862ec27ec742547bc80e8a9e718f39bd12ee2
diff --git a/playbooks/post-deployment.yml b/playbooks/post-deployment.yml
index 747fd66..8f2f8e0 100644
--- a/playbooks/post-deployment.yml
+++ b/playbooks/post-deployment.yml
@@ -17,12 +17,47 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
+# check if post-deployment.yml exists in engine cache on localhost
+- hosts: localhost
+ connection: local
+ gather_facts: true
+ become: yes
+ vars_files:
+ - "{{ engine_path }}/engine/var/versions.yml"
+ - "{{ engine_path }}/engine/var/global.yml"
+ - "{{ sdf_file }}"
+
+ tasks:
+ - name: Check if any post-deployment task defined for '{{ deploy_scenario }}' role
+ stat:
+ path: "{{ engine_cache }}/repos/swconfig/{{ scenario[deploy_scenario].installers[installer_type].role }}/tasks/post-deployment.yml"
+ register: post_deployment_yml
+
+# run the scenario post-deployment tasks before running the common post-deployment tasks
+- hosts: all
+ gather_facts: true
+ become: yes
+ vars_files:
+ - "{{ engine_path }}/engine/var/versions.yml"
+ - "{{ engine_path }}/engine/var/global.yml"
+ - "{{ sdf_file }}"
+
+ tasks:
+ - name: Execute post-deployment tasks of '{{ deploy_scenario }}' role
+ include_role:
+ name: "{{ engine_cache }}/repos/swconfig/{{ scenario[deploy_scenario].installers[installer_type].role }}"
+ tasks_from: post-deployment
+ when:
+ - hostvars['localhost'].post_deployment_yml.stat.exists
+
+# run common post-deployment tasks
- hosts: baremetal
remote_user: root
gather_facts: true
become: true
vars_files:
- "roles/post-deployment/vars/main.yml"
+
tasks:
- name: Install necessary utilities for CEPH
apt:
@@ -57,7 +92,6 @@
- "{{ pdf_file }}"
- "{{ idf_file }}"
-# TODO: enable the execution of scenario specific post-deployment tasks
roles:
- role: post-deployment