This contains a lot of changes, including better system configuration for some issues discovered during testing, and minor tweaking for better user experience when doing maintenance
50 lines
2.6 KiB
Makefile
50 lines
2.6 KiB
Makefile
ENV ?= none
|
|
ANSIBLE_USER ?= atmen
|
|
ANSIBLE_SSH_KEY ?= ~/.ssh/atmen
|
|
CLUSTER_NAME ?= halis
|
|
|
|
ifeq ($(ENV), prod)
|
|
INVENTORY:=$(shell ls -p inventory/prod | grep -v / | sed 's/^/-i inventory\/prod\//g' | sed -z 's/\n/ /g' | head -c -1)
|
|
NODE_IP:=$(shell grep -s server inventory/prod/* | head -1 | cut -d ':' -f 1 | xargs cat | grep ansible_host | head -1 | cut -d ':' -f 2 | cut -c2-)
|
|
ifeq ($(ENV), dev)
|
|
INVENTORY:=$(shell ls -p inventory/dev | grep -v / | sed 's/^/-i inventory\/dev\//g' | sed -z 's/\n/ /g' | head -c -1)
|
|
NODE_IP:=$(shell grep -s server inventory/dev/* | head -1 | cut -d ':' -f 1 | xargs cat | grep ansible_host | head -1 | cut -d ':' -f 2 | cut -c2-)
|
|
else
|
|
INVENTORY = -i inventory/templates/hosts.yml
|
|
NODE_IP:=$(shell grep -s server inventory/templates/* | head -1 | cut -d ':' -f 1 | xargs cat | grep ansible_host | head -1 | cut -d ':' -f 2 | cut -c2-)
|
|
endif
|
|
|
|
init:
|
|
ANSIBLE_VAULT_PASSWORD_FILE=./.vault_pass ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook $(INVENTORY) "init.yml"
|
|
|
|
install:
|
|
ANSIBLE_VAULT_PASSWORD_FILE=./.vault_pass ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook $(INVENTORY) "bootstrap.yml" --extra-vars "enable_setup=true enable_wireguard=true enable_k3s=true"
|
|
|
|
upgrade:
|
|
ANSIBLE_VAULT_PASSWORD_FILE=./.vault_pass ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook $(INVENTORY) "k3s-upgrade.yml"
|
|
|
|
conf:
|
|
ANSIBLE_VAULT_PASSWORD_FILE=./.vault_pass ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook $(INVENTORY) node-configuration
|
|
|
|
wg:
|
|
ANSIBLE_VAULT_PASSWORD_FILE=./.vault_pass ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook $(INVENTORY) "bootstrap.yml" --extra-vars "enable_setup=false enable_wireguard=true enable_k3s=false"
|
|
|
|
k3s:
|
|
ANSIBLE_VAULT_PASSWORD_FILE=./.vault_pass ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook $(INVENTORY) "bootstrap.yml" --extra-vars "enable_wireguard=false enable_k3s=true enable_setup=false"
|
|
|
|
k3s-uninstall:
|
|
ANSIBLE_VAULT_PASSWORD_FILE=./.vault_pass ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook $(INVENTORY) "k3s-uninstall.yml"
|
|
|
|
ping:
|
|
ANSIBLE_VAULT_PASSWORD_FILE=./.vault_pass ANSIBLE_HOST_KEY_CHECKING=False ansible all $(INVENTORY) -m ping
|
|
|
|
ping-unprovisioned:
|
|
ANSIBLE_VAULT_PASSWORD_FILE=./.vault_pass ANSIBLE_HOST_KEY_CHECKING=False ansible all -i inventory/unprovisioned.yml -m ping
|
|
|
|
get_k3s_credentials:
|
|
@echo "Retrieving k3s credentials locally..."
|
|
ssh $(ANSIBLE_USER)@$(NODE_IP) -i $(ANSIBLE_SSH_KEY) -p 7929 "cat /home/$(ANSIBLE_USER)/.kube/config" > ~/.kube/config-$(CLUSTER_NAME)
|
|
@sed -i 's/127.0.*:/$(NODE_IP):/g' ~/.kube/config-$(CLUSTER_NAME)
|
|
@curl https://git.halis.io/therbron/dotfiles/raw/branch/master/.bin/kube-merge | bash
|
|
@kubectl get nodes --context $(CLUSTER_NAME)
|