mirror of
https://codeberg.org/scottslowe/learning-tools.git
synced 2026-03-11 09:04:37 +00:00
Add Ruby code to determine full path to supporting files referenced in all Vagrantfiles. This will allow more effective use of Vagrant commands when not in the same directory as the Vagrantfile.
51 lines
1.8 KiB
Ruby
51 lines
1.8 KiB
Ruby
# -*- mode: ruby -*-
|
|
# vi: set ft=ruby :
|
|
|
|
# Require the OpenStack provider plugin and YAML module
|
|
require 'vagrant-openstack-provider'
|
|
require 'yaml'
|
|
|
|
# Read YAML file with OpenStack credentials
|
|
creds = YAML.load_file(File.join(File.dirname(__FILE__), 'credentials.yml'))
|
|
|
|
# Read YAML file with instance information
|
|
instances = YAML.load_file(File.join(File.dirname(__FILE__), 'instances.yml'))
|
|
|
|
# Specify Vagrant version and Vagrant API version
|
|
Vagrant.require_version '>= 1.6.0'
|
|
VAGRANTFILE_API_VERSION = '2'
|
|
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'openstack'
|
|
|
|
# Create and configure the OpenStack instance(s)
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
|
|
# No Vagrant box needed with OpenStack
|
|
# config.vm.box = "dummy"
|
|
|
|
# Specify OpenStack authentication information
|
|
config.vm.provider 'openstack' do |os|
|
|
# Edit the following line with your correct information
|
|
os.openstack_auth_url = 'http://controller:5000/v2.0'
|
|
os.username = creds['username']
|
|
os.password = creds['password']
|
|
os.tenant_name = creds['tenant']
|
|
end # config.vm.provider 'openstack'
|
|
|
|
# Specify SSH username and path to private key
|
|
config.ssh.username = instances['ssh_user']
|
|
# Edit the following line with your correct information
|
|
config.ssh.private_key_path = '~/.ssh/keypair.pem'
|
|
|
|
# Configure the OpenStack instance information
|
|
config.vm.provider 'openstack' do |os|
|
|
os.server_name = instances['name']
|
|
os.flavor = instances['flavor']
|
|
os.image = instances['image']
|
|
os.floating_ip_pool = instances['ip_pool']
|
|
os.networks = instances['networks']
|
|
os.keypair_name = instances['keypair']
|
|
# Edit the following line with your correct information
|
|
os.security_groups = ['default','basic-services']
|
|
os.sync_method = 'none'
|
|
end # config.vm.provider 'openstack'
|
|
end # Vagrant.configure
|