summaryrefslogtreecommitdiffstats
path: root/xci/infra/bifrost/infra-provision.sh
blob: e60e9de0e57322246923680e98f0584156a2e565 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2018 SUSE LINUX GmbH.
# 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
##############################################################################
#-------------------------------------------------------------------------------
# Start provisioning VM nodes
#-------------------------------------------------------------------------------
# This playbook
# - removes directories that were created by the previous xci run
# - clones opnfv/releng-xci and openstack/bifrost repositories
# - combines opnfv/releng-xci and openstack/bifrost scripts/playbooks
# - destroys VMs, removes ironic db, leases, logs
# - creates and provisions VMs for the chosen flavor
#-------------------------------------------------------------------------------

BIFROST_ROOT_DIR="$(dirname $(realpath ${BASH_SOURCE[0]}))"
export ANSIBLE_ROLES_PATH="$HOME/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:${XCI_PATH}/xci/playbooks/roles:${XCI_CACHE}/repos/bifrost/playbooks/roles"
export ANSIBLE_LIBRARY="$HOME/.ansible/plugins/modules:/usr/share/ansible/plugins/modules:${XCI_CACHE}/repos/bifrost/playbooks/library"

echo "Info: Create XCI VM resources"
echo "-------------------------------------------------------------------------"

ansible-playbook ${XCI_ANSIBLE_PARAMS} \
        -i ${XCI_PATH}/xci/playbooks/dynamic_inventory.py \
        -e num_nodes=${NUM_NODES} \
        -e vm_domain_type=${VM_DOMAIN_TYPE} \
        -e baremetal_json_file=/tmp/baremetal.json \
        -e xci_distro=${XCI_DISTRO} \
        -e pdf_file=${PDF} \
        -e idf_file=${IDF} \
        ${BIFROST_ROOT_DIR}/playbooks/xci-setup-nodes.yml


ansible-playbook ${XCI_ANSIBLE_PARAMS} \
        --private-key=${XCI_PATH}/xci/scripts/vm/id_rsa_for_dib \
        --user=devuser \
        -i ${XCI_PATH}/xci/playbooks/dynamic_inventory.py \
        ${BIFROST_ROOT_DIR}/playbooks/xci-prepare-env.yml

source ${XCI_CACHE}/repos/bifrost/scripts/bifrost-env.sh

# This is hardcoded to delegate to localhost but we really need to delegate to opnfv instead.
sed -i "/delegate_to:/d" ${XCI_CACHE}/repos/bifrost/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml

ansible-playbook ${XCI_ANSIBLE_PARAMS} \
    --user=devuser \
    -i ${XCI_PATH}/xci/playbooks/dynamic_inventory.py \
    -i ${XCI_CACHE}/repos/bifrost/playbooks/inventory/bifrost_inventory.py \
    -e use_cirros=false \
    -e testing_user=root \
    -e test_vm_num_nodes=${NUM_NODES} \
    -e test_vm_cpu='host-model' \
    -e inventory_dhcp=${BIFROST_INVENTORY_DHCP} \
    -e inventory_dhcp_static_ip=false \
    -e enable_inspector=true \
    -e inspect_nodes=true \
    -e download_ipa=${BIFROST_DOWNLOAD_IPA} \
    -e create_ipa_image=${BIFROST_CREATE_IPA} \
    -e write_interfaces_file=true \
    -e ipv4_gateway=192.168.122.1 \
    -e wait_timeout=3600 \
    -e enable_keystone=false \
    -e ironicinspector_source_install=true \
    -e ironicinspector_git_branch=${BIFROST_IRONIC_INSPECTOR_VERSION:-master} \
    -e ironicinspectorclient_source_install=true \
    -e ironicinspectorclient_git_branch=${BIFROST_IRONIC_INSPECTOR_CLIENT_VERSION:-master} \
    -e ironicclient_source_install=true \
    -e ironicclient_git_branch=${BIFROST_IRONIC_CLIENT_VERSION:-master} \
    -e ironic_git_branch=${BIFROST_IRONIC_VERSION:-master} \
    -e use_prebuilt_images=${BIFROST_USE_PREBUILT_IMAGES:-false} \
    -e xci_distro=${XCI_DISTRO} \
    -e ironic_url="http://192.168.122.2:6385/" \
    ${BIFROST_ROOT_DIR}/playbooks/opnfv-virtual.yml


if [ "${BAREMETAL}" = true ]; then
  ansible-playbook ${XCI_ANSIBLE_PARAMS} \
      --user=devuser -i ${XCI_PATH}/xci/playbooks/dynamic_inventory.py \
      -i ${XCI_CACHE}/repos/bifrost/playbooks/inventory/bifrost_inventory.py \
      ${BIFROST_ROOT_DIR}/playbooks/wait-for-baremetal.yml
fi

echo "-----------------------------------------------------------------------"
echo "Info: VM nodes are provisioned!"
echo "-----------------------------------------------------------------------"