Giter Club home page Giter Club logo

proxmox-vm's Introduction

stuttgart-things/proxmox-vm

Terraform module for creating proxmox vms

EXAMPLE USAGE TERRAFORM

CREATE PVE VM
# CALL MODULE - main.tf
# main.tf
module "proxmox-vm" {
  source                  = "git::https://github.com/stuttgart-things/proxmox-vm.git"
  pve_api_url             = var.pve_api_url
  pve_api_user            = var.pve_api_user
  pve_api_password        = var.pve_api_password
  pve_api_tls_verify      = var.pve_api_tls_verify

  pve_cluster_node        = "sthings-pve1"
  pve_datastore           = "datastore"
  pve_folder_path         = "stuttgart-things"
  pve_network             = "vmbr101"
  vm_count                = 1
  vm_name                 = "vm-test-name"
  vm_notes                = "vm-info"
  vm_template             = "ubuntu22"
  vm_num_cpus             = "4"
  vm_memory               = "4096"
  vm_disk_size            = "32G"
  vm_ssh_user             = var.vm_ssh_user
  vm_ssh_password         = var.vm_ssh_password
}

output "ip" {
  value     = module.proxmox-vm.ip
}

output "mac" {
  value     = module.proxmox-vm.mac
}

output "id" {
  value     = module.proxmox-vm.id
}


variable "pve_api_url" {
  description = "url of proxmox api. Example: https://server-example.sva.de:8006/api2/json"
}
 
variable "pve_api_user" {
  description = "username of proxmox api user"
}
 
variable "pve_api_password" {
  description = "password of proxmox api user"
}
 
variable "vm_ssh_user" {
  description = "desired username for ssh connection"
}
 
variable "vm_ssh_password" {
  description = "desired password for ssh connection"
}
 
variable "pve_api_tls_verify" {
  description = "proxmox API disable check if cert is valid"
}
# VARIABLES -tfvars
pve_api_url="<API-URL>"  
pve_api_user="<API-USER>"
pve_api_password="<API-PASSWORD>"
pve_api_tls_verify = true
vm_ssh_user="<SSH-USER>"
vm_ssh_password="<SSH-PASSWORD>"
EXECUTION
terraform init
terraform apply
terraform destroy

EXAMPLE USAGE CROSSPLANE

TFVARS (SECRETS)
pve_api_url="<API-URL>"
pve_api_user="<API-USER>"
pve_api_password="<API-PASSWORD>"
vm_ssh_user="<SSH-USER>"
vm_ssh_password="<SSH-PASSWORD>"
kubectl create secret generic pve-tfvars --from-file=terraform.tfvars
WORKSPACE
---
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
  name: appserver
  annotations:
    crossplane.io/external-name: pve-vm
spec:
  providerConfigRef:
    name: terraform-default
  forProvider:
    source: Remote
    module: git::https://github.com/stuttgart-things/proxmox-vm.git?ref=v2.9.14-1.5.5
    vars:
      - key: vm_count
        value: "1"
      - key: vm_num_cpus
        value: "4"
      - key: vm_memory
        value: "4096"
      - key: vm_name
        value: appserver
      - key: vm_template
        value: ubuntu22
      - key: pve_network
        value: vmbr103
      - key: pve_datastore
        value: v3700
      - key: vm_disk_size
        value: 128G
      - key: pve_folder_path
        value: stuttgart-things
      - key: pve_cluster_node
        value: sthings-pve1
    varFiles:
      - source: SecretKey
        secretKeyRef:
          namespace: default
          name: pve-tfvars
          key: terraform.tfvars
  writeConnectionSecretToRef:
    namespace: default
    name: terraform-workspace-appserver

OUTPUTS

  • ip - ip address of created vm
  • mac - mac address of created vm
  • id - proxmox id of created vm

License

BSD

Author Information

Marcel Zapf; 09/2021; Stuttgart-Things

proxmox-vm's People

Contributors

anacalva avatar patrick-hermann-sva avatar syntax3rror404 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.