-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
46 lines (39 loc) · 1.36 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
#全ての仮想マシンで公開鍵を共通にする
config.ssh.insert_key = false
#box指定
config.vm.box = "generic/ubuntu2204"
# ansible_local用にディレクトリをマウント
config.vm.synced_folder ".", "/vagrant"
# control1の設定
config.vm.define "control1" do |server|
# ホスト名を設定
server.vm.hostname = "control1"
# ホストオンリーアダプタを設定
server.vm.network "private_network", ip: "192.168.57.10"
# VirtualBox側の各種設定
server.vm.provider "virtualbox" do |vb|
vb.name = config.vm.box.gsub(/.*\//, "") + "_" + server.vm.hostname
vb.memory = 1024
vb.cpus = 2
end
# 秘密鍵をVMに転送
server.vm.provision "file", source: "~/.vagrant.d/insecure_private_key", destination: "~/.ssh/target1_private_key"
# ansibleで初期設定
server.vm.provision "ansible_local" do |ansible|
ansible.playbook = "./playbooks/control1.yml"
end
end
# target1の設定
config.vm.define "target1" do |server|
server.vm.hostname = "target1"
server.vm.network "private_network", ip: "192.168.57.20"
server.vm.provider "virtualbox" do |vb|
vb.name = config.vm.box.gsub(/.*\//, "") + "_" + server.vm.hostname
vb.memory = 1024
vb.cpus = 2
end
end
end