Add final versions of support files

Add final versions of Vagrantfile, configuration script, file with
credentials, and YAML file with VM details.
This commit is contained in:
Scott Lowe 2015-03-10 21:48:35 -06:00
parent b8dfe57e38
commit fddec44007
4 changed files with 28 additions and 57 deletions

View file

@ -5,16 +5,10 @@
Vagrant.require_version ">= 1.6.0"
VAGRANTFILE_API_VERSION = "2"
# Require 'yaml' and 'fileutils' modules
# Require 'yaml' module
require 'yaml'
require 'fileutils'
# Look for user-data file to configure/customize CoreOS boxes
# No changes should need to be made to this file
USER_DATA = File.join(File.dirname(__FILE__), "user-data")
# Read YAML file with VM details (box, CPU, RAM, IP addresses)
# Be sure to edit servers.yml to provide correct IP addresses
# Read YAML file with VM details (box, CPU, and RAM)
servers = YAML.load_file('servers.yml')
# Create and configure the VMs
@ -26,31 +20,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Iterate through entries in YAML file to create VMs
servers.each do |servers|
config.vm.define servers["name"] do |srv|
# Don't check for box updates
srv.vm.box_check_update = false
srv.vm.hostname = servers["name"]
srv.vm.box = servers["box"]
# Assign an additional static private network
srv.vm.network "private_network", ip: servers["priv_ip"]
# Configure VMs based on CoreOS box
if srv.vm.box == "coreos-stable"
# Disable default synced folder for CoreOS VMs
srv.vm.synced_folder ".", "/vagrant", disabled: true
# Copy user_data file into CoreOS VM
srv.vm.provision "file", source: "#{USER_DATA}", destination: "/tmp/vagrantfile-user-data"
# Move user_data to correct location to be processed by cloud-init
srv.vm.provision "shell", inline: "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", privileged: true
end
# Configure VMs based on Ubuntu box
if srv.vm.box == "slowe/ubuntu-trusty-x64"
# Enable default synced folder
srv.vm.synced_folder ".", "/vagrant"
# Copy files into the VM
srv.vm.provision "file", source: "server.json", destination: "/home/vagrant/config.json"
srv.vm.provision "file", source: "consul.conf", destination: "/home/vagrant/consul.conf"
# Run final provisioning script
srv.vm.provision "shell", path: "consul.sh"
end
# Enable default synced folder
srv.vm.synced_folder ".", "/vagrant"
# Perform final provisioning activities
srv.vm.provision "shell", path: "config.sh", privileged: true
srv.vm.provision "file", source: "adminrc", destination: "/home/vagrant/adminrc"
# Configure VMs with RAM and CPUs per settings in servers.yml
srv.vm.provider :vmware_fusion do |vmw|
vmw.vmx["memsize"] = servers["ram"]
@ -58,4 +39,4 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
end
end
end
end

6
openstack-cli/adminrc Normal file
View file

@ -0,0 +1,6 @@
export OS_AUTH_URL=http://<IP ADDRESS>:5000/v2.0/
export OS_PROJECT_NAME=<PROJECT>
export OS_TENANT_NAME=<PROJECT>
export OS_USERNAME=<USERNAME>
export OS_PASSWORD=<PASSWORD>
export OS_NO_CACHE=1

10
openstack-cli/config.sh Normal file
View file

@ -0,0 +1,10 @@
#!/bin/bash
# Update package lists
sudo apt-get update
# Install necessary packages
sudo apt-get -y install python-pip python-dev
# Install OpenStack Client (OSC)
sudo pip install python-openstackclient

View file

@ -1,31 +1,5 @@
---
- name: consul-01
- name: openstack-cli
box: slowe/ubuntu-trusty-x64
ram: 512
vcpu: 1
priv_ip: 192.168.1.101
- name: consul-02
box: slowe/ubuntu-trusty-x64
ram: 512
vcpu: 1
priv_ip: 192.168.1.102
- name: consul-03
box: slowe/ubuntu-trusty-x64
ram: 512
vcpu: 1
priv_ip: 192.168.1.103
- name: coreos-01
box: coreos-stable
ram: 512
vcpu: 1
priv_ip: 192.168.1.104
- name: coreos-02
box: coreos-stable
ram: 512
vcpu: 1
priv_ip: 192.168.1.105
- name: coreos-03
box: coreos-stable
ram: 512
vcpu: 1
priv_ip: 192.168.1.106