-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
103 lines (91 loc) · 3.91 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
terraform {
required_providers {
proxmox = {
source = "Telmate/proxmox"
version = "~> 2.9.0"
}
}
}
provider "proxmox" {
pm_api_url = var.pve_api_url
pm_api_token_id = var.pve_token_id
pm_api_token_secret = var.pve_token_secret
}
# Create Single Container
module "lxc_minimal_config" {
source = "github.com/trfore/terraform-telmate-proxmox//modules/lxc"
node = "pve" # Required
lxc_id = 100 # Required
os_template = "local:vztmpl/ubuntu-20.04-standard_20.04-1_amd64.tar.gz" # Required
os_type = "ubuntu" # Optional, recommended
user_ssh_key_public = "~/.ssh/id_ed25519.pub" # Optional, recommended
}
output "id" {
value = module.lxc_minimal_config.id
}
output "mac_address" {
value = module.lxc_minimal_config.mac_address
}
# Create Multiple Containers
module "lxc_multiple_config" {
source = "github.com/trfore/terraform-telmate-proxmox//modules/lxc"
for_each = tomap({
"lxc-example-01" = {
id = 101
},
"lxc-example-02" = {
id = 102
},
})
node = "pve" # Required
lxc_id = each.value.id # Required
lxc_name = each.key # Optional
os_template = "local:vztmpl/ubuntu-20.04-standard_20.04-1_amd64.tar.gz" # Required
os_type = "ubuntu" # Optional, recommended
user_ssh_key_public = "~/.ssh/id_ed25519.pub" # Optional, recommended
}
# Create Single LXC with Static IP Address
module "lxc_static_ip_config" {
source = "github.com/trfore/terraform-telmate-proxmox//modules/lxc"
node = "pve" # Required
lxc_id = 103 # Required
lxc_name = "lxc-example-static-ip" # Optional
description = "terraform provisioned on ${timestamp()}" # Optional
os_template = "local:vztmpl/ubuntu-20.04-standard_20.04-1_amd64.tar.gz" # Required
os_type = "ubuntu" # Optional, recommended
user_ssh_key_public = "~/.ssh/id_ed25519.pub" # Optional, recommended
start_on_create = true
start_on_boot = true
startup_options = "order=1,up=30,down=30"
vlan_tag = "1"
ipv4_address = "192.168.1.103/24"
ipv4_gateway = "192.168.1.1"
}
# Create Single LXC with Additional Mountpoints
module "vm_mountpoint_config" {
source = "github.com/trfore/terraform-telmate-proxmox//modules/lxc"
node = "pve" # Required
lxc_id = 104 # Required
lxc_name = "lxc-example-mountpoints" # Optional
os_template = "local:vztmpl/ubuntu-20.04-standard_20.04-1_amd64.tar.gz" # Required
os_type = "ubuntu" # Optional, recommended
user_ssh_key_public = "~/.ssh/id_ed25519.pub" # Optional, recommended
mountpoint = [
{
mp = "/mnt/local"
mp_size = "4G"
mp_slot = 0
mp_key = "0"
mp_storage = "local-lvm"
mp_volume = null
mp_backup = true
},
{
mp = "/mnt/configs"
mp_size = "4G"
mp_slot = 1
mp_key = "1"
mp_storage = "local-lvm"
}
]
}