Some customization for vagrant
parent
1138535a14
commit
b7a43229c0
|
@ -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
|
||||
|
||||
|
|
|
@ -33,4 +33,3 @@
|
|||
|
||||
roles:
|
||||
- fai
|
||||
|
||||
|
|
Loading…
Reference in New Issue