|
|
@ -5,45 +5,43 @@ |
|
|
|
VAGRANTFILE_API_VERSION = "2" |
|
|
|
|
|
|
|
# Customize the count of CPU cores on the VM |
|
|
|
CPUS = 2 |
|
|
|
CPUS = 4 |
|
|
|
|
|
|
|
# Customize the amount of memory on the VM |
|
|
|
MEMORY = 8192 |
|
|
|
MEMORY = ENV.fetch("VM_SIZE", "4096").to_i |
|
|
|
|
|
|
|
# Every Vagrant development environment requires a box. You can search for |
|
|
|
# boxes at https://vagrantcloud.com/search. |
|
|
|
BOX = "generic/centos7" |
|
|
|
BOX = ENV.fetch("VM_BOX", "generic/centos8") |
|
|
|
|
|
|
|
# Machine host name |
|
|
|
HOSTNAME = "tobiko" |
|
|
|
|
|
|
|
# Directory where Vagrantfile directory is copied or mounted to the VM |
|
|
|
TOBIKO_SRC_DIR = "/vagrant" |
|
|
|
# Top vagrantfile dir |
|
|
|
VAGRANTFILE_DIR = File.dirname(__FILE__) |
|
|
|
|
|
|
|
# Default prefix to OpenStack Git repositories |
|
|
|
OPENSTACK_GIT_BASE = "https://git.openstack.org" |
|
|
|
|
|
|
|
# DevStack Git repo URL and branch |
|
|
|
DEVSTACK_GIT_REPO = "#{OPENSTACK_GIT_BASE}/openstack-dev/devstack" |
|
|
|
DEVSTACK_GIT_BRANCH = "stable/train" |
|
|
|
|
|
|
|
# DevStack destination directory |
|
|
|
DEVSTACK_DEST_DIR = "/opt/stack" |
|
|
|
|
|
|
|
# DevStack source file directory |
|
|
|
DEVSTACK_SRC_DIR = "#{DEVSTACK_DEST_DIR}/devstack" |
|
|
|
# Source provision playbook |
|
|
|
PROVISION_PLAYBOOK = ENV.fetch( |
|
|
|
"PROVISION_PLAYBOOK", "#{VAGRANTFILE_DIR}/vagrant/devstack/provision.yaml") |
|
|
|
|
|
|
|
# Host IP address to be assigned to OpenStack in DevStack |
|
|
|
DEVSTACK_HOST_IP = "172.18.161.6" |
|
|
|
HOST_IP = "192.168.33.10" |
|
|
|
|
|
|
|
# local.conf file to be used for DevStack provisioning (es local.conf) |
|
|
|
DEVSTACK_CONF_FILENAME = 'local.conf' # 'ovn-local.conf' |
|
|
|
# Red Hat supscription parameters |
|
|
|
REDHAT_ACTIVATIONKEY = ENV.fetch("REDHAT_ACTIVATIONKEY", "") |
|
|
|
REDHAT_USERNAME = ENV.fetch("REDHAT_USERNAME", "") |
|
|
|
REDHAT_PASSWORD = ENV.fetch("REDHAT_PASSWORD", "") |
|
|
|
|
|
|
|
# Local directory with local projects subdirs |
|
|
|
LOCAL_PROJECT_DIR = '..' |
|
|
|
# Local directory from where look for devstack project |
|
|
|
DEVSTACK_SRC_DIR = ENV.fetch( |
|
|
|
"DEVSTACK_SRC_DIR", "#{File.dirname(VAGRANTFILE_DIR)}/devstack") |
|
|
|
|
|
|
|
# Local projects to be copied from LOCAL_PROJECT_DIR to DEVSTACK_DEST_DIR |
|
|
|
LOCAL_PROJECT_NAMES = [] # ['devstack', 'networking-ovn'] |
|
|
|
# Local directory from where looking for tobiko project files |
|
|
|
TOBIKO_SRC_DIR = ENV.fetch("TOBIKO_SRC_DIR", VAGRANTFILE_DIR) |
|
|
|
|
|
|
|
# Local directory from where looking for requirements project files |
|
|
|
REQUIREMENTS_SRC_DIR = ENV.fetch( |
|
|
|
"REQUIREMENTS_SRC_DIR", "#{File.dirname(VAGRANTFILE_DIR)}/requirements") |
|
|
|
|
|
|
|
# All Vagrant configuration is done below. The "2" in Vagrant.configure |
|
|
|
# configures the configuration version (we support older styles for |
|
|
@ -54,7 +52,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
|
|
|
# For a complete reference, please see the online documentation at |
|
|
|
# https://docs.vagrantup.com. |
|
|
|
|
|
|
|
# Every Vagrant development environment requires a box. You can search for |
|
|
|
# boxes at https://vagrantcloud.com/search. |
|
|
|
config.vm.box = BOX |
|
|
|
# config.vm.box_version = "< 3.0" |
|
|
|
config.vm.hostname = HOSTNAME |
|
|
|
|
|
|
|
# Disable automatic box update checking. If you disable this, then |
|
|
@ -75,12 +76,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
|
|
|
|
|
|
|
# Create a private network, which allows host-only access to the machine |
|
|
|
# using a specific IP. |
|
|
|
config.vm.network "private_network", ip: DEVSTACK_HOST_IP |
|
|
|
config.vm.network "private_network", ip: HOST_IP |
|
|
|
|
|
|
|
# Create a public network, which generally matched to bridged network. |
|
|
|
# Bridged networks make the machine appear as another physical device on |
|
|
|
# your network. |
|
|
|
# config.vm.network "public_network", ip: "172.18.161.6" |
|
|
|
# config.vm.network "public_network" |
|
|
|
|
|
|
|
# Share an additional folder to the guest VM. The first argument is |
|
|
|
# the path on the host to the actual folder. The second argument is |
|
|
@ -91,7 +92,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
|
|
|
# Provider-specific configuration so you can fine-tune various |
|
|
|
# backing providers for Vagrant. These expose provider-specific options. |
|
|
|
# Example for VirtualBox: |
|
|
|
|
|
|
|
# |
|
|
|
config.vm.provider "virtualbox" do |vb| |
|
|
|
# Display the VirtualBox GUI when booting the machine |
|
|
|
vb.gui = false |
|
|
@ -105,73 +106,19 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
|
|
|
libvirt.memory = MEMORY |
|
|
|
end |
|
|
|
|
|
|
|
config.vm.synced_folder ".", "/vagrant", type: "rsync", |
|
|
|
rsync__exclude: [".tox/", "tobiko.conf", ".tobiko", ".infrared"] |
|
|
|
|
|
|
|
# OS faults doesn't support other ports for SSH connection used by ansible |
|
|
|
config.vm.network "forwarded_port", guest: 22, host: 22 |
|
|
|
|
|
|
|
# View the documentation for the provider you are using for more |
|
|
|
# information on available options. |
|
|
|
|
|
|
|
# Use the same DNS server as the host machine |
|
|
|
config.vm.provision "file", source: "/etc/resolv.conf", |
|
|
|
destination: "~/resolv.conf" |
|
|
|
config.vm.provision "shell", privileged: false, |
|
|
|
inline: "sudo mv ~/resolv.conf /etc/resolv.conf" |
|
|
|
|
|
|
|
# Copy local project directories to DevStack DEST directory |
|
|
|
for project_name in LOCAL_PROJECT_NAMES do |
|
|
|
local_dir = "#{LOCAL_PROJECT_DIR}/#{project_name}" |
|
|
|
if Dir.exist?(local_dir) then |
|
|
|
target_dir = "#{DEVSTACK_DEST_DIR}/#{project_name}" |
|
|
|
config.vm.synced_folder local_dir, target_dir, type: "rsync", |
|
|
|
rsync__exclude: [".tox/"] |
|
|
|
end |
|
|
|
# Run provision playbook |
|
|
|
config.vm.provision "ansible" do |ansible| |
|
|
|
ansible.limit = 'all' |
|
|
|
ansible.playbook = PROVISION_PLAYBOOK |
|
|
|
ansible.extra_vars = ansible.extra_vars = { |
|
|
|
'redhat_activationkey' => REDHAT_ACTIVATIONKEY, |
|
|
|
'redhat_username' => REDHAT_USERNAME, |
|
|
|
'redhat_password' => REDHAT_PASSWORD, |
|
|
|
'devstack_src_dir' => DEVSTACK_SRC_DIR, |
|
|
|
'requirements_src_dir' => REQUIREMENTS_SRC_DIR, |
|
|
|
'tobiko_src_dir' => TOBIKO_SRC_DIR, |
|
|
|
} |
|
|
|
end |
|
|
|
|
|
|
|
# Enable provisioning with a shell script. Additional provisioners such as |
|
|
|
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the |
|
|
|
# documentation for more information about their specific syntax and use. |
|
|
|
config.vm.provision "shell", privileged: false, inline: <<-SHELL |
|
|
|
set -uex |
|
|
|
if ! sudo su - stack; then |
|
|
|
# setup stack user |
|
|
|
sudo useradd -s /bin/bash -d '#{DEVSTACK_DEST_DIR}' -m stack |
|
|
|
sudo chmod 755 '#{DEVSTACK_DEST_DIR}' |
|
|
|
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack |
|
|
|
fi |
|
|
|
|
|
|
|
if ! [ -d '#{DEVSTACK_DEST_DIR}/tobiko' ]; then |
|
|
|
sudo mkdir -p '#{DEVSTACK_DEST_DIR}/tobiko' |
|
|
|
sudo mount --bind /vagrant '#{DEVSTACK_DEST_DIR}/tobiko' |
|
|
|
fi |
|
|
|
|
|
|
|
# Generate provision RC file to pass variables to provision script |
|
|
|
sudo echo ' |
|
|
|
export TOBIKO_SRC_DIR=#{TOBIKO_SRC_DIR} |
|
|
|
export OPENSTACK_GIT_BASE=#{OPENSTACK_GIT_BASE} |
|
|
|
export DEVSTACK_GIT_REPO=#{DEVSTACK_GIT_REPO} |
|
|
|
export DEVSTACK_GIT_BRANCH=#{DEVSTACK_GIT_BRANCH} |
|
|
|
export DEVSTACK_SRC_DIR=#{DEVSTACK_SRC_DIR} |
|
|
|
export DEVSTACK_DEST_DIR=#{DEVSTACK_DEST_DIR} |
|
|
|
export DEVSTACK_HOST_IP=#{DEVSTACK_HOST_IP} |
|
|
|
export DEVSTACK_CONF_FILENAME=#{DEVSTACK_CONF_FILENAME} |
|
|
|
' > ./provisionrc |
|
|
|
sudo mv ./provisionrc '#{DEVSTACK_DEST_DIR}/provisionrc' |
|
|
|
|
|
|
|
# Execute provision script as stack user |
|
|
|
sudo su -l stack -c '#{TOBIKO_SRC_DIR}/devstack/vagrant/provision.bash' |
|
|
|
|
|
|
|
# Tobiko requires to write tobiko.log to devstack log directory |
|
|
|
sudo chmod 777 '#{DEVSTACK_DEST_DIR}/logs' |
|
|
|
|
|
|
|
# Tobiko requires to ssh as vagrant@localhost a vagrant user |
|
|
|
if ! [ -f ~/.ssh/id_rsa ]; then |
|
|
|
ssh-keygen -N '' -t rsa -f ~/.ssh/id_rsa |
|
|
|
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys |
|
|
|
chmod -fR go-rwx ~/.ssh |
|
|
|
fi |
|
|
|
|
|
|
|
SHELL |
|
|
|
end |
|
|
|
|