Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
cleaned up Vagrantfiles for new box features + styleguide (rubocop)
Browse files Browse the repository at this point in the history
  • Loading branch information
routelastresort committed Mar 27, 2015
1 parent 9e1b705 commit 274fe4f
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 78 deletions.
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Metrics/LineLength:
Enabled: false
Style/FileName:
Enabled: false
Style/StringLiterals:
Enabled: false
40 changes: 15 additions & 25 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,24 @@ require "vagrant-host-shell"
require "vagrant-junos"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#disable filder sharing by default
config.vm.synced_folder ".", "/vagrant", disabled: true

config.vm.define "ndo", primary: true do |ndo|
ndo.vm.box = "juniper/netdevops-ubuntu1404"
ndo.vm.hostname = "NetDevOps-Student"
ndo.vm.network "private_network",
ip: "172.16.0.10",
virtualbox__intnet: "NetDevOps-StudentInternal"
config.vm.synced_folder "", "/vagrant", disabled: false
ip: "172.16.0.10",
virtualbox__intnet: "NetDevOps-StudentInternal"
config.vm.synced_folder "", "/vagrant"

ndo.vm.provider "virtualbox" do |v|
# v.gui = true
# v.customize ["modifyvm", :id, "--nic1", "hostonly"]
# v.gui = true
# v.customize ["modifyvm", :id, "--nic1", "hostonly"]
end

ndo.ssh.shell = 'sh'

ndo.vm.provision "shell" do |s|
# TODO: DO THIS STUFF!!!!!
# add this to the shell
# export ANSIBLE_LIBRARY=/etc/ansible/roles/
# set routes for 10.10.0.0/24 and 192.168.10.0/24 to 172.16.0.1
# TODO: DO THIS STUFF!!!!!
# add this to the shell
# export ANSIBLE_LIBRARY=/etc/ansible/roles/
# set routes for 10.10.0.0/24 and 192.168.10.0/24 to 172.16.0.1
s.path = "scripts/ndo-setup.sh"
end
end
Expand All @@ -39,23 +34,18 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
srx.vm.box = "juniper/ffp-12.1X47-D20.7"
srx.vm.hostname = "NetDevOps-SRX01"
srx.vm.provider "virtualbox" do |v|
#v.gui = true
# v.gui = true
end
srx.vm.network "private_network",
ip: "172.16.0.1",
virtualbox__intnet: "NetDevOps-StudentInternal",
nic_type: 'virtio'
ip: "172.16.0.1",
virtualbox__intnet: "NetDevOps-StudentInternal"

srx.vm.network "private_network",
ip: "10.255.255.10",
virtualbox__intnet: "NetDevOps-StudentLAN",
nic_type: 'virtio'
ip: "10.255.255.10",
virtualbox__intnet: "NetDevOps-StudentLAN"

srx.vm.synced_folder "", "/vagrant", disabled: true

srx.ssh.username = 'root'
srx.ssh.shell = 'sh'
srx.ssh.insert_key = false

srx.vm.provision "file", source: "scripts/srx-setup.sh", destination: "/tmp/srx-setup.sh"
srx.vm.provision :host_shell do |host_shell|
host_shell.inline = 'vagrant ssh srx -c "/usr/sbin/cli -f /tmp/srx-setup.sh"'
Expand Down
38 changes: 14 additions & 24 deletions Vagrantfile.BRIDGED
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,38 @@ require "vagrant-host-shell"
require "vagrant-junos"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.synced_folder ".", "/vagrant", disabled: true

config.vm.define "ndo", primary: true do |ndo|
ndo.vm.box = "juniper/netdevops-ubuntu1404"
ndo.vm.hostname = "NetDevOps-Student"
ndo.vm.network "private_network",
ip: "172.16.0.10",
virtualbox__intnet: "NetDevOps-StudentInternal"
config.vm.synced_folder "", "/vagrant", disabled: false
ip: "172.16.0.10",
virtualbox__intnet: "NetDevOps-StudentInternal"
config.vm.synced_folder "", "/vagrant"

ndo.vm.provider "virtualbox" do |v|
# v.gui = true
# v.customize ["modifyvm", :id, "--nic1", "hostonly"]
# v.gui = true
# v.customize ["modifyvm", :id, "--nic1", "hostonly"]
end

ndo.ssh.shell = 'sh'


ndo.vm.provision "shell" do |s|
s.path = "scripts/ifbounce.sh"
end
end

config.vm.define "srx" do |srx|
srx.vm.box = "juniper/ffp-12.1X47-D10.4"
srx.vm.hostname = "NetDevOps-SRX01"
srx.vm.provider "virtualbox" do |v|
#v.gui = true
# v.gui = true
end
srx.vm.network "private_network",
ip: "172.16.0.1",
virtualbox__intnet: "NetDevOps-StudentInternal",
nic_type: 'virtio'
srx.vm.network "public_network",
#ip: "10.255.255.10",
#virtualbox__intnet: "NetDevOps-StudentLAN",
nic_type: 'virtio'

