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
|
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Require YAML module
require 'yaml'
# Read YAML file with box details
inventory = YAML.load_file('inventory.yml')
Vagrant.configure("2") do |config|
inventory['all']['children'].each do |group,group_details|
config.winrm.transport = :ssl
config.winrm.basic_auth_only = true
config.winrm.ssl_peer_verification = false
group_details['children'].each do |sub_group,sub_group_details|
sub_group_details['hosts'].each do |server,details|
config.vm.define server do |srv|
srv.vm.box = details['vagrant_box']
srv.vm.hostname = server
srv.vm.network :private_network,
:ip => details['ansible_host'],
:libvirt__network_name => 'spnego-test',
:libvirt__domain_name => inventory['all']['vars']['domain_name']
srv.vm.provider :virtualbox do |v|
v.name = File.basename(File.dirname(__FILE__)) + "_" + server + "_" + Time.now.to_i.to_s
v.gui = false
v.memory = 4096
v.cpus = 2
end
srv.vm.provider :libvirt do |l|
l.memory = 4096
l.cpus = 2
end
if group == "linux"
srv.vm.provision "shell", inline: <<-SHELL
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
systemctl restart sshd.service
SHELL
end
end
end
end
end
end
|