- windows 10
- virtual box 5.1.6
- vagrant 1.8.6
- Vagrantfileを編集する。
後続の「VagrantFile」を参照する。
- VMを立ち上げる。
全てのVMを立ち上げる。
# vagrant up
指定のVMを立ち上げる。
# vagrant up master
# vagrant up slave
- SSHで接続する。
vagrantのSSHコマンドで対象のVMへ接続する。
# vagrant ssh master
masterへ接続後、slaveへ接続する。
# ssh vagrant@192.168.33.11
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "CentOS7"
config.vm.define :master do |master|
master.vm.box = "CentOS7"
master.vm.hostname = "MASTER"
master.vm.network :forwarded_port, id: "ssh", guest: 22, host: 2222
master.vm.network "private_network", ip: "192.168.33.10"
end
config.vm.define :slave do |slave|
slave.vm.box = "CentOS7"
slave.vm.hostname = "SLAVE"
slave.vm.network :forwarded_port, id: "ssh", guest: 22, host: 2223
slave.vm.network "private_network", ip: "192.168.33.11"
end
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
vb.memory = "1024"
end
end
VagrantとDockerとAnsibleで環境自動構築!(前編:vagrantとAnsible編)
[Vagrant] Vagrant で複数のVM を立ち上げて、お互いに通信できるようにするには [VirtualBox]