Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec6132a0e9 | ||
|
|
b7542e9e23 | ||
|
|
3f81d42e1a | ||
|
|
b7a5e94c9d |
@@ -1,50 +0,0 @@
|
||||
name: Terraform CI
|
||||
run-name: ${{ gitea.actor }} triggered a Terraform CI
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
terraform:
|
||||
runs-on: infra-terraform
|
||||
|
||||
container:
|
||||
volumes:
|
||||
- /srv/terraform-state/proxmox-prod:/srv/terraform-state/proxmox-prod"
|
||||
defaults:
|
||||
run:
|
||||
working-directory: stacks/prod/proxmox
|
||||
|
||||
env:
|
||||
# TODO: migrate to Openbao
|
||||
PROXMOX_VE_ENDPOINT: ${{ secrets.PROXMOX_VE_ENDPOINT }}
|
||||
PROXMOX_VE_API_TOKEN: ${{ secrets.PROXMOX_VE_API_TOKEN }}
|
||||
PROXMOX_VE_SSH_PRIVATE_KEY: ${{ secrets.PROXMOX_VE_SSH_PRIVATE_KEY }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Terraform
|
||||
uses: hashicorp/setup-terraform@v3
|
||||
with:
|
||||
terraform_version: 1.13.3
|
||||
|
||||
# Job will fail if you didn't run `terraform fmt -recursive`
|
||||
- name: Check formatting
|
||||
run: terraform fmt -check -recursive
|
||||
|
||||
- name: Initialize Terraform modules
|
||||
run: terraform init
|
||||
|
||||
- name: Validate Terraform
|
||||
run: terraform validate
|
||||
|
||||
- name: Create Terraform plan
|
||||
run: terraform plan -out=tfplan
|
||||
|
||||
# Job will apply the plan if pushed to main
|
||||
- name: Conditionally apply the Terraform plan
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
run: terraform apply -auto-approve tfplan
|
||||
|
||||
@@ -10,8 +10,8 @@ To run `terraform` commands, you must define `proxmox_api_token` and `proxmox_en
|
||||
|
||||
```
|
||||
# ./proxmox_node_name/secrets.tfvars
|
||||
proxmox_api_token=terraform@pve!terraform=...
|
||||
proxmox_endpoint=192.168.30.10:8006 # fishburne's IP + Proxmox port
|
||||
proxmox_api_token="terraform@pve!terraform=..."
|
||||
proxmox_endpoint="192.168.30.10:8006" # fishburne's IP + Proxmox port
|
||||
```
|
||||
|
||||
## Importing an existing Proxmox resource to Terraform
|
||||
|
||||
@@ -64,7 +64,10 @@ resource "proxmox_virtual_environment_container" "this" {
|
||||
|
||||
lifecycle {
|
||||
prevent_destroy = true
|
||||
ignore_changes = [operating_system]
|
||||
ignore_changes = [
|
||||
disk,
|
||||
operating_system
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ variable "is_network_interface" {
|
||||
|
||||
variable "network_interface_mac_address" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "network_interface_name" {
|
||||
|
||||
@@ -12,6 +12,7 @@ resource "proxmox_virtual_environment_vm" "this" {
|
||||
# Ignore the following changes:
|
||||
ignore_changes = [
|
||||
initialization,
|
||||
disk
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
@@ -107,6 +107,28 @@ module "hockeypuck" {
|
||||
network_interface_mac_address = "BC:24:11:82:60:4E"
|
||||
}
|
||||
|
||||
module "operator-parker" {
|
||||
source = "../../../modules/proxmox-ct"
|
||||
|
||||
description = "operator"
|
||||
ct_id = 116
|
||||
proxmox_node_name = "parker"
|
||||
|
||||
is_unprivileged = true
|
||||
|
||||
disk_size = 32
|
||||
|
||||
cpu_cores = 2
|
||||
|
||||
ct_hostname = "operator"
|
||||
ip_address = "192.168.30.76/24"
|
||||
ip_gateway = "192.168.30.1"
|
||||
|
||||
dedicated_memory = 1024
|
||||
|
||||
# network_interface_mac_address = "BC:24:11:76:06:C3"
|
||||
}
|
||||
|
||||
########## CHONG ##########
|
||||
module "keymaker" {
|
||||
source = "../../../modules/proxmox-vm"
|
||||
@@ -222,6 +244,26 @@ module "ejabberd" {
|
||||
network_interface_mac_address = "BC:24:11:E2:58:45"
|
||||
}
|
||||
|
||||
module "constructor" {
|
||||
source = "../../../modules/proxmox-ct"
|
||||
|
||||
description = "builder"
|
||||
ct_id = 117
|
||||
proxmox_node_name = "chong"
|
||||
|
||||
is_unprivileged = true
|
||||
|
||||
disk_size = 16
|
||||
|
||||
cpu_cores = 2
|
||||
|
||||
ct_hostname = "constructor"
|
||||
ip_address = "192.168.30.66/24"
|
||||
ip_gateway = "192.168.30.1"
|
||||
|
||||
dedicated_memory = 1024
|
||||
}
|
||||
|
||||
########## FISHBURNE ##########
|
||||
module "operator" {
|
||||
source = "../../../modules/proxmox-ct"
|
||||
@@ -234,7 +276,7 @@ module "operator" {
|
||||
|
||||
disk_datastore_id = "backup-storage"
|
||||
|
||||
disk_size = 16
|
||||
disk_size = 32
|
||||
|
||||
cpu_cores = 2
|
||||
|
||||
@@ -245,6 +287,8 @@ module "operator" {
|
||||
dedicated_memory = 1024
|
||||
|
||||
network_interface_mac_address = "BC:24:11:76:06:C3"
|
||||
|
||||
is_keyctl = true
|
||||
}
|
||||
|
||||
module "bluepill" {
|
||||
|
||||
@@ -6,7 +6,7 @@ provider "proxmox" {
|
||||
endpoint = "https://192.168.30.70:8006"
|
||||
|
||||
# API token authentication (through environment variables)
|
||||
# api_token = var.proxmox_api_token
|
||||
api_token = var.proxmox_api_token
|
||||
|
||||
# Accept self-signed certificates (TODO: change in the future if necessary)
|
||||
insecure = true
|
||||
@@ -14,10 +14,9 @@ provider "proxmox" {
|
||||
# Allow SSH connections for certain operations (like uploading ISO files)
|
||||
# https://registry.terraform.io/providers/bpg/proxmox/latest/docs#ssh-connection
|
||||
ssh {
|
||||
agent = false
|
||||
username = "svc-terraform"
|
||||
# Read directly from PROXMOX_VE_SSH_PRIVATE_KEY env variable (in Gitea CI/CD)
|
||||
# private_key = file("/home/svc-terraform/.ssh/id_rsa")
|
||||
agent = false
|
||||
username = "svc-terraform"
|
||||
private_key = file("/home/svc-terraform/.ssh/id_rsa")
|
||||
# port = 22
|
||||
node {
|
||||
name = "parker"
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
# Comment out only if you need to pass it in as a variable when running not through CI/CD
|
||||
# Should not be the norm!!!!
|
||||
variable "proxmox_endpoint" {
|
||||
description = "Proxmox HTTPS API endpoint (including the port 8006)."
|
||||
type = string
|
||||
}
|
||||
|
||||
# variable "proxmox_endpoint" {
|
||||
# description = "Proxmox HTTPS API endpoint (including the port 8006)."
|
||||
# type = string
|
||||
# }
|
||||
#
|
||||
# variable "proxmox_api_token" {
|
||||
# description = "The API token for Proxmox authentication in the form user@realm!tokenid=token-value"
|
||||
# type = string
|
||||
# sensitive = true # Don't show in console outputs
|
||||
# }
|
||||
variable "proxmox_api_token" {
|
||||
description = "The API token for Proxmox authentication in the form user@realm!tokenid=token-value"
|
||||
type = string
|
||||
sensitive = true # Don't show in console outputs
|
||||
}
|
||||
|
||||
# variable "username" {
|
||||
# type = string
|
||||
|
||||
Reference in New Issue
Block a user