diff --git a/openstack-cli/Vagrantfile b/openstack-cli/Vagrantfile index c9b45f8..d28ad97 100644 --- a/openstack-cli/Vagrantfile +++ b/openstack-cli/Vagrantfile @@ -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 \ No newline at end of file +end diff --git a/openstack-cli/adminrc b/openstack-cli/adminrc new file mode 100644 index 0000000..c4a7d27 --- /dev/null +++ b/openstack-cli/adminrc @@ -0,0 +1,6 @@ +export OS_AUTH_URL=http://:5000/v2.0/ +export OS_PROJECT_NAME= +export OS_TENANT_NAME= +export OS_USERNAME= +export OS_PASSWORD= +export OS_NO_CACHE=1 \ No newline at end of file diff --git a/openstack-cli/config.sh b/openstack-cli/config.sh new file mode 100644 index 0000000..11a77f1 --- /dev/null +++ b/openstack-cli/config.sh @@ -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 diff --git a/openstack-cli/servers.yml b/openstack-cli/servers.yml index 6b3f56e..415a323 100644 --- a/openstack-cli/servers.yml +++ b/openstack-cli/servers.yml @@ -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