Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

combined that with some dedicated RFC1918 addresses, and corresponding names.

There are 3 items involved:

Vagrant config

The This is done in one Vagrantfile and looks like this:

Code Block
theme
languageruby
MidnighttitleVagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

machines=[
 {
   :hostname => "wheezy",
   :ip => "192.168.77.71",
   :box => "debian/wheezy64"
 },
 {
   :hostname => "jessie",
   :ip => "192.168.77.72",
   :box => "debian/jessie64"
 },
 {
   :hostname => "stretch",
   :ip => "192.168.77.73",
   :cpus => 4,
   :memory => 4096,
   :box => "debian/stretch64"
 },
 {
   :hostname => "trusty",
   :ip => "192.168.77.74",
   :box => "ubuntu/trusty64"
 },
 {
   :hostname => "xenial",
   :ip => "192.168.77.75",
   :box => "ubuntu/xenial64",
   :shellcode => "apt-get -yy install python-minimal",
 },
 {
   :hostname => "bionic",
   :ip => "192.168.77.76",
   :box => "ubuntu/bionic64",
   :shellcode => "apt-get -yy install python-minimal",
 },
 {
   :hostname => "centos6",
   :ip => "192.168.77.77",
   :box => "centos/6"
 },
 {
   :hostname => "centos7",
   :ip => "192.168.77.78",
   :box => "centos/7"
 },
 {
   :hostname => "rhel6",
   :ip => "192.168.77.79",
   :box => "samdoran/rhel6"
 },
 {
   :hostname => "rhel7",
   :ip => "192.168.77.80",
   :box => "generic/rhel7"
 }
]


# To inject into each VM
mypubkey = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip

Vagrant.configure("2") do |config|
  machines.each do |machine|
    config.vm.define machine[:hostname] do |node|
      node.vm.box = machine[:box]
      node.vm.hostname = machine[:hostname]
      node.vm.provision 'shell', inline: "echo \"#{mypubkey}\" >> /home/vagrant/.ssh/authorized_keys", privileged: false
      if machine.has_key? :shellcode
        node.vm.provision 'shell', inline: machine[:shellcode]
      end
      node.vm.network "private_network", ip: machine[:ip]
      node.vm.provider "virtualbox" do |vb|
        vb.customize ["modifyvm", :id, "--memory", machine.has_key?(:memory) ? machine[:memory] : 512 ] 
        vb.customize ["modifyvm", :id, "--cpus", machine.has_key?(:cpus) ? machine[:cpus] : 1 ] 
      end
    end
  end
end

...

Code Block
# Vagrant distros
Host wheezy jessie stretch trusty xenial bionic centos6 centos7 rhel6 rhel7
  User vagrant
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no



At this moment you should be able to simply do:


Code Block
vagrant up centos7
ssh centos7


and when you're done:

Code Block
vagrant destroy centos7


Happy testing!