Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
ef0b91ae3d | |||
a202dc8ef3 | |||
a0fa66b93e | |||
071b71fa5c | |||
ad0287e0f3 | |||
b01508236b | |||
4b216b5807 | |||
0000e2a845 | |||
508014a73e | |||
19804dc890 | |||
e86b398d1b |
@ -16,9 +16,9 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- tflint --color
|
- tflint --color
|
||||||
|
|
||||||
- name: terraform
|
- name: tofu
|
||||||
image: docker.io/jmccann/drone-terraform:8
|
image: quay.io/thegeeklab/wp-opentofu
|
||||||
settings:
|
settings:
|
||||||
actions:
|
action:
|
||||||
- validate
|
- validate
|
||||||
tf_version: 1.5.0
|
tofu_version: 1.6.1
|
||||||
|
22
main.tf
22
main.tf
@ -1,3 +1,21 @@
|
|||||||
|
locals {
|
||||||
|
ipv4_addresses = {
|
||||||
|
for server_key, server in var.server : server.name => flatten([
|
||||||
|
for k, v in try(proxmox_virtual_environment_vm.server[server.name].ipv4_addresses, []) :
|
||||||
|
v if length(regexall(try(server.netif_filter, var.server_netif_filter), proxmox_virtual_environment_vm.server[server.name].network_interface_names[k])) > 0
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
ipv6_addresses = {
|
||||||
|
for server_key, server in var.server : server.name => flatten([
|
||||||
|
for k, v in try(proxmox_virtual_environment_vm.server[server.name].ipv6_addresses, []) :
|
||||||
|
v if length(regexall(try(server.netif_filter, var.server_netif_filter), proxmox_virtual_environment_vm.server[server.name].network_interface_names[k])) > 0
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resource "proxmox_virtual_environment_vm" "server" {
|
resource "proxmox_virtual_environment_vm" "server" {
|
||||||
for_each = { for row in var.server : row.name => row }
|
for_each = { for row in var.server : row.name => row }
|
||||||
|
|
||||||
@ -95,9 +113,7 @@ resource "restapi_object" "ucs_server" {
|
|||||||
"position" : var.ucs_zones[try(each.value.dns_zone, var.server_dns_zone)],
|
"position" : var.ucs_zones[try(each.value.dns_zone, var.server_dns_zone)],
|
||||||
"properties" : {
|
"properties" : {
|
||||||
"name" : each.value.name,
|
"name" : each.value.name,
|
||||||
"a" : concat(
|
"a" : concat(local.ipv4_addresses[each.key]),
|
||||||
[for k, v in flatten(proxmox_virtual_environment_vm.server[each.value.name].ipv4_addresses) : v if k != index(proxmox_virtual_environment_vm.server[each.value.name].network_interface_names, "lo")],
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
output "output" {
|
output "output" {
|
||||||
value = {
|
value = {
|
||||||
for server_key, server in proxmox_virtual_environment_vm.server : server_key => server
|
for server_key, server in proxmox_virtual_environment_vm.server : server_key => merge(
|
||||||
|
server,
|
||||||
|
{ ipv4_addresses = local.ipv4_addresses[server_key] },
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
variables.tf
29
variables.tf
@ -1,12 +1,4 @@
|
|||||||
// Proxmox VE
|
// Proxmox VE
|
||||||
# variable "pve_api_url" {
|
|
||||||
# type = string
|
|
||||||
# }
|
|
||||||
|
|
||||||
# variable "pve_api_token" {
|
|
||||||
# type = string
|
|
||||||
# }
|
|
||||||
|
|
||||||
variable "pve_ssh_keys" {
|
variable "pve_ssh_keys" {
|
||||||
type = list(string)
|
type = list(string)
|
||||||
}
|
}
|
||||||
@ -16,27 +8,11 @@ variable "pve_node_name" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cloudflare
|
// Cloudflare
|
||||||
variable "cloudflare_api_token" {
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "cloudflare_zones" {
|
variable "cloudflare_zones" {
|
||||||
type = any
|
type = any
|
||||||
}
|
}
|
||||||
|
|
||||||
// Univention
|
// Univention
|
||||||
variable "ucs_api_url" {
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "ucs_api_username" {
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "ucs_api_password" {
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "ucs_zones" {
|
variable "ucs_zones" {
|
||||||
type = any
|
type = any
|
||||||
}
|
}
|
||||||
@ -67,3 +43,8 @@ variable "server_guest_agent" {
|
|||||||
type = bool
|
type = bool
|
||||||
default = false
|
default = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "server_netif_filter" {
|
||||||
|
type = string
|
||||||
|
default = "^(eth|ens|enp).+"
|
||||||
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
terraform {
|
terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
cloudflare = {
|
cloudflare = {
|
||||||
source = "cloudflare/cloudflare"
|
source = "registry.opentofu.org/cloudflare/cloudflare"
|
||||||
}
|
}
|
||||||
proxmox = {
|
proxmox = {
|
||||||
source = "bpg/proxmox"
|
source = "registry.opentofu.org/bpg/proxmox"
|
||||||
}
|
}
|
||||||
restapi = {
|
restapi = {
|
||||||
source = "mastercard/restapi"
|
source = "registry.opentofu.org/thegeeklab/restapi"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user