2024-01-14 00:36:00 +00:00
|
|
|
.PHONY: ansible
|
|
|
|
|
2023-11-10 20:50:45 +00:00
|
|
|
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..."; \
|
2024-02-02 12:47:58 +00:00
|
|
|
sleep 5; \
|
|
|
|
$(MAKE) install; \
|
2023-11-10 20:50:45 +00:00
|
|
|
fi
|
|
|
|
|
2023-11-10 21:55:41 +00:00
|
|
|
down:
|
|
|
|
@echo "Stopping Homelab..."
|
2023-11-19 00:10:55 +00:00
|
|
|
@vagrant halt
|
2023-11-10 21:55:41 +00:00
|
|
|
|
2024-02-02 12:47:58 +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;
|
|
|
|
|
2023-10-30 15:54:48 +00:00
|
|
|
install_vb:
|
2024-02-02 12:47:58 +00:00
|
|
|
@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:
|
2024-02-28 11:28:59 +00:00
|
|
|
@INV_LIST="-i ../inventory/lab.yml"; \
|
2024-02-28 11:21:26 +00:00
|
|
|
if [ x"${VPS}" != "x" ]; then \
|
|
|
|
INV_LIST="$${INV_LIST} -i ../inventory/outside.yml"; \
|
|
|
|
fi; \
|
|
|
|
if [ x"${NAS}" != "x" ]; then \
|
|
|
|
INV_LIST="$${INV_LIST} -i ../inventory/nas.yml"; \
|
|
|
|
fi; \
|
|
|
|
cd ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook $${INV_LIST} init.yml --extra-vars 'enable_setup=true enable_wireguard=true enable_k3s=true'
|
2023-11-10 20:50:45 +00:00
|
|
|
@make get_k3s_credentials
|
2023-10-23 12:26:55 +00:00
|
|
|
|
|
|
|
k3s_reset:
|
2023-11-10 20:50:45 +00:00
|
|
|
@echo "Resetting k3s configuration..."
|
2024-02-28 11:21:26 +00:00
|
|
|
@cd ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ../inventory/nas.yml -i ../inventory/lab.yml -i ../inventory/outsider.yml k3s-ansible/reset.yml
|
2023-12-05 08:58:25 +00:00
|
|
|
@make ansible
|
2023-11-10 20:50:45 +00:00
|
|
|
@make get_k3s_credentials
|
2023-10-23 12:26:55 +00:00
|
|
|
|
|
|
|
destroy:
|
2023-11-10 20:50:45 +00:00
|
|
|
@echo "Destroy Homelab installation..."
|
|
|
|
@vagrant destroy -f
|
2023-10-23 12:26:55 +00:00
|
|
|
|
2024-02-02 12:47:58 +00:00
|
|
|
full_reset:
|
|
|
|
$(MAKE) destroy;
|
|
|
|
$(MAKE) install;
|
|
|
|
|
2023-10-23 12:26:55 +00:00
|
|
|
get_k3s_credentials:
|
2023-11-10 20:50:45 +00:00
|
|
|
@echo "Retrieving k3s credentials locally..."
|
|
|
|
@vagrant ssh -c "sudo cat /home/creator/.kube/config" hb-wide-1 > ~/.kube/config-halia
|
2024-02-02 12:47:58 +00:00
|
|
|
@sed -i 's/127.0.*:/192.168.56.101:/g' ~/.kube/config-halia
|
2024-02-28 11:21:26 +00:00
|
|
|
@curl https://git.halis.io/therbron/dotfiles/raw/branch/master/.bin/kube-merge | bash
|
2023-11-10 20:50:45 +00:00
|
|
|
@kubectl get nodes --context halia
|
|
|
|
|