Coder Social home page Coder Social logo

rodrigomatto / terraform-proxmox-provisioning Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10 KB

A Terraform project to automate the provisioning of virtual machines in Proxmox, based on cloud-init images from Ubuntu templates. This repository includes Terraform configurations and scripts to create and configure VMs in Proxmox, as well as steps to generate your own CI template

HCL 100.00%

terraform-proxmox-provisioning's Introduction

Terraform Proxmox Provisioning

The Terraform Proxmox Provisioning project is designed to automate the creation and configuration of virtual machines on a Proxmox server using Terraform. This setup allows for the provisioning of VMs with static IP addresses, custom node names, and gateway configurations, making it suitable for deploying Kubernetes clusters or other environments.

Features

  • Automated VM Provisioning: Create and configure VMs on Proxmox with Terraform.
  • Static IP Configuration: Assign static IPs to VMs based on their names.
  • Customizable Nodes: Easily modify node names, static IPs, and gateways.

Prerequisites

Before using this project, ensure you have the following prerequisites installed and configured:

  • Proxmox server
  • Terraform
  • Cloud-init template

For detailed steps on generating your own cloud-init template, and more in deep configuration of this project, please refer to the first part of my blog post*.

*The blog will be published tomorrow :D If it's not, please come back and read this part again.

Configuration

Before provisioning the VMs, you need to configure the environment variables and modify the variables.tf and main.tf files according to your setup.

Environment variables

Set the following environment variables:

  • PM_API_URL: The URL of your Proxmox API.
  • PM_TOKEN_ID: Your Proxmox token ID.
  • PM_TOKEN_SECRET: Your Proxmox token secret.
  • SSH_KEY: The SSH key for accessing the VMs.

Example:

export TF_VAR_pm_api_url=https://proxmox.example.com:8006/api2/json
export TF_VAR_pm_api_token_id=your_token_id
export TF_VAR_pm_api_token_secret=your_token_secret
export TF_VAR_ssh_key=$(cat ~/.ssh/id_rsa.pub)

Modify variables.tf

Update the variables.tf file to set up your node names, static IPs, and gateway:

variable "nodes_ips" {
  description = "Map of VM names to their static IP addresses"
  type        = map(string)
  default     = {
    master-01  = "192.168.100.151"  // Change
    worker-01  = "192.168.100.152"  // those
    worker-02  = "192.168.100.153"  // values
  }
}

variable "nodes_gw" {
  description = "Gateway IP for the network"
  type        = string
  default     = "192.168.100.1"     // This one too
}

You can add or remove as many nodes as you want here, terraform will handle it.

Verify and modify main.tf

Ensure that the main.tf file matches your Proxmox server's storage and network configurations. Verify and modify the storage and network sections as needed. For example, if your storage is local or local-lvm and the network interface is vmbr0, ensure these are correctly specified:

# Storage
    disks {
      scsi {
        scsi0 {
          disk {
            size     = "32G"
            storage  = "local"  // Check this storage 
            format   = "qcow2"
          }
        }
      }
      ide {
        ide2 {
          cloudinit {
            storage = "local"   // this one too
          }
        }
      }
    }

# Networking

  network {
    model  = "virtio"
    bridge = "vmbr0"            // and the bridge you are using
  }

Usage

To provision the VMs, once you have cloned the repository and configured your enviroment variables, follow these steps:

cd terraform-proxmox-provisioning

Initialize Terraform:

terraform init

Apply the Terraform configuration:

terraform apply

Review the plan and confirm to proceed with the provisioning.

Disclaimer

This project is intended for testing purposes only and should not be used in a production environment as is.

Additional Resources

For more information on using Proxmox with Terraform, refer to the official documentation:

Telmante Proxmox Terraform Provider

terraform-proxmox-provisioning's People

Contributors

rodrigomatto avatar

Watchers

 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.