From 680c288b367761b2dfa241482cec715a16a99621 Mon Sep 17 00:00:00 2001 From: Mark Giles Date: Fri, 8 Jun 2018 12:53:01 -0400 Subject: [PATCH] Set up the kolla-cli and inventory for the vagrant dev environment When bootstrapping the vagrant dev environment run commands on the operator node to set up the kolla-cli, and to set up the host inventory as appropriate for either multinode or aio deployment. Change-Id: I7765d5302329919dce6317d78b84af1c7bf572b3 --- contrib/dev/vagrant/Vagrantfile | 4 +-- contrib/dev/vagrant/bootstrap.sh | 57 ++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/contrib/dev/vagrant/Vagrantfile b/contrib/dev/vagrant/Vagrantfile index 5f852acf44..1956ce0c77 100644 --- a/contrib/dev/vagrant/Vagrantfile +++ b/contrib/dev/vagrant/Vagrantfile @@ -232,7 +232,7 @@ Vagrant.configure(2) do |config| # The operator controls the deployment config.vm.define "operator", primary: true do |admin| admin.vm.hostname = "operator.local" - admin.vm.provision :shell, path: PROVISION_SCRIPT, args: "operator #{MULTINODE ? 'multinode' : 'aio'} #{kolla_path} #{kolla_ansible_path} #{kolla_cli_path}" + admin.vm.provision :shell, path: PROVISION_SCRIPT, args: "operator #{MULTINODE ? 'multinode' : 'aio'} #{kolla_path} #{kolla_ansible_path} #{kolla_cli_path} #{NUMBER_OF_COMPUTE_NODES} #{NUMBER_OF_STORAGE_NODES} #{NUMBER_OF_NETWORK_NODES} #{NUMBER_OF_CONTROL_NODES}" admin.vm.synced_folder kolla_ansible_repo_path, kolla_ansible_path, create:"True", type: get_default(:sync_method) admin.vm.synced_folder kolla_repo_path, kolla_path, create:"True", type: get_default(:sync_method) admin.vm.synced_folder kolla_cli_repo_path, kolla_cli_path, create:"True", type: get_default(:sync_method) @@ -256,7 +256,7 @@ Vagrant.configure(2) do |config| hostname = "#{node_type}0#{i}" config.vm.define hostname do |node| node.vm.hostname = "#{hostname}.local" - node.vm.provision :shell, path: PROVISION_SCRIPT, args: "#{hostname} multinode #{kolla_path} #{kolla_ansible_path} #{kolla_cli_path}" + node.vm.provision :shell, path: PROVISION_SCRIPT, args: "#{hostname} multinode #{kolla_path} #{kolla_ansible_path} #{kolla_cli_path} #{NUMBER_OF_COMPUTE_NODES} #{NUMBER_OF_STORAGE_NODES} #{NUMBER_OF_NETWORK_NODES} #{NUMBER_OF_CONTROL_NODES}" node.vm.synced_folder File.join(vagrant_dir, 'storage', node_type), "/data/host", create:"True", type: get_default(:sync_method) node.vm.synced_folder File.join(vagrant_dir, 'storage', 'shared'), "/data/shared", create:"True", type: get_default(:sync_method) node.vm.synced_folder ".", vagrant_shared_folder, disabled: true diff --git a/contrib/dev/vagrant/bootstrap.sh b/contrib/dev/vagrant/bootstrap.sh index 087b02085d..a49226318d 100644 --- a/contrib/dev/vagrant/bootstrap.sh +++ b/contrib/dev/vagrant/bootstrap.sh @@ -11,6 +11,10 @@ MODE=$2 KOLLA_PATH=$3 KOLLA_ANSIBLE_PATH=$4 KOLLA_CLI_PATH=$5 +NUMBER_OF_COMPUTE_NODES=$6 +NUMBER_OF_STORAGE_NODES=$7 +NUMBER_OF_NETWORK_NODES=$8 +NUMBER_OF_CONTROL_NODES=$9 export http_proxy= export https_proxy= @@ -151,14 +155,54 @@ function configure_kolla { # Use local docker registry sed -i -r "s,^[# ]*namespace *=.+$,namespace = ${REGISTRY}/lokolla," /etc/kolla/kolla-build.conf sed -i -r "s,^[# ]*push *=.+$,push = True," /etc/kolla/kolla-build.conf - sed -i -r "s,^[# ]*docker_registry:.+$,docker_registry: \"${REGISTRY}\"," /etc/kolla/globals.yml - sed -i -r "s,^[# ]*docker_namespace:.+$,docker_namespace: \"lokolla\"," /etc/kolla/globals.yml - sed -i -r "s,^[# ]*docker_insecure_registry:.+$,docker_insecure_registry: \"True\"," /etc/kolla/globals.yml + kolla-cli property set docker_registry ${REGISTRY} + kolla-cli property set docker_namespace lokolla + kolla-cli property set docker_insecure_registry True # Set network interfaces - sed -i -r "s,^[# ]*network_interface:.+$,network_interface: \"eth1\"," /etc/kolla/globals.yml - sed -i -r "s,^[# ]*neutron_external_interface:.+$,neutron_external_interface: \"eth2\"," /etc/kolla/globals.yml + kolla-cli property set network_interface eth1 + kolla-cli property set neutron_external_interface eth2 # Set VIP address to be on the vagrant private network - sed -i -r "s,^[# ]*kolla_internal_vip_address:.+$,kolla_internal_vip_address: \"172.28.128.254\"," /etc/kolla/globals.yml + kolla-cli property set kolla_internal_vip_address 172.28.128.254 +} + +function configure_kolla_cli { + # Run the CLI setup script + pushd ${KOLLA_CLI_PATH} + python ./cli_setup.py + popd + + # Set up the kolla-cli inventory + if [ "$MODE" == 'aio' ]; then + kolla-cli setdeploy local + kolla-cli host add localhost + for group in control deployment monitoring network storage; do + kolla-cli group addhost $group localhost + done + else + for node_num in $(seq 1 ${NUMBER_OF_COMPUTE_NODES}); do + node_name="compute0${node_num}" + kolla-cli host add $node_name + kolla-cli group addhost external-compute $node_name + done + + for node_num in $(seq 1 ${NUMBER_OF_STORAGE_NODES}); do + node_name="storage0${node_num}" + kolla-cli host add $node_name + kolla-cli group addhost storage $node_name + done + + for node_num in $(seq 1 ${NUMBER_OF_NETWORK_NODES}); do + node_name="network0${node_num}" + kolla-cli host add $node_name + kolla-cli group addhost network $node_name + done + + for node_num in $(seq 1 ${NUMBER_OF_CONTROL_NODES}); do + node_name="control0${node_num}" + kolla-cli host add $node_name + kolla-cli group addhost control $node_name + done + fi } # Configure the operator node and install some additional packages. @@ -192,6 +236,7 @@ function configure_operator { mkdir -p /usr/share/kolla chown -R vagrant: /etc/kolla /usr/share/kolla + configure_kolla_cli configure_kolla # Make sure Ansible uses scp.