feat(libvirt): Add support for libvirt (qemu)

This commit is contained in:
Tanguy Herbron 2024-02-02 13:47:58 +01:00
parent 4380bafe28
commit e248973644
2 changed files with 42 additions and 7 deletions

View File

@ -8,19 +8,33 @@ up:
vagrant up; \
else \
echo "No Homelab installation found or missing components, creating..."; \
sleep 10; \
$(MAKE) install_vb; \
sleep 5; \
$(MAKE) install; \
fi
down:
@echo "Stopping Homelab..."
@vagrant halt
install:
@vagrant plugin list | grep libvirt > /dev/null; \
if [ "$$?" -gt 0 ]; then \
$(MAKE) install_vb; \
else \
$(MAKE) install_libvirt; \
fi
echo "Installing k3s backbone configuration...";
make ansible;
install_vb:
@echo "Creating components..."
@vagrant up
@echo "Installing k3s backbone configuration..."
@make ansible
@echo "Creating components using virtualbox..."
@vagrant up --provider=virtualbox
install_libvirt:
@echo "Creating components using libvirt..."
@vagrant up --provider=libvirt
wg:
@cd ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ../inventory/lab.yml -i ../inventory/outsider.yml init.yml --extra-vars "enable_setup=false enable_wireguard=true enable_k3s=false"
@ -39,10 +53,14 @@ destroy:
@echo "Destroy Homelab installation..."
@vagrant destroy -f
full_reset:
$(MAKE) destroy;
$(MAKE) install;
get_k3s_credentials:
@echo "Retrieving k3s credentials locally..."
@vagrant ssh -c "sudo cat /home/creator/.kube/config" hb-wide-1 > ~/.kube/config-halia
@sed -i 's/100.64.*:/192.168.56.101:/g' ~/.kube/config-halia
@sed -i 's/127.0.*:/192.168.56.101:/g' ~/.kube/config-halia
@kube-merge
@kubectl get nodes --context halia

17
Vagrantfile vendored
View File

@ -8,12 +8,18 @@ Vagrant.configure("2") do |config|
v.cpus = 2
end
config.vm.provider "libvirt" do |q|
q.memory = 2048
q.cpus = 2
end
boxes = [
{ :name => "hb-slim-1", :ip => "192.168.56.11"},
{ :name => "hb-slim-2", :ip => "192.168.56.12"},
{ :name => "hb-slim-3", :ip => "192.168.56.13"},
{ :name => "hb-wide-1", :ip => "192.168.56.101", :cpus => 2, :memory => 4096},
{ :name => "hb-wide-2", :ip => "192.168.56.102", :cpus => 2, :memory => 4096},
{ :name => "hb-wide-3", :ip => "192.168.56.103", :cpus => 2, :memory => 4096},
{ :name => "nas", :ip => "192.168.56.200", :cpus => 2, :memory => 4096, :drive => { name: "extra_disk", size: "30GB" }},
]
@ -24,6 +30,7 @@ Vagrant.configure("2") do |config|
if !opts[:drive].nil?
box.vm.disk :disk, size: opts[:drive][:size], name: opts[:drive][:name]
end
box.vm.provider "virtualbox" do |v|
if !opts[:memory].nil?
v.memory = opts[:memory]
@ -32,6 +39,16 @@ Vagrant.configure("2") do |config|
v.cpus = opts[:cpus]
end
end
box.vm.provider "libvirt" do |q|
if !opts[:memory].nil?
q.memory = opts[:memory]
end
if !opts[:cpus].nil?
q.cpus = opts[:cpus]
end
end
end
end
end