Page MenuHomeDevCentral

D3687.diff
No OneTemporary

D3687.diff

diff --git a/.editorconfig b/.editorconfig
--- a/.editorconfig
+++ b/.editorconfig
@@ -8,7 +8,7 @@
charset = utf-8
# 4 space indentation
-[*.{conf, php, py, sh}]
+[*.{conf,php,py,sh,hcl,tf}]
indent_style = space
indent_size = 4
diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,12 @@
*.pyc
*.pyo
+# Terraform
+.terraform/
+*.lock.hcl
+*.lock.info
+*.tfstate
+.tfvars
+
# Autogenerated content
roles/webserver-core/nginx/files/ocsp-ca-certs.pem
diff --git a/terraform/README.md b/terraform/README.md
new file mode 100644
--- /dev/null
+++ b/terraform/README.md
@@ -0,0 +1,69 @@
+# Terraform configurations
+
+This directory hosts all **Terraform / OpenTofu** infrastructure definitions
+that complement the Salt configuration in this repository.
+
+It allows automating provisioning of servers where Terraform providers
+are supported.
+
+## Scope
+
+Terraform is used to:
+ - deploy VM on **VMware ESXi** hosts
+
+It's intended, in combination with NetBox, to be used as a single source of
+truth for *infrastructure provisioning*.
+
+Terraform is not intended to:
+ - manage the configuration of the systems it provisions
+ - manage Docker containers — use roles/paas-docker/ with Salt
+ - manage DNS records — use roles/dns/ with Salt
+
+## Organization
+
+Terraform configurations are organized by provider.
+
+Each provider has its own directory, with subdirectories for each target,
+each with a `main.tf` file that defines the resources to be provisioned:
+
+ - vmware_esxi/ — VMware ESXi provider
+ - hyper-001/ — hypervisor
+
+## Usage
+
+From a `terraform/<provider>/<target>` directory, you can run `tofu` commands.
+For example:
+
+```sh
+cd vmware_esxi/hyper-001
+
+# Initialize providers and modules
+tofu init
+
+# Preview changes
+tofu plan
+
+# Apply changes
+tofu apply
+```
+
+## Providers
+
+At present, only **VMware ESXi virtual machines** are managed here.
+In the future, other providers may be added.
+
+### VMware ESXi
+
+Terraform configuration for VMware ESXi virtual machines, standalone.
+
+The `terraform/vmware_esxi/` directory uses the following provider:
+[`josenk/esxi`](https://registry.terraform.io/providers/josenk/esxi/latest)
+
+It allows provisioning of ESXi virtual machines, without vSphere/vCenter.
+
+## References
+
+You can find more information on:
+
+ - [OpenTofu Documentation](https://opentofu.org/docs/)
+ - [Terraform Language Documentation](https://developer.hashicorp.com/terraform/language)
diff --git a/terraform/vmware_esxi/hyper-001/dot.tfvars b/terraform/vmware_esxi/hyper-001/dot.tfvars
new file mode 100644
--- /dev/null
+++ b/terraform/vmware_esxi/hyper-001/dot.tfvars
@@ -0,0 +1,2 @@
+exsi_hostname=""
+exsi_password=""
diff --git a/terraform/vmware_esxi/hyper-001/main.tf b/terraform/vmware_esxi/hyper-001/main.tf
new file mode 100644
--- /dev/null
+++ b/terraform/vmware_esxi/hyper-001/main.tf
@@ -0,0 +1,40 @@
+# -------------------------------------------------------------
+# Terraform / OpenTofu — VM for hyper-001
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Provider: ESXi
+# Target: hyper-001.nasqueron.org
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# router-002
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+resource esxi_virtual_disk "router-002-disk" {
+ virtual_disk_dir = "router-002"
+ virtual_disk_disk_store = "datastore1"
+ virtual_disk_size = "24" # Gb
+ virtual_disk_name = "router-002.vmdk"
+}
+
+resource esxi_guest "router-002" {
+ disk_store = "datastore1"
+ guest_name = "router-002"
+
+ numvcpus = "4"
+ memsize = "2G"
+
+ virtual_disks {
+ virtual_disk_id = "router-002-disk"
+ }
+
+ network_interfaces {
+ virtual_network = "IntraNought"
+ }
+
+ network_interfaces {
+ virtual_network = "VM Network - Public"
+ mac_address = ""
+ }
+}
diff --git a/terraform/vmware_esxi/hyper-001/providers.tf b/terraform/vmware_esxi/hyper-001/providers.tf
new file mode 100644
--- /dev/null
+++ b/terraform/vmware_esxi/hyper-001/providers.tf
@@ -0,0 +1,23 @@
+# -------------------------------------------------------------
+# Terraform / OpenTofu — Providers
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+terraform {
+ required_providers {
+ esxi = {
+ source = "josenk/esxi"
+ version = "1.10.3"
+ }
+ }
+}
+
+provider "esxi" {
+ esxi_hostname = var.exsi_hostname
+ esxi_hostport = var.exsi_hostport
+ esxi_hostssl = var.hostssl
+ esxi_username = var.exsi_username
+ esxi_password = var.exsi_password
+}
diff --git a/terraform/vmware_esxi/hyper-001/variables.tf b/terraform/vmware_esxi/hyper-001/variables.tf
new file mode 100644
--- /dev/null
+++ b/terraform/vmware_esxi/hyper-001/variables.tf
@@ -0,0 +1,19 @@
+variable "exsi_hostname" {
+ default = "hyper-001.nasqueron.org"
+}
+
+variable "exsi_hostport" {
+ default = "22"
+}
+
+variable "hostssl" {
+ default = "443"
+}
+
+variable "exsi_username" {
+ default = ""
+}
+
+variable "exsi_password" {
+ default = ""
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Sep 19, 05:39 (19 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2995756
Default Alt Text
D3687.diff (5 KB)

Event Timeline