blob: 7242c54f2bc1bf45ecb5111f4c96598f0622e994 [file] [log] [blame]
Fatih Degirmenci50b146b2019-05-10 14:11:57 +02001#!/bin/bash
2# ============LICENSE_START=======================================================
3# Copyright (C) 2019 The Nordix Foundation. All rights reserved.
4# ================================================================================
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# SPDX-License-Identifier: Apache-2.0
18# ============LICENSE_END=========================================================
19
20set -o errexit
21set -o nounset
22set -o pipefail
23
Fatih Degirmenci0fc2cb52019-06-23 10:20:54 +000024PROVISIONER_ROOT_DIR="$(dirname $(realpath ${BASH_SOURCE[0]}))"
Fatih Degirmenci50b146b2019-05-10 14:11:57 +020025export ANSIBLE_ROLES_PATH="$HOME/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:${ENGINE_PATH}/engine/playbooks/roles:${ENGINE_CACHE}/repos/bifrost/playbooks/roles"
26export ANSIBLE_LIBRARY="$HOME/.ansible/plugins/modules:/usr/share/ansible/plugins/modules:${ENGINE_CACHE}/repos/bifrost/playbooks/library"
27
28# set the BAREMETAL variable
29grep -o vendor.* ${ENGINE_CACHE}/config/pdf.yml | grep -q libvirt && export BAREMETAL=false || export BAREMETAL=true
30
31# create libvirt resources if not baremetal, install and configure bifrost
32echo "Info: Prepare nodes, configure bifrost and create bifrost inventory"
33echo "-------------------------------------------------------------------------"
34cd ${ENGINE_PATH}
35ansible-playbook ${ENGINE_ANSIBLE_PARAMS} \
Fatih Degirmenci50b146b2019-05-10 14:11:57 +020036 -e baremetal=$BAREMETAL \
Fatih Degirmenci0fc2cb52019-06-23 10:20:54 +000037 ${PROVISIONER_ROOT_DIR}/playbooks/main.yml
Fatih Degirmenci50b146b2019-05-10 14:11:57 +020038echo "-------------------------------------------------------------------------"
39
Vamsi Savaram6580c932019-08-06 12:42:02 +000040# Bifrost looks at environment variable VENV to see if it needs to use
41# virtual environment.
42# See: https://docs.openstack.org/bifrost/latest/install/virtualenv.html
43export VENV=${ENGINE_VENV}
44# In bifrost inventory/target and inventory/localhost are defined as:
45# 127.0.0.1 ansible_connection=local
46# Hence ansible_python_interpreter needs to be set for localhost
47# tasks to force ansible to use python from virtual environment.
48
Fatih Degirmenci50b146b2019-05-10 14:11:57 +020049# install bifrost and enroll & deploy nodes
50echo "Info: Install bifrost"
51echo "-------------------------------------------------------------------------"
52cd ${ENGINE_CACHE}/repos/bifrost/playbooks
53ansible-playbook ${ENGINE_ANSIBLE_PARAMS} \
54 -i inventory/target \
Vamsi Savaram6580c932019-08-06 12:42:02 +000055 -e ansible_python_interpreter=${ENGINE_VENV}/bin/python \
Fatih Degirmenci50b146b2019-05-10 14:11:57 +020056 bifrost-install.yml
57echo "-------------------------------------------------------------------------"
58
59echo "Info: Enroll and deploy nodes using bifrost"
60echo "-------------------------------------------------------------------------"
61cd ${ENGINE_CACHE}/repos/bifrost/playbooks
62ansible-playbook ${ENGINE_ANSIBLE_PARAMS} \
63 -i inventory/bifrost_inventory.py \
Vamsi Savaram6580c932019-08-06 12:42:02 +000064 -e ansible_python_interpreter=${ENGINE_VENV}/bin/python \
Fatih Degirmenci50b146b2019-05-10 14:11:57 +020065 bifrost-enroll-deploy.yml
66echo "-------------------------------------------------------------------------"
67
Fatih Degirmencia537fd12019-06-12 16:21:11 +020068echo "Info: Generate Ansible inventory"
69echo "-------------------------------------------------------------------------"
70cd ${ENGINE_CACHE}/repos/bifrost/playbooks
71ansible-playbook ${ENGINE_ANSIBLE_PARAMS} \
Vamsi Savaram280675f2019-08-21 13:07:19 +000072 -i inventory/bifrost_inventory.py \
73 --ssh-extra-args ' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'\
Fatih Degirmenci0fc2cb52019-06-23 10:20:54 +000074 ${PROVISIONER_ROOT_DIR}/playbooks/generate-inventory.yml
Fatih Degirmencia537fd12019-06-12 16:21:11 +020075
76echo "-------------------------------------------------------------------------"
Fatih Degirmenci50b146b2019-05-10 14:11:57 +020077echo "Info: Nodes are provisioned using bifrost!"
78echo "-------------------------------------------------------------------------"
79
80# vim: set ts=2 sw=2 expandtab: