-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
66 lines (56 loc) · 2.4 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/focal64'
config.vm.define 'es_master_01' do |es_master_01|
es_master_01.vm.hostname = 'la-stack-es-master-01'
es_master_01.vm.network 'private_network', ip: '10.0.100.10'
end
config.vm.define 'es_data_01' do |es_data_01|
es_data_01.vm.hostname = 'la-stack-es-data-01'
es_data_01.vm.network 'private_network', ip: '10.0.100.20'
end
config.vm.define 'es_data_02' do |es_data_02|
es_data_02.vm.hostname = 'la-stack-es-data-02'
es_data_02.vm.network 'private_network', ip: '10.0.100.30'
end
config.vm.define 'grafana' do |grafana|
grafana.vm.hostname = 'la-stack-grafana-web-00'
grafana.vm.network 'private_network', ip: '10.0.150.10'
end
config.vm.define 'superset' do |superset|
superset.vm.hostname = 'la-stack-superset-web-00'
superset.vm.network 'private_network', ip: '10.0.150.20'
end
config.vm.define 'ralph' do |ralph|
ralph.vm.hostname = 'la-stack-ralph-00'
ralph.vm.network 'private_network', ip: '10.0.200.10'
end
config.vm.provider 'virtualbox' do |v|
v.memory = 2048
v.cpus = 2
end
# config.ssh.insert_key = false
# config.ssh.private_key_path = '~/.ssh/id_rsa_arkops'
## Copy personal public ssh key to the VMs to allow Ansible to connect to them
public_key = File.read('id_rsa_arkops.pub')
config.vm.provision 'shell', inline: <<-SCRIPT
echo 'Copying ansible-vm public SSH Keys to the VM'
mkdir -p /home/vagrant/.ssh
chmod 700 /home/vagrant/.ssh
echo '#{public_key}' >> /home/vagrant/.ssh/authorized_keys
chmod -R 600 /home/vagrant/.ssh/authorized_keys
echo 'Host 10.0.*.*' >> /home/vagrant/.ssh/config
echo 'StrictHostKeyChecking no' >> /home/vagrant/.ssh/config
echo 'UserKnownHostsFile /dev/null' >> /home/vagrant/.ssh/config
chmod -R 600 /home/vagrant/.ssh/config
SCRIPT
## This will not work in our case, we need to run vagrant up --no-provision first then vagrant provision
## but the provisioner will use only the first vagrant private key to connect and fail with the other VMs
## Even when we force set the private key in the ansible inventory file
# config.vm.provision 'ansible' do |ansible|
# ansible.playbook = 'bootstrap.yml'
# ansible.inventory_path = 'inventories/vagrant.yaml'
# ansible.config_file = 'ansible.cfg'
# ansible.limit = 'all'
# ansible.verbose = '-vvv'
# end
end