Skip to content

Instantly share code, notes, and snippets.

@wnoguchi
Created July 21, 2014 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wnoguchi/b784ca2b4c04cd0111f6 to your computer and use it in GitHub Desktop.
Save wnoguchi/b784ca2b4c04cd0111f6 to your computer and use it in GitHub Desktop.
第60回: SerfとConsulでシステム運用を楽しくしよう!http://connpass.com/event/7322/ : 今回の実験使用したVagrantfileの一覧
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "chef/centos-6.5"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
end
config.vm.define "web_1" do |instance|
instance.vm.network :private_network, ip: "192.168.33.10"
instance.vm.provision :shell do |shell|
shell.inline = <<-EOS
if [ ! `which unzip` ]; then sudo yum -y install unzip ;fi
if [ ! `which serf` ]; then
cd /tmp/
wget -O 0.6.3_linux_amd64.zip https://dl.bintray.com/mitchellh/serf/0.6.3_linux_amd64.zip
unzip 0.6.3_linux_amd64.zip
sudo mv serf /usr/local/bin/
nohup /usr/local/bin/serf agent -iface=eth1 -node=host1 -discover=webapp 0<&- &>/dev/null&
cat <<EOF >>/etc/rc.d/rc.local
/usr/local/bin/serf agent -iface=eth1 -node=host1 -discover=webapp &
EOF
fi
EOS
end
end
config.vm.define "web_2" do |instance|
instance.vm.network :private_network, ip: "192.168.33.11"
instance.vm.provision :shell do |shell|
shell.inline = <<-EOS
if [ ! `which unzip` ]; then sudo yum -y install unzip ;fi
if [ ! `which serf` ]; then
cd /tmp/
wget -O 0.6.3_linux_amd64.zip https://dl.bintray.com/mitchellh/serf/0.6.3_linux_amd64.zip
unzip 0.6.3_linux_amd64.zip
sudo mv serf /usr/local/bin/
nohup /usr/local/bin/serf agent -iface=eth1 -node=host2 -discover=webapp 0<&- &>/dev/null&
cat <<EOF >>/etc/rc.d/rc.local
/usr/local/bin/serf agent -iface=eth1 -node=host2 -discover=webapp &
EOF
fi
EOS
end
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "chef/centos-6.5"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
end
config.vm.define "web_1" do |instance|
instance.vm.network :private_network, ip: "192.168.33.10"
end
config.vm.define "web_2" do |instance|
instance.vm.network :private_network, ip: "192.168.33.11"
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "chef/centos-6.5"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
end
# Number of Virtual Machines
NUMBER_OF_VMS = 10
ip_addr_base = 10
(1..NUMBER_OF_VMS).each do |host_index|
define_name = "web_#{host_index}"
hostname = "host#{host_index}"
octet4 = ip_addr_base + host_index - 1
config.vm.define define_name do |instance|
instance.vm.network :private_network, ip: "192.168.33.#{octet4}"
instance.vm.provision :shell do |shell|
shell.inline = <<-EOS
if [ ! `which unzip` ]; then sudo yum -y install unzip ;fi
if [ ! `which serf` ]; then
cd /tmp/
wget -O 0.6.3_linux_amd64.zip https://dl.bintray.com/mitchellh/serf/0.6.3_linux_amd64.zip
unzip 0.6.3_linux_amd64.zip
sudo mv serf /usr/local/bin/
nohup /usr/local/bin/serf agent -iface=eth1 -node=#{hostname} -discover=webapp 0<&- &>/dev/null&
cat <<EOF >>/etc/rc.d/rc.local
/usr/local/bin/serf agent -iface=eth1 -node=#{hostname} -discover=webapp &
EOF
fi
EOS
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment