feat: load tailscale oauth credential for edge bootstrap
This commit is contained in:
parent
4e9631dc71
commit
8fa9ae3c0e
|
|
@ -183,6 +183,7 @@ set -eu
|
||||||
install_dir="${self.triggers.install_dir}"
|
install_dir="${self.triggers.install_dir}"
|
||||||
install_docker="${self.triggers.install_docker}"
|
install_docker="${self.triggers.install_docker}"
|
||||||
tailscale_auth_key='${var.edge_tailscale_auth_key}'
|
tailscale_auth_key='${var.edge_tailscale_auth_key}'
|
||||||
|
tailscale_tag='${var.edge_tailscale_tag}'
|
||||||
server_name="${self.triggers.server_name}"
|
server_name="${self.triggers.server_name}"
|
||||||
server_names="${self.triggers.server_names}"
|
server_names="${self.triggers.server_names}"
|
||||||
certbot_domain_args="${self.triggers.certbot_domain_args}"
|
certbot_domain_args="${self.triggers.certbot_domain_args}"
|
||||||
|
|
@ -227,7 +228,7 @@ if ! tailscale ip -4 >/dev/null 2>&1; then
|
||||||
echo "Tailscale is not connected on the edge VM. Set LAB_EDGE_TAILSCALE_AUTH_KEY for a fresh edge bootstrap." >&2
|
echo "Tailscale is not connected on the edge VM. Set LAB_EDGE_TAILSCALE_AUTH_KEY for a fresh edge bootstrap." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sudo tailscale up --auth-key "$tailscale_auth_key" --hostname homelab-oci-edge --accept-routes
|
sudo tailscale up --auth-key "$tailscale_auth_key" --hostname homelab-oci-edge --advertise-tags "$tailscale_tag" --accept-routes
|
||||||
fi
|
fi
|
||||||
if ! tailscale ip -4 >/dev/null 2>&1; then
|
if ! tailscale ip -4 >/dev/null 2>&1; then
|
||||||
echo "Tailscale did not obtain an IPv4 address on the edge VM." >&2
|
echo "Tailscale did not obtain an IPv4 address on the edge VM." >&2
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,12 @@ variable "edge_tailscale_auth_key" {
|
||||||
default = ""
|
default = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "edge_tailscale_tag" {
|
||||||
|
description = "Tailscale tag to advertise when joining a recreated OCI edge VM."
|
||||||
|
type = string
|
||||||
|
default = "tag:homelab-edge"
|
||||||
|
}
|
||||||
|
|
||||||
variable "edge_install_docker" {
|
variable "edge_install_docker" {
|
||||||
type = bool
|
type = bool
|
||||||
default = false
|
default = false
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,15 @@ export_homelab_inventory_tf_vars() {
|
||||||
export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}"
|
export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}"
|
||||||
export_if_unset TF_VAR_edge_user "${LAB_EDGE_USER:-}"
|
export_if_unset TF_VAR_edge_user "${LAB_EDGE_USER:-}"
|
||||||
export_if_unset TF_VAR_edge_install_dir "${LAB_EDGE_INSTALL_DIR:-}"
|
export_if_unset TF_VAR_edge_install_dir "${LAB_EDGE_INSTALL_DIR:-}"
|
||||||
export_if_unset TF_VAR_edge_tailscale_auth_key "${LAB_EDGE_TAILSCALE_AUTH_KEY:-}"
|
local edge_tailscale_auth_key="${LAB_EDGE_TAILSCALE_AUTH_KEY:-}"
|
||||||
|
if [[ -z "${edge_tailscale_auth_key}" ]]; then
|
||||||
|
local edge_tailscale_credentials_file="${LAB_EDGE_TAILSCALE_OAUTH_CREDENTIAL_FILE:-${HOME}/tailscaled.txt}"
|
||||||
|
if [[ -r "${edge_tailscale_credentials_file}" ]]; then
|
||||||
|
edge_tailscale_auth_key="$(sed -n 's/^secret:[[:space:]]*//p' "${edge_tailscale_credentials_file}" | head -n 1)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
export_if_unset TF_VAR_edge_tailscale_auth_key "${edge_tailscale_auth_key}"
|
||||||
|
export_if_unset TF_VAR_edge_tailscale_tag "${LAB_EDGE_TAILSCALE_TAG:-tag:homelab-edge}"
|
||||||
export_if_unset TF_VAR_server_name "${LAB_DOMAIN:-}"
|
export_if_unset TF_VAR_server_name "${LAB_DOMAIN:-}"
|
||||||
export_if_unset TF_VAR_additional_server_names "${LAB_ADDITIONAL_SERVER_NAMES_JSON:-}"
|
export_if_unset TF_VAR_additional_server_names "${LAB_ADDITIONAL_SERVER_NAMES_JSON:-}"
|
||||||
export_if_unset TF_VAR_jeannie_api_metrics_target "${LAB_JEANNIE_API_METRICS_TARGET:-api.${LAB_DOMAIN:-lab2025.duckdns.org}:443}"
|
export_if_unset TF_VAR_jeannie_api_metrics_target "${LAB_JEANNIE_API_METRICS_TARGET:-api.${LAB_DOMAIN:-lab2025.duckdns.org}:443}"
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,15 @@ export_homelab_inventory_tf_vars() {
|
||||||
export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}"
|
export_if_unset TF_VAR_edge_host "${LAB_EDGE_HOST:-}"
|
||||||
export_if_unset TF_VAR_edge_user "${LAB_EDGE_USER:-}"
|
export_if_unset TF_VAR_edge_user "${LAB_EDGE_USER:-}"
|
||||||
export_if_unset TF_VAR_edge_install_dir "${LAB_EDGE_INSTALL_DIR:-}"
|
export_if_unset TF_VAR_edge_install_dir "${LAB_EDGE_INSTALL_DIR:-}"
|
||||||
export_if_unset TF_VAR_edge_tailscale_auth_key "${LAB_EDGE_TAILSCALE_AUTH_KEY:-}"
|
local edge_tailscale_auth_key="${LAB_EDGE_TAILSCALE_AUTH_KEY:-}"
|
||||||
|
if [[ -z "${edge_tailscale_auth_key}" ]]; then
|
||||||
|
local edge_tailscale_credentials_file="${LAB_EDGE_TAILSCALE_OAUTH_CREDENTIAL_FILE:-${HOME}/tailscaled.txt}"
|
||||||
|
if [[ -r "${edge_tailscale_credentials_file}" ]]; then
|
||||||
|
edge_tailscale_auth_key="$(sed -n 's/^secret:[[:space:]]*//p' "${edge_tailscale_credentials_file}" | head -n 1)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
export_if_unset TF_VAR_edge_tailscale_auth_key "${edge_tailscale_auth_key}"
|
||||||
|
export_if_unset TF_VAR_edge_tailscale_tag "${LAB_EDGE_TAILSCALE_TAG:-tag:homelab-edge}"
|
||||||
export_if_unset TF_VAR_server_name "${LAB_DOMAIN:-}"
|
export_if_unset TF_VAR_server_name "${LAB_DOMAIN:-}"
|
||||||
export_if_unset TF_VAR_additional_server_names "${LAB_ADDITIONAL_SERVER_NAMES_JSON:-}"
|
export_if_unset TF_VAR_additional_server_names "${LAB_ADDITIONAL_SERVER_NAMES_JSON:-}"
|
||||||
export_if_unset TF_VAR_jeannie_api_metrics_target "${LAB_JEANNIE_API_METRICS_TARGET:-api.${LAB_DOMAIN:-lab2025.duckdns.org}:443}"
|
export_if_unset TF_VAR_jeannie_api_metrics_target "${LAB_JEANNIE_API_METRICS_TARGET:-api.${LAB_DOMAIN:-lab2025.duckdns.org}:443}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue