extract vagrantfile shared bits
This commit is contained in:
1 parent
a48777e482
commit
d24e75f76b
3 files changed
+75
-68
No files matched your search
Vendored
+7
-53
@@ -1,8 +1,8 @@
|
||||
VAGRANTFILE_API_VERSION = "2"
|
||||
|
||||
vm_ip = "172.16.0.3" # arbitrary private IP
|
||||
require './vagrant-common.rb'
|
||||
|
||||
go_version = "1.4.2"
|
||||
vm_ip = "172.16.0.3" # arbitrary private IP
|
||||
|
||||
pkgs = %w(
|
||||
lxc-docker
|
||||
@@ -16,52 +16,6 @@ pkgs = %w(
|
||||
bc
|
||||
)
|
||||
|
||||
go_path = "/usr/local/go/bin"
|
||||
|
||||
$install_build_deps = <<SCRIPT
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-key adv \
|
||||
--keyserver hkp://keyserver.ubuntu.com:80 \
|
||||
--recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
|
||||
echo 'deb https://get.docker.io/ubuntu docker main' \
|
||||
> /etc/apt/sources.list.d/docker.list
|
||||
apt-get -qq update
|
||||
apt-get -qq install --no-install-recommends #{pkgs.join(' ')}
|
||||
SCRIPT
|
||||
|
||||
$install_go_toochain = <<SCRIPT
|
||||
curl -s https://storage.googleapis.com/golang/go#{go_version}.linux-amd64.tar.gz \
|
||||
| tar xz -C /usr/local
|
||||
#{go_path}/go clean -i net
|
||||
#{go_path}/go install -tags netgo std
|
||||
SCRIPT
|
||||
|
||||
$tweak_user_env = <<SCRIPT
|
||||
echo 'export GOPATH="${HOME}"' \
|
||||
>> ~vagrant/.profile
|
||||
echo 'export PATH="${HOME}/bin:#{go_path}:${PATH}"' \
|
||||
>> ~vagrant/.profile
|
||||
ln -sf ~vagrant/src/github.com/weaveworks/weave ~vagrant/
|
||||
sudo chown -R vagrant:vagrant ~vagrant/src
|
||||
SCRIPT
|
||||
|
||||
$tweak_docker_daemon = <<SCRIPT
|
||||
usermod -a -G docker vagrant
|
||||
echo 'DOCKER_OPTS="-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375"' \
|
||||
>> /etc/default/docker
|
||||
service docker restart
|
||||
SCRIPT
|
||||
|
||||
$cleanup = <<SCRIPT
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
## Who the hell thinks official images have to have both of these?
|
||||
/etc/init.d/chef-client stop
|
||||
/etc/init.d/puppet stop
|
||||
apt-get -qq remove puppet chef
|
||||
apt-get -qq autoremove
|
||||
killall -9 chef-client
|
||||
SCRIPT
|
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
|
||||
config.vm.box = "ubuntu/ubuntu-14.10-amd64"
|
||||
@@ -76,11 +30,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
config.vm.synced_folder ".", "/vagrant", disabled: true
|
||||
config.vm.synced_folder ".", "/home/vagrant/src/github.com/weaveworks/weave"
|
||||
|
||||
config.vm.provision :shell, :inline => $install_build_deps
|
||||
config.vm.provision :shell, :inline => $install_go_toochain
|
||||
config.vm.provision :shell, :inline => $tweak_user_env, :privileged => false
|
||||
config.vm.provision :shell, :inline => $tweak_docker_daemon
|
||||
config.vm.provision :shell, :inline => $cleanup
|
||||
install_build_deps config.vm, pkgs
|
||||
install_go_toochain config.vm
|
||||
tweak_user_env config.vm
|
||||
tweak_docker_daemon config.vm
|
||||
cleanup config.vm
|
||||
|
||||
end
|
||||
|
||||
|
||||
Vendored
+4
-15
@@ -9,18 +9,10 @@ n_machines = 2
|
||||
ip_prefix = "192.168.48"
|
||||
ip_suffix_base = 10
|
||||
|
||||
$cleanup = <<SCRIPT
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
## Who the hell thinks official images have to have both of these?
|
||||
/etc/init.d/chef-client stop
|
||||
/etc/init.d/puppet stop
|
||||
apt-get -qq remove puppet chef
|
||||
apt-get -qq autoremove
|
||||
killall -9 chef-client
|
||||
SCRIPT
|
||||
require '../vagrant-common.rb'
|
||||
|
||||
def configure_docker(host, hostname, ip)
|
||||
pkgs = "lxc-docker ethtool"
|
||||
pkgs = %w(lxc-docker ethtool)
|
||||
|
||||
host.vm.box = "ubuntu/ubuntu-14.10-amd64"
|
||||
host.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/utopic/current/utopic-server-cloudimg-amd64-vagrant-disk1.box"
|
||||
@@ -33,16 +25,13 @@ def configure_docker(host, hostname, ip)
|
||||
host.vm.provision :shell, :inline => "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9"
|
||||
host.vm.provision :shell, :inline => "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
|
||||
|
||||
pkg_cmd = "apt-get update -qq; " \
|
||||
"apt-get install -q -y --force-yes --no-install-recommends "
|
||||
pkg_cmd << pkgs
|
||||
host.vm.provision :shell, :inline => pkg_cmd
|
||||
install_packages host.vm, pkgs
|
||||
host.vm.provision :shell, :inline => "usermod -a -G docker vagrant; "
|
||||
|
||||
# Listen on the remote API
|
||||
host.vm.provision :shell, :inline => "echo 'DOCKER_OPTS=\"-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375\"' >> /etc/default/docker"
|
||||
host.vm.provision :shell, :inline => "service docker restart"
|
||||
host.vm.provision :shell, :inline => $cleanup
|
||||
cleanup(host.vm)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
$go_version = "1.4.2"
|
||||
|
||||
$go_path = "/usr/local/go/bin"
|
||||
|
||||
def install_packages(vm, pkgs)
|
||||
vm.provision :shell, :inline => <<SCRIPT
|
||||
apt-get update -qq
|
||||
apt-get install -qq -y --force-yes --no-install-recommends #{pkgs.join(' ')}
|
||||
SCRIPT
|
||||
end
|
||||
|
||||
def install_build_deps(vm, pkgs)
|
||||
vm.provision :shell, :inline => <<SCRIPT
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-key adv \
|
||||
--keyserver hkp://keyserver.ubuntu.com:80 \
|
||||
--recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
|
||||
echo 'deb https://get.docker.io/ubuntu docker main' \
|
||||
> /etc/apt/sources.list.d/docker.list
|
||||
SCRIPT
|
||||
install_packages(vm, pkgs)
|
||||
end
|
||||
|
||||
def install_go_toochain(vm)
|
||||
vm.provision :shell, :inline => <<SCRIPT
|
||||
curl -s https://storage.googleapis.com/golang/go#{$go_version}.linux-amd64.tar.gz \
|
||||
| tar xz -C /usr/local
|
||||
#{$go_path}/go clean -i net
|
||||
#{$go_path}/go install -tags netgo std
|
||||
SCRIPT
|
||||
end
|
||||
|
||||
def tweak_user_env(vm)
|
||||
script = <<SCRIPT
|
||||
echo 'export GOPATH="${HOME}"' \
|
||||
>> ~vagrant/.profile
|
||||
echo 'export PATH="${HOME}/bin:#{$go_path}:${PATH}"' \
|
||||
>> ~vagrant/.profile
|
||||
ln -sf ~vagrant/src/github.com/weaveworks/weave ~vagrant/
|
||||
sudo chown -R vagrant:vagrant ~vagrant/src
|
||||
SCRIPT
|
||||
vm.provision :shell, :inline => script, :privileged => false
|
||||
end
|
||||
|
||||
def tweak_docker_daemon(vm)
|
||||
vm.provision :shell, :inline => <<SCRIPT
|
||||
usermod -a -G docker vagrant
|
||||
echo 'DOCKER_OPTS="-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375"' \
|
||||
>> /etc/default/docker
|
||||
service docker restart
|
||||
SCRIPT
|
||||
end
|
||||
|
||||
def cleanup(vm)
|
||||
vm.provision :shell, :inline => <<SCRIPT
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
## Who the hell thinks official images have to have both of these?
|
||||
/etc/init.d/chef-client stop
|
||||
/etc/init.d/puppet stop
|
||||
apt-get -qq remove puppet chef
|
||||
apt-get -qq autoremove
|
||||
killall -9 chef-client
|
||||
SCRIPT
|
||||
end
|
||||
Reference in new issue
Block a user