https://github.com/rgl/terraform-proxmox-windows-example
example on how to launch a windows vm using terraform in proxmox
https://github.com/rgl/terraform-proxmox-windows-example
proxmox terraform windows
Last synced: over 1 year ago
JSON representation
example on how to launch a windows vm using terraform in proxmox
- Host: GitHub
- URL: https://github.com/rgl/terraform-proxmox-windows-example
- Owner: rgl
- Created: 2023-11-25T17:17:08.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-22T06:12:43.000Z (over 1 year ago)
- Last Synced: 2024-12-31T11:06:16.683Z (over 1 year ago)
- Topics: proxmox, terraform, windows
- Language: HCL
- Homepage:
- Size: 67.4 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Usage (from a Ubuntu 22.04 host)
[](https://github.com/rgl/terraform-proxmox-windows-example/actions/workflows/lint.yml)
Create and install the [base Windows 2022 UEFI template](https://github.com/rgl/windows-vagrant).
Install Terraform:
```bash
# see https://github.com/hashicorp/terraform/releases
# renovate: datasource=github-releases depName=hashicorp/terraform
terraform_version='1.9.8'
wget "https://releases.hashicorp.com/terraform/$terraform_version/terraform_${$terraform_version}_linux_amd64.zip"
unzip "terraform_${$terraform_version}_linux_amd64.zip"
sudo install terraform /usr/local/bin
rm terraform terraform_*_linux_amd64.zip
```
Set your proxmox details:
```bash
# see https://registry.terraform.io/providers/bpg/proxmox/latest/docs#argument-reference
# see https://github.com/bpg/terraform-provider-proxmox/blob/v0.67.1/proxmoxtf/provider/provider.go#L50-L59
cat >secrets-proxmox.sh <<'EOF'
unset HTTPS_PROXY
#export HTTPS_PROXY='http://localhost:8080'
export TF_VAR_proxmox_pve_node_address='192.168.1.21'
export PROXMOX_VE_INSECURE='1'
export PROXMOX_VE_ENDPOINT="https://$TF_VAR_proxmox_pve_node_address:8006"
export PROXMOX_VE_USERNAME='root@pam'
export PROXMOX_VE_PASSWORD='vagrant'
EOF
source secrets-proxmox.sh
```
Create the infrastructure:
```bash
export CHECKPOINT_DISABLE='1'
export TF_LOG='DEBUG' # TRACE, DEBUG, INFO, WARN or ERROR.
export TF_LOG_PATH='terraform.log'
terraform init
terraform plan -out=tfplan
time terraform apply tfplan
```
Login into the machine using SSH:
```bash
ssh-keygen -f ~/.ssh/known_hosts -R "$(terraform output --raw ip)"
ssh "vagrant@$(terraform output --raw ip)"
exit # ssh
```
Login into the machine using PowerShell Remoting over SSH:
```bash
pwsh
Enter-PSSession -HostName "vagrant@$(terraform output --raw ip)"
$PSVersionTable
whoami /all
exit # Enter-PSSession
exit # pwsh
```
Destroy the infrastructure:
```bash
time terraform destroy -auto-approve
```
List this repository dependencies (and which have newer versions):
```bash
export GITHUB_COM_TOKEN='YOUR_GITHUB_PERSONAL_TOKEN'
./renovate.sh
```