-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
118 lines (103 loc) · 2.55 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
terraform {
required_providers {
proxmox = {
source = "registry.terraform.io/bpg/proxmox"
version = "0.60.1"
}
}
}
provider "proxmox" {
endpoint = "https://192.168.1.10:8006" # Proxmox IP
insecure = true
username = "root@pam"
password = "PASSWORD" # Promox root pasword
}
resource "proxmox_virtual_environment_file" "ubuntu_cloud_image" {
content_type = "iso"
datastore_id = "local"
node_name = "HomeLab" # Proxmox HomeLab name
source_file {
path = "iso/jammy-server-cloudimg-amd64.img"
# https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
}
}
# Ubuntu VM 1
resource "proxmox_virtual_environment_vm" "ubuntu_vm_1" {
name = "ubuntu-vm-1" # Hostname
node_name = "pve" # Proxmox pve name
vm_id = 250 # VM ID
cpu {
cores = 2
sockets = 2
type = "host"
numa = true
}
memory {
dedicated = 2048
}
initialization {
ip_config {
ipv4 {
address = "192.168.1.12/24"
gateway = "192.168.1.1"
}
}
user_account {
username = "ubuntu" # Username
password = "ubuntu" # Password
keys = [ "ssh-public-key" ] # SSH key
}
}
disk {
datastore_id = "local-lvm"
file_id = proxmox_virtual_environment_file.ubuntu_cloud_image.id
interface = "virtio0"
iothread = true
discard = "on"
size = 96 # Disk Size GB
}
network_device {
bridge = "vmbr0"
}
}
# Ubuntu VM 1
# Ubuntu VM 2
resource "proxmox_virtual_environment_vm" "ubuntu_vm_2" {
name = "ubuntu-vm-2" # Hostname
node_name = "pve" # Proxmox pve name
vm_id = 260
cpu {
cores = 2
sockets = 2
type = "host"
numa = true
}
memory {
dedicated = 2048
}
initialization {
ip_config {
ipv4 {
address = "192.168.1.12/24"
gateway = "192.168.1.1"
}
}
user_account {
username = "ubuntu" # Username
password = "ubuntu" # Password
keys = [ "ssh-rsa" ] # SSH key
}
}
disk {
datastore_id = "local-lvm"
file_id = proxmox_virtual_environment_file.ubuntu_cloud_image.id
interface = "virtio0"
iothread = true
discard = "on"
size = 96 # Disk Size GB
}
network_device {
bridge = "vmbr0"
}
}
# Ubuntu VM 2