diff --git a/etcd-2.0/README.md b/etcd-2.0/README.md index 3a1ba5e..e00a057 100644 --- a/etcd-2.0/README.md +++ b/etcd-2.0/README.md @@ -18,15 +18,15 @@ These files were created to allow users to use Vagrant ([http://www.vagrantup.co ## Instructions -These instructions assume you've already installed VMware Fusion, Vagrant, and the Vagrant VMware plugin. Please refer to the documentation for those products for more information on installation or configuration. +These instructions assume you've already installed your back-end virtualization provider (VMware Fusion or VirtualBox), Vagrant, and any necessary plugins (such as the Vagrant VMware plugin). Please refer to the documentation for those products for more information on installation or configuration. -1. Use `vagrant box add` to install an Ubuntu 14.04 x64 box for the "vmware_fusion" provider. (In theory you should be able to use this Vagrant environment with VMware Workstation as well, but only VMware Fusion was tested.) I have a base box you can use for this purpose; to use my Ubuntu 14.04 x64 base box, add the box with `vagrant box add slowe/ubuntu-trusty-x64`. +1. Use `vagrant box add` to install an Ubuntu 14.04 x64 base box. For a VirtualBox-formatted box, use "ubuntu/trusty64". For a VMware-formatted box, the "bento/ubuntu-14.04" is a good option. (In theory you should be able to use this Vagrant environment with VMware Workstation as well, but only VMware Fusion was tested.) 2. Place the files from the `etcd-2.0` directory of this GitHub repository (the "lowescott/learning-tools" repository) into a directory on your system. You can clone the entire "learning-tools" repository (using `git clone`), or just download the specific files from the `etcd-2.0` directory. -3. Edit `servers.yml` to ensure that the box specified in that file matches the Ubuntu 14.04 x64 base box you just installed and will be using. _I recommend that you do not change any other values in this file unless you know it is necessary._ +3. Edit `machines.yml` to ensure that the box specified in that file matches the Ubuntu 14.04 x64 base box you just installed and will be using. _I recommend that you do not change any other values in this file unless you know it is necessary._ -4. From a terminal window, change into the directory where the files from this directory are stored and run `vagrant up` to bring up the VMs specified in `servers.yml` and `Vagrantfile`. +4. From a terminal window, change into the directory where the files from this directory are stored and run `vagrant up` to bring up the VMs specified in `machines.yml` and `Vagrantfile`. 5. Once Vagrant has finished creating, booting, and provisioning each of the VMs and starting etcd, log into the first system ("etcd-01" by default) using `vagrant ssh etcd-01`. diff --git a/etcd-2.0/Vagrantfile b/etcd-2.0/Vagrantfile index bf39e5f..eea9731 100644 --- a/etcd-2.0/Vagrantfile +++ b/etcd-2.0/Vagrantfile @@ -1,34 +1,29 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# Specify Vagrant version, Vagrant API version, and Vagrant clone location -Vagrant.require_version ">= 1.6.0" -VAGRANTFILE_API_VERSION = "2" -ENV['VAGRANT_VMWARE_CLONE_DIRECTORY'] = '~/.vagrant' -ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_fusion' -#ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' +# Specify minimum Vagrant version and Vagrant API version +Vagrant.require_version '>= 1.6.0' +VAGRANTFILE_API_VERSION = '2' -# Require 'yaml' module +# Require 'yaml' and 'erb' modules require 'yaml' +require 'erb' # Read YAML file with VM details (box, CPU, RAM, IP addresses) -# Be sure to edit servers.yml to provide correct IP addresses -servers = YAML.load_file(File.join(File.dirname(__FILE__), 'servers.yml')) - -# Require 'erb' module -require 'erb' +# Be sure to edit machines.yml to provide correct IP addresses +machines = YAML.load_file(File.join(File.dirname(__FILE__), 'machines.yml')) # Use config from YAML file to write out templates for etcd overrides template = File.join(File.dirname(__FILE__), 'etcd.defaults.erb') content = ERB.new File.new(template).read etcd_initial_cluster = [] -servers.each do |servers| - etcd_initial_cluster << "#{servers['name']}=http://#{servers['priv_ip']}:2380" +machines.each do |machine| + etcd_initial_cluster << "#{machine['name']}=http://#{machine['priv_ip']}:2380" end -servers.each do |servers| - ip = servers['priv_ip'] - target = File.join(File.dirname(__FILE__), "#{servers['name']}.defaults") +machines.each do |machine| + ip = machine['priv_ip'] + target = File.join(File.dirname(__FILE__), "#{machine['name']}.defaults") File.open(target, 'w') { |f| f.write(content.result(binding)) } end @@ -39,35 +34,44 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.ssh.insert_key = false # Iterate through entries in YAML file to create VMs - servers.each do |servers| - config.vm.define servers["name"] do |srv| + machines.each do |machine| + config.vm.define machine['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"] + + # Set the hostname of the VM + srv.vm.hostname = machine['name'] + + # Specify the box to use (use VMware box by default) + srv.vm.box = machine['box']['vmw'] # Assign an additional static private network - srv.vm.network "private_network", ip: servers["priv_ip"] + srv.vm.network 'private_network', ip: machine['priv_ip'] # Specify default synced folder; requires VMware Tools # Note shared folders are REQUIRED for the shell provisioning to work - srv.vm.synced_folder ".", "/vagrant" + srv.vm.synced_folder '.', '/vagrant', disabled: true # Provision etcd to the VMs - srv.vm.provision "shell", path: "provision.sh", privileged: true + srv.vm.provision 'file', source: 'etcd.conf', + destination: '/home/vagrant/etcd.conf' + srv.vm.provision 'file', source: "#{machine['name']}.defaults", + destination: '/home/vagrant/etcd.defaults' + srv.vm.provision 'shell', path: 'provision.sh', privileged: true - # Configure VMs with RAM and CPUs per settings in servers.yml (Fusion) - srv.vm.provider :vmware_fusion do |vmw| - vmw.vmx["memsize"] = servers["ram"] - vmw.vmx["numvcpus"] = servers["vcpu"] - end # srv.vm.provider vmware_fusion + # Configure VMs with RAM and CPUs per settings in machines.yml (Fusion) + srv.vm.provider 'vmware_fusion' do |vmw| + vmw.vmx['memsize'] = machine['ram'] + vmw.vmx['numvcpus'] = machine['vcpu'] + end # srv.vm.provider 'vmware_fusion' - # Configure VMs with RAM and CPUs per settings in servers.yml (VirtualBox) - srv.vm.provider :virtualbox do |vb| - vb.memory = servers["ram"] - vb.cpus = servers["vcpu"] - end # srv.vm.provider virtualbox + # Configure VMs with RAM and CPUs per settings in machines.yml (VirtualBox) + srv.vm.provider 'virtualbox' do |vb, override| + vb.memory = machine['ram'] + vb.cpus = machine['vcpu'] + override.vm.box = machine['box']['vb'] + end # srv.vm.provider 'virtualbox' end # config.vm.define - end # servers.each + end # machines.each end # Vagrant.configure diff --git a/etcd-2.0/etcd.defaults.erb b/etcd-2.0/etcd.defaults.erb index 6cc2f89..ad0a369 100644 --- a/etcd-2.0/etcd.defaults.erb +++ b/etcd-2.0/etcd.defaults.erb @@ -4,9 +4,9 @@ export ETCD_INITIAL_CLUSTER="<%= etcd_initial_cluster.join(',') %>" export ETCD_INITIAL_CLUSTER_STATE="new" export ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01" -export ETCD_INITIAL_ADVERTISE_PEER_URLS="http://<%= servers['priv_ip'] %>:2380" +export ETCD_INITIAL_ADVERTISE_PEER_URLS="http://<%= machine['priv_ip'] %>:2380" export ETCD_DATA_DIR="/var/etcd" -export ETCD_LISTEN_PEER_URLS="http://<%= servers['priv_ip'] %>:2380" -export ETCD_LISTEN_CLIENT_URLS="http://<%= servers['priv_ip'] %>:2379,http://0.0.0.0:4001" -export ETCD_ADVERTISE_CLIENT_URLS="http://<%= servers['priv_ip'] %>:2379" -export ETCD_NAME="<%= servers['name'] %>" +export ETCD_LISTEN_PEER_URLS="http://<%= machine['priv_ip'] %>:2380" +export ETCD_LISTEN_CLIENT_URLS="http://<%= machine['priv_ip'] %>:2379,http://0.0.0.0:4001" +export ETCD_ADVERTISE_CLIENT_URLS="http://<%= machine['priv_ip'] %>:2379" +export ETCD_NAME="<%= machine['name'] %>" diff --git a/etcd-2.0/machines.yml b/etcd-2.0/machines.yml new file mode 100644 index 0000000..7964390 --- /dev/null +++ b/etcd-2.0/machines.yml @@ -0,0 +1,22 @@ +--- +- box: + vmw: "bento/ubuntu-14.04" + vb: "ubuntu/trusty64" + name: "etcd-01" + priv_ip: "192.168.101.101" + ram: "512" + vcpu: "1" +- box: + vmw: "bento/ubuntu-14.04" + vb: "ubuntu/trusty64" + name: "etcd-02" + priv_ip: "192.168.101.102" + ram: "512" + vcpu: "1" +- box: + vmw: "bento/ubuntu-14.04" + vb: "ubuntu/trusty64" + name: "etcd-03" + priv_ip: "192.168.101.103" + ram: "512" + vcpu: "1" diff --git a/etcd-2.0/provision.sh b/etcd-2.0/provision.sh index e0182bb..7997546 100644 --- a/etcd-2.0/provision.sh +++ b/etcd-2.0/provision.sh @@ -28,8 +28,8 @@ if [[ ! -e /usr/local/bin/etcd ]]; then fi # Copy files into the correct locations; requires shared folders -sudo cp /vagrant/etcd.conf /etc/init/etcd.conf -sudo cp /vagrant/$HOSTNAME.defaults /etc/default/etcd +sudo cp /home/vagrant/etcd.conf /etc/init/etcd.conf +sudo cp /home/vagrant/etcd.defaults /etc/default/etcd # restart if already running, otherwise start. initctl status etcd && initctl restart etcd || initctl start etcd diff --git a/etcd-2.0/servers.yml b/etcd-2.0/servers.yml deleted file mode 100644 index 26b89e6..0000000 --- a/etcd-2.0/servers.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: etcd-01 - box: slowe/ubuntu-trusty-x64 - ram: 512 - vcpu: 1 - priv_ip: 192.168.101.101 -- name: etcd-02 - box: slowe/ubuntu-trusty-x64 - ram: 512 - vcpu: 1 - priv_ip: 192.168.101.102 -- name: etcd-03 - box: slowe/ubuntu-trusty-x64 - ram: 512 - vcpu: 1 - priv_ip: 192.168.101.103 diff --git a/ipvs-docker/README.md b/ipvs-docker/README.md index 41fa329..8bf67be 100644 --- a/ipvs-docker/README.md +++ b/ipvs-docker/README.md @@ -13,9 +13,9 @@ These files were created to allow users to use Vagrant ([http://www.vagrantup.co ## Instructions -These instructions assume you've already installed VMware Fusion, Vagrant, and the Vagrant VMware plugin. Please refer to the documentation for those products for more information on installation or configuration. Note that Internet access is required when using `vagrant up` to create this environment. +These instructions assume you've already installed your back-end virtualization provider, Vagrant, and any necessary plugins (such as the Vagrant VMware plugin). Please refer to the documentation for those products for more information on installation or configuration. Note that Internet access is required when using `vagrant up` to create this environment. -1. Use `vagrant box add` to install an Ubuntu 14.04 x86_64 Vagrant box. I have a base box you can use for this purpose; to use my Ubuntu 14.04 x64 base box, add the box with `vagrant box add slowe/ubuntu-trusty-x64`. +1. Use `vagrant box add` to install an Ubuntu 14.04 x86_64 Vagrant box. The "bento/ubuntu-14.04" box is a good option for a VMware-formatted box. The "ubuntu/trusty64" box is a good option for a VirtualBox-formatted box. 2. Place the files from the `ipvs-docker` directory of this GitHub repository into a directory on your local system. You can clone the entire "learning-tools" repository (using `git clone`) or just download the specific files from the the `ipvs-docker` folder. diff --git a/ipvs-docker/Vagrantfile b/ipvs-docker/Vagrantfile index e0e1ccf..efa1e46 100644 --- a/ipvs-docker/Vagrantfile +++ b/ipvs-docker/Vagrantfile @@ -1,7 +1,7 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# Specify Vagrant version, Vagrant API version, and desired clone location +# Specify minimum Vagrant version and Vagrant API version Vagrant.require_version '>= 1.6.0' VAGRANTFILE_API_VERSION = '2' @@ -9,6 +9,7 @@ VAGRANTFILE_API_VERSION = '2' require 'yaml' # Read YAML file with VM details (box, CPU, RAM, IP addresses) +# Edit machines.yml to change machine details machines = YAML.load_file(File.join(File.dirname(__FILE__), 'machines.yml')) # Create and configure the VMs @@ -23,10 +24,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Don't check for box updates srv.vm.box_check_update = false + + # Set the VM's hostname srv.vm.hostname = machine['name'] # Use VMware box by default (override later for VirtualBox) - srv.vm.box = machine['vmw_box'] + srv.vm.box = machine['box']['vmw'] # Configure default synced folder (disable by default) if machine['sync_disabled'] != nil @@ -35,26 +38,30 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| srv.vm.synced_folder '.', '/vagrant', disabled: true end #if machine['sync_disabled'] - # Assign additional private network - if machine['ip_addr'] != nil - srv.vm.network 'private_network', ip: machine['ip_addr'] - end # if machine['ip_addr'] + # Iterate through networks as per settings in machines.yml + machine['nics'].each do |net| + if net['ip_addr'] == 'dhcp' + srv.vm.network net['type'], type: net['ip_addr'] + else + srv.vm.network net['type'], ip: net['ip_addr'] + end # if net['ip_addr'] + end # machine['nics'].each # Configure CPU & RAM per settings in machines.yml (Fusion) - srv.vm.provider :vmware_fusion do |vmw| + srv.vm.provider 'vmware_fusion' do |vmw| vmw.vmx['memsize'] = machine['ram'] vmw.vmx['numvcpus'] = machine['vcpu'] if machine['nested'] == true vmw.vmx['vhv.enable'] = 'TRUE' end #if machine['nested'] - end # srv.vm.provider vmware_fusion + end # srv.vm.provider 'vmware_fusion' # Configure CPU & RAM per settings in machines.yml (VirtualBox) - srv.vm.provider :virtualbox do |vb, override| + srv.vm.provider 'virtualbox' do |vb, override| vb.memory = machine['ram'] vb.cpus = machine['vcpu'] - override.vm.box = machine['vb_box'] - end # srv.vm.provider virtualbox + override.vm.box = machine['box']['vb'] + end # srv.vm.provider 'virtualbox' # Provision Docker on appropriate VMs if machine['docker'] == true diff --git a/ipvs-docker/machines.yml b/ipvs-docker/machines.yml index 9b3937b..c012529 100644 --- a/ipvs-docker/machines.yml +++ b/ipvs-docker/machines.yml @@ -1,22 +1,31 @@ --- -- name: docker-01 - vmw_box: slowe/ubuntu-trusty-x64 - vb_box: ubuntu/trusty64 - ram: 512 - vcpu: 1 - ip_addr: 192.168.100.151 +- box: + vmw: "bento/ubuntu-14.04" + vb: "ubuntu/trusty64" docker: true -- name: docker-02 - vmw_box: slowe/ubuntu-trusty-x64 - vb_box: ubuntu/trusty64 - ram: 512 - vcpu: 1 - ip_addr: 192.168.100.152 + name: "docker-01" + nics: + - type: "private_network" + ip_addr: "192.168.100.151" + ram: "512" + vcpu: "1" +- box: + vmw: "bento/ubuntu-14.04" + vb: "ubuntu/trusty64" docker: true -- name: lvs-01 - vmw_box: slowe/ubuntu-trusty-x64 - vb_box: ubuntu/trusty64 - ram: 512 - vcpu: 1 - ip_addr: 192.168.100.101 + name: "docker-02" + nics: + - type: "private_network" + ip_addr: "192.168.100.152" + ram: "512" + vcpu: "1" +- box: + vmw: "bento/ubuntu-14.04" + vb: "ubuntu/trusty64" docker: false + name: "lvs-01" + nics: + - type: "private_network" + ip_addr: "192.168.100.101" + ram: "512" + vcpu: "1"