Fatih Degirmenci | 50b146b | 2019-05-10 14:11:57 +0200 | [diff] [blame] | 1 | #!/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 | |
| 20 | set -o errexit |
| 21 | set -o nounset |
| 22 | set -o pipefail |
| 23 | |
Fatih Degirmenci | 0fc2cb5 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 24 | PROVISIONER_ROOT_DIR="$(dirname $(realpath ${BASH_SOURCE[0]}))" |
Fatih Degirmenci | 50b146b | 2019-05-10 14:11:57 +0200 | [diff] [blame] | 25 | export ANSIBLE_ROLES_PATH="$HOME/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:${ENGINE_PATH}/engine/playbooks/roles:${ENGINE_CACHE}/repos/bifrost/playbooks/roles" |
| 26 | export ANSIBLE_LIBRARY="$HOME/.ansible/plugins/modules:/usr/share/ansible/plugins/modules:${ENGINE_CACHE}/repos/bifrost/playbooks/library" |
| 27 | |
| 28 | # set the BAREMETAL variable |
| 29 | grep -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 |
| 32 | echo "Info: Prepare nodes, configure bifrost and create bifrost inventory" |
| 33 | echo "-------------------------------------------------------------------------" |
| 34 | cd ${ENGINE_PATH} |
| 35 | ansible-playbook ${ENGINE_ANSIBLE_PARAMS} \ |
Fatih Degirmenci | 50b146b | 2019-05-10 14:11:57 +0200 | [diff] [blame] | 36 | -e baremetal=$BAREMETAL \ |
Fatih Degirmenci | 0fc2cb5 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 37 | ${PROVISIONER_ROOT_DIR}/playbooks/main.yml |
Fatih Degirmenci | 50b146b | 2019-05-10 14:11:57 +0200 | [diff] [blame] | 38 | echo "-------------------------------------------------------------------------" |
| 39 | |
Vamsi Savaram | 6580c93 | 2019-08-06 12:42:02 +0000 | [diff] [blame] | 40 | # 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 |
| 43 | export 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 Degirmenci | 50b146b | 2019-05-10 14:11:57 +0200 | [diff] [blame] | 49 | # install bifrost and enroll & deploy nodes |
| 50 | echo "Info: Install bifrost" |
| 51 | echo "-------------------------------------------------------------------------" |
| 52 | cd ${ENGINE_CACHE}/repos/bifrost/playbooks |
| 53 | ansible-playbook ${ENGINE_ANSIBLE_PARAMS} \ |
| 54 | -i inventory/target \ |
Vamsi Savaram | 6580c93 | 2019-08-06 12:42:02 +0000 | [diff] [blame] | 55 | -e ansible_python_interpreter=${ENGINE_VENV}/bin/python \ |
Fatih Degirmenci | 50b146b | 2019-05-10 14:11:57 +0200 | [diff] [blame] | 56 | bifrost-install.yml |
| 57 | echo "-------------------------------------------------------------------------" |
| 58 | |
| 59 | echo "Info: Enroll and deploy nodes using bifrost" |
| 60 | echo "-------------------------------------------------------------------------" |
| 61 | cd ${ENGINE_CACHE}/repos/bifrost/playbooks |
| 62 | ansible-playbook ${ENGINE_ANSIBLE_PARAMS} \ |
| 63 | -i inventory/bifrost_inventory.py \ |
Vamsi Savaram | 6580c93 | 2019-08-06 12:42:02 +0000 | [diff] [blame] | 64 | -e ansible_python_interpreter=${ENGINE_VENV}/bin/python \ |
Fatih Degirmenci | 50b146b | 2019-05-10 14:11:57 +0200 | [diff] [blame] | 65 | bifrost-enroll-deploy.yml |
| 66 | echo "-------------------------------------------------------------------------" |
| 67 | |
Fatih Degirmenci | a537fd1 | 2019-06-12 16:21:11 +0200 | [diff] [blame] | 68 | echo "Info: Generate Ansible inventory" |
| 69 | echo "-------------------------------------------------------------------------" |
| 70 | cd ${ENGINE_CACHE}/repos/bifrost/playbooks |
| 71 | ansible-playbook ${ENGINE_ANSIBLE_PARAMS} \ |
Vamsi Savaram | 280675f | 2019-08-21 13:07:19 +0000 | [diff] [blame] | 72 | -i inventory/bifrost_inventory.py \ |
| 73 | --ssh-extra-args ' -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'\ |
Fatih Degirmenci | 0fc2cb5 | 2019-06-23 10:20:54 +0000 | [diff] [blame] | 74 | ${PROVISIONER_ROOT_DIR}/playbooks/generate-inventory.yml |
Fatih Degirmenci | a537fd1 | 2019-06-12 16:21:11 +0200 | [diff] [blame] | 75 | |
| 76 | echo "-------------------------------------------------------------------------" |
Fatih Degirmenci | 50b146b | 2019-05-10 14:11:57 +0200 | [diff] [blame] | 77 | echo "Info: Nodes are provisioned using bifrost!" |
| 78 | echo "-------------------------------------------------------------------------" |
| 79 | |
| 80 | # vim: set ts=2 sw=2 expandtab: |