Some customization for vagrant

pull/2/head
Alexander Böhm 2021-03-20 18:17:49 +01:00
parent 1138535a14
commit b7a43229c0
2 changed files with 33 additions and 4 deletions

36
Vagrantfile vendored
View File

@ -1,20 +1,49 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# start vagrant with:
#
# USE_ANSIBLE_IN_VM=true vagrant up
#
# to provision the VM with ansible in the VM
$use_ansible_in_vm = ENV['USE_ANSIBLE_IN_VM'] || false
def create(config, name)
config.vm.define name do |v|
v.vm.hostname = name
v.vm.box = "generic/debian10"
v.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.linked_clone = true
vb.cpus = 2
vb.memory = 1024
# special thing for virtualbox
vb.customize ["modifyvm", :id, "--nicpromisc2", "allow-all"]
end
# add a extra NIC for the DHCP services
v.vm.network "private_network", virtualbox__intnet: true, auto_config: false
v.vm.provision "ansible" do |ans|
ans.playbook = "playbook-vagrant.yml"
if $use_ansible_in_vm
# copy the project to vagrant user
v.vm.synced_folder ".", "/home/vagrant/fai", type: "rsync"
$provision = <<-EOF
sudo apt-get install -y python3-pip
pip3 install ansible
echo faiserver ansible_connection=local python_interpreter=/usr/bin/python3 > ~/inventory
cd /home/vagrant/fai
ansible-playbook -i ~/inventory playbook-vagrant.yml
EOF
# and ran the provision with ansible
v.vm.provision "shell", inline: $provision
else
# ran provision with ansible and use VM as target host
v.vm.provision "ansible" do |ans|
ans.playbook = "playbook-vagrant.yml"
end
end
end
end
@ -22,3 +51,4 @@ end
Vagrant.configure("2") do |config|
create(config, "faiserver")
end

View File

@ -33,4 +33,3 @@
roles:
- fai