terraform-homelab/prepareEnv.sh

40 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
bw login
export BW_SESSION=$(bw unlock --raw)
bw sync
echo "Please wait while we prepare terraform.auto.tfvars"
proxmox_api_url=$(bw get --session $BW_SESSION uri proxmox_api)
proxmox_api_token_id=$(bw get --session $BW_SESSION username proxmox_api)
proxmox_api_token_secret=$(bw get --session $BW_SESSION password proxmox_api)
ci_user=$(bw get --session $BW_SESSION username ci_details)
ci_password=$(bw get --session $BW_SESSION password ci_details)
ssh_key=$(bw get --session $BW_SESSION notes ssh_public_key_main)
teams=$(bw get --session $BW_SESSION notes teams)
passphrase=$(bw get --session $BW_SESSION password state_passphrase)
tfusername=$(bw get --session $BW_SESSION username tofu_postgres)
tfpassword=$(bw get --session $BW_SESSION password tofu_postgres)
tfurl=$(bw get --session $BW_SESSION uri tofu_postgres)
echo 'proxmox_api_url = "'$proxmox_api_url'"' >> terraform.auto.tfvars
echo 'proxmox_api_token_id = "'$proxmox_api_token_id'"' >> terraform.auto.tfvars
echo 'proxmox_api_token_secret = "'$proxmox_api_token_secret'"' >> terraform.auto.tfvars
echo 'ci_user = "'$ci_user'"' >> terraform.auto.tfvars
echo 'ci_password = "'$ci_password'"' >> terraform.auto.tfvars
echo 'ssh_key = "'$ssh_key'"' >> terraform.auto.tfvars
echo 'teams = "'$teams'"' >> terraform.auto.tfvars
echo 'passphrase = "'$passphrase'"' >> terraform.auto.tfvars
echo 'tfusername = "'$tfusername'"' >> terraform.auto.tfvars
echo 'tfpassword = "'$tfpassword'"' >> terraform.auto.tfvars
echo 'tfurl = "'$tfurl'"' >> terraform.auto.tfvars
echo 'lxc_template = "debian-12-standard_12.7-1_amd64.tar.zst"' >> terraform.auto.tfvars