버전
vagrant v2
가상머신 설정 및 실행을 커맨드라인 명령어로 처리할 수 있도록 한 프로그램
VirtualBox / VMware 등을 지원
VirtualBox 기준으로 설명
설치는 공식 사이트에서 다운로드
https://www.vagrantup.com/
기본 이미지 (box) 가져오기
http://docs.vagrantup.com/v2/getting-started/boxes.html
$ vagrant box add chef/centos-6.5
공홈에 있는 box 이미지들 링크
https://atlas.hashicorp.com/boxes/search
vagrant 로 vm(그룹) 설정하기
Vagrant 파일 생성 및 수정
vagrant plugin 설치 (hostmanager)
$ vagrant plugin install vagrant-hostmanager
chef 테스트를 위해 설정한 Vagrantfile 내용
hosts = {
"chef-server" => { ip: "192.168.30.10", ssh_forward: 11022, mem: 1600 },
"workstation" => { ip: "192.168.30.20", ssh_forward: 12022, mem: 640 },
"node01" => { ip: "192.168.30.21", ssh_forward: 12122, mem: 512 },
"node02" => { ip: "192.168.30.22", ssh_forward: 12222, mem: 512 },
"node03" => { ip: "192.168.30.23", ssh_forward: 12322, mem: 512 }
}
Vagrant.configure(2) do |config|
# Define base image
config.vm.box = "chef/centos-6.5"
config.ssh.insert_key = false
config.ssh.private_key_path = "~\\.vagrant.d\\insecure_private_key"
# Manage /etc/hosts on host and VMs
config.hostmanager.enabled = false
config.hostmanager.manage_host = true
config.hostmanager.include_offline = true
config.hostmanager.ignore_private_ip = false
hosts.each do |name, prop|
config.vm.define name do |machine|
machine.vm.provider :virtualbox do |v|
v.name = name
v.customize ["modifyvm", :id, "--memory", prop[:mem] ]
end
machine.vm.network :private_network, ip: prop[:ip]
machine.vm.network "forwarded_port", guest: 22, host: prop[:ssh_forward], id: "ssh"
machine.vm.hostname = "%s.localdomain" % name
machine.vm.provision :hostmanager
end
end
end