Homelab/Makefile

67 lines
1.8 KiB
Makefile
Raw Normal View History

.PHONY: ansible
up:
@echo "Checking for Homelab installation..."
@vagrant status | grep "not created" > /dev/null; \
if [ "$$?" -gt 0 ]; then \
echo "Installation found, bringing it up..."; \
vagrant up; \
else \
echo "No Homelab installation found or missing components, creating..."; \
sleep 5; \
$(MAKE) install; \
fi
2023-11-10 21:55:41 +00:00
down:
@echo "Stopping Homelab..."
@vagrant halt
2023-11-10 21:55:41 +00:00
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 using virtualbox..."
@vagrant up --provider=virtualbox
install_libvirt:
@echo "Creating components using libvirt..."
@vagrant up --provider=libvirt
2023-12-05 08:58:25 +00:00
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"
ansible:
@cd ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ../inventory/lab.yml -i ../inventory/outsider.yml init.yml --extra-vars "enable_setup=true enable_wireguard=true enable_k3s=true"
@make get_k3s_credentials
k3s_reset:
@echo "Resetting k3s configuration..."
@cd ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ../inventory/lab.yml -i ../inventory/outsider.yml k3s-ansible/reset.yml
2023-12-05 08:58:25 +00:00
@make ansible
@make get_k3s_credentials
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/127.0.*:/192.168.56.101:/g' ~/.kube/config-halia
@kube-merge
@kubectl get nodes --context halia