srx.vm.synced_folder "", "/vagrant", disabled: true
ip: "172.16.0.1",
virtualbox__intnet: "NetDevOps-StudentInternal"
srx.vm.network "public_network"
# ip: "10.255.255.10",
# virtualbox__intnet: "NetDevOps-StudentLAN",

srx.ssh.username = 'root'
srx.ssh.shell = 'sh'
srx.ssh.insert_key = false
srx.vm.synced_folder "", "/vagrant", disabled: true

srx.vm.provision "file", source: "scripts/srx-setup.sh", destination: "/tmp/srx-setup.sh"
srx.vm.provision :host_shell do |host_shell|
Expand Down
40 changes: 16 additions & 24 deletions proctor/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,25 @@ require "vagrant-host-shell"
require "vagrant-junos"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
#disable filder sharing by default
config.vm.synced_folder ".", "/vagrant", disabled: true

config.vm.define "ndo", primary: true do |ndo|
ndo.vm.box = "juniper/netdevops-ubuntu1404"
ndo.vm.hostname = "NetDevOps-Proctor"
ndo.vm.network "private_network",
ip: "10.10.0.10",
virtualbox__intnet: "NetDevOps-StudentInternal"
config.vm.synced_folder "", "/vagrant", disabled: false
ip: "10.10.0.10",
virtualbox__intnet: "NetDevOps-StudentInternal"
config.vm.synced_folder "", "/vagrant"

ndo.vm.provider "virtualbox" do |v|
# v.gui = true
# v.customize ["modifyvm", :id, "--nic1", "hostonly"]
# v.gui = true
# v.customize ["modifyvm", :id, "--nic1", "hostonly"]
end

ndo.ssh.shell = 'sh'

ndo.vm.provision "shell" do |s|
# TODO: DO THIS STUFF!!!!!
# add this to the shell
# export ANSIBLE_LIBRARY=/etc/ansible/roles/
# set routes for 10.10.0.0/24 and 192.168.10.0/24 to 172.16.0.1
# TODO: DO THIS STUFF!!!!!
# add this to the shell
# export ANSIBLE_LIBRARY=/etc/ansible/roles/
# set routes for 10.10.0.0/24 and 192.168.10.0/24 to 172.16.0.1
s.path = "scripts/ifbounce.sh"
end
end
Expand All @@ -39,23 +35,19 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
srx.vm.box = "juniper/ffp-12.1X47-D20.7"
srx.vm.hostname = "NetDevOps-SRX01"
srx.vm.provider "virtualbox" do |v|
#v.gui = true
# v.gui = true
end
srx.vm.network "private_network",
ip: "192.168.10.10",
virtualbox__intnet: "NetDevOps-Private",
nic_type: 'virtio'
ip: "192.168.10.10",
virtualbox__intnet: "NetDevOps-Private",
nic_type: 'virtio'
srx.vm.network "private_network",
ip: "10.10.0.10"
virtualbox__intnet: "NetDevOps-Public",
nic_type: 'virtio'
ip: "10.10.0.10",
virtualbox__intnet: "NetDevOps-Public",
nic_type: 'virtio'

srx.vm.synced_folder "", "/vagrant", disabled: true

srx.ssh.username = 'root'
srx.ssh.shell = 'sh'
srx.ssh.insert_key = false

srx.vm.provision "file", source: "scripts/srx-setup.sh", destination: "/tmp/srx-setup.sh"
srx.vm.provision :host_shell do |host_shell|
host_shell.inline = 'vagrant ssh srx -c "/usr/sbin/cli -f /tmp/srx-setup.sh"'
Expand Down
20 changes: 15 additions & 5 deletions scripts/ndo-setup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#!/usr/bin/env bash
export ANSIBLE_LIBRARY=/etc/ansible/roles/
echo "export ANSIBLE_LIBRARY=/etc/ansible/roles/" >> /home/vagrant/.bashrc
if ! grep -qe "export ANSIBLE_LIBRARY=/etc/ansible/roles/" "/home/vagrant/.bashrc"; then
cat >> /home/vagrant/.bashrc <<EOF
/sbin/route add -net 10.10.0.0 netmask 255.255.255.0 gw 172.16.0.1 dev eth1
/sbin/route add -net 192.168.10.0 netmask 255.255.255.0 gw 172.16.0.1 dev eth1
echo "up route add -net 10.10.0.0/24 gw 172.16.0.1 dev eth1" >> /etc/network/interfaces
echo "up route add -net 192.168.10.0/24 gw 172.16.0.1 dev eth1" >> /etc/network/interfaces
export ANSIBLE_LIBRARY=/etc/ansible/roles/
EOF
fi

ip r a 10.10.0.0/24 via 172.16.0.1 dev eth1
ip r a 192.168.10.0/24 via 172.16.0.1 dev eth1

cat >> /etc/network/interfaces <<EOF
post-up route add -net 10.10.0.0 netmask 255.255.255.0 gw 172.16.0.1 dev eth1
post-up route add -net 192.168.10.0 netmask 255.255.255.0 gw 172.16.0.1 dev eth1
EOF

0 comments on commit 274fe4f

Please sign in to comment.