-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
48 lines (40 loc) · 1.5 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
47
48
Vagrant.configure("2") do |config|
# List of servers
servers=[
{
:hostname => "nlb-01",
:box => "centos/8",
:ip => "192.168.50.2",
:ssh_port => '2221',
:haproxy_web => '7000'
},
{
:hostname => "nlb-02",
:box => "centos/8",
:ip => "192.168.50.3",
:ssh_port => '2222',
:haproxy_web => '7001'
},
]
servers.each do |machine|
config.vm.define machine[:hostname] do |node|
node.vm.box = machine[:box]
node.vm.hostname = machine[:hostname]
node.vm.network :private_network, ip: machine[:ip]
node.vm.network "forwarded_port", guest: 22, host: machine[:ssh_port], id: "ssh"
node.vm.network "forwarded_port", guest: 9091, host: machine[:haproxy_web], id: "haproxy_web"
node.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--memory", 1024]
v.customize ["modifyvm", :id, "--name", machine[:hostname]]
end
end
end
# Inject your public SSH key
id_rsa_key_pub = File.read(File.join(Dir.home, ".ssh", "id_rsa.pub"))
config.vm.provision :shell,
:inline => "echo 'appending SSH public key to ~vagrant/.ssh/authorized_keys' && echo '#{id_rsa_key_pub }' >> /home/vagrant/.ssh/authorized_keys && chmod 600 /home/vagrant/.ssh/authorized_keys"
config.ssh.insert_key = false
#config.vm.provision "ansible" do |ansible|
#ansible.playbook = "site.yml"
#end
end