快速生成测试环境, 用配置的方式来生成与管理虚拟机
Install
- vbox
- vagrant
官方文档
批量生成示例
进入本地目录, 编辑Vagrantfile, 然后up
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
servers = { :test1 => '192.168.2.132', :test2 => '192.168.2.133' } Vagrant.configure("2") do |config| config.vm.box = "centos/7" servers.each do |server_name, server_ip| config.vm.define server_name do |server_config| server_config.vm.hostname = "#{server_name.to_s}" server_config.vm.network :public_network, ip: server_ip server_config.vm.provider "virtualbox" do |vb| vb.name = server_name.to_s vb.memory = "512" vb.cpus = 2 end end end end |