Vagrantで複数ホストのセグメントを分けるには普通にサブネットを分けてIPを設定すればOKでした。
Vagrantfile
Vagrant.configure(2) do |config|
$script = <<EOF
yum install wget
yum -y install ibus-kkc vlgothic-*
localectl set-locale LANG=ja_JP.UTF-8
source /etc/locale.conf
EOF
config.vm.define "chef-server" do |node|
node.vm.box = "CentOS7.0"
node.vm.hostname = "chef-server"
node.vm.network :private_network, ip: "192.168.100.5"
node.vm.network :private_network, ip: "192.168.101.10", :netmask => "255.255.255.0", virtualbox__intnet: "01"
node.vm.provision :shell, :inline => $script
end
config.vm.define "chef-client01" do |node|
node.vm.box = "CentOS7.0"
node.vm.hostname = "chef-client01"
node.vm.network :private_network, ip: "192.168.100.6"
node.vm.network :private_network, ip: "192.168.101.11", :netmask => "255.255.255.0", virtualbox__intnet: "01"
node.vm.network :private_network, ip: "192.168.102.20", :netmask => "255.255.255.0", virtualbox__intnet: "02"
node.vm.provision :shell, :inline => $script
end
config.vm.define "chef-client02" do |node|
node.vm.box = "CentOS7.0"
node.vm.hostname = "chef-client02"
node.vm.network :private_network, ip: "192.168.100.7"
node.vm.network :private_network, ip: "192.168.102.21", :netmask => "255.255.255.0", virtualbox__intnet: "02"
node.vm.provision :shell, :inline => $script
end
end
メモ
#centos7取得
#box取得
vagrant box add CentOS7 https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box
#取得できたことを確認
vagrant box list
#作業ディレクトリで、初期化
vagrant init
#起動
vagrant up
#停止
vagrant halt
#一時停止、再開
vagrant suspend
vagrant resume
#再起動
vagrant reload
#破棄
vagrant destroy
#boxを保存
vagrant package
#いいかんじのhost名をつける
vagrant ssh-config --host chefclient
vagrant ssh-config --host chefclient >> ~/.ssh/config