#!/usr/bin/env just

opentofu_dir := "infra/"
ansible_proton_pass_plugin_ref := "4bd0741c347646060ec59c73f8adf7ed8e706cf3"
ansible_proton_pass_plugin_url := "https://raw.githubusercontent.com/protonpass/proton-pass-ansible-integration/" + ansible_proton_pass_plugin_ref + "/lookup_plugins/proton_pass.py"

up: tofu-apply ansible-run-playbook
down: tofu-destroy

tofu-init:
    tofu -chdir={{ opentofu_dir }} init -upgrade

tofu-apply: tofu-init
    tofu -chdir={{ opentofu_dir }} apply -auto-approve

tofu-destroy: tofu-init
    tofu -chdir={{ opentofu_dir }} apply -auto-approve -destroy

ansible-run-playbook:
    ansible-playbook -i ansible/inventories/incus/incus.yaml -c community.general.incus ansible/site.yaml

get-admin-conf:
    incus exec master-0 -- cat /etc/kubernetes/admin.conf > k8s-admin.conf

clean: tofu-destroy
    git clean -fdx

fetch-plugins:
    mkdir -p ansible/lookup_plugins
    curl -fsSL -o ansible/lookup_plugins/proton_pass.py {{ ansible_proton_pass_plugin_url }}
