Compare commits

...

9 Commits
v1.0.0 ... main

Author SHA1 Message Date
ef0b91ae3d fix: use try to set default for server list (#7)
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build-package Pipeline was successful
Reviewed-on: #7
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
Co-committed-by: Robert Kaussow <mail@thegeeklab.de>
2024-04-11 15:52:04 +02:00
a202dc8ef3 fix: use include match for server_netif_filter (#6)
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build-package Pipeline was successful
Reviewed-on: #6
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
Co-committed-by: Robert Kaussow <mail@thegeeklab.de>
2024-03-26 21:22:53 +01:00
a0fa66b93e feat: add var server_netif_filter to overwrite interface filter (#5)
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build-package Pipeline was successful
Reviewed-on: #5
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
Co-committed-by: Robert Kaussow <mail@thegeeklab.de>
2024-03-22 12:06:02 +01:00
071b71fa5c fix: use ip address map indexed by server key (#4)
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build-package Pipeline was successful
Reviewed-on: #4
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
Co-committed-by: Robert Kaussow <mail@thegeeklab.de>
2024-03-20 22:45:08 +01:00
ad0287e0f3 fix: add filter to remove loopback and overlay networks from ip lists (#3)
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/tag/build-package Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
Reviewed-on: #3
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
Co-committed-by: Robert Kaussow <mail@thegeeklab.de>
2024-03-17 12:07:50 +01:00
b01508236b Merge pull request 'chore: use opentofu and replace restapi provider' (#2) from use-tofu into main
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build-package Pipeline was successful
Reviewed-on: #2
2024-03-14 20:56:54 +01:00
4b216b5807
fix ci syntax
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build-package Pipeline was successful
2024-03-14 20:56:00 +01:00
0000e2a845
chore: use opentofu and replace restapi provider
Some checks failed
ci/woodpecker/pr/build-package unknown status
ci/woodpecker/pr/test Pipeline failed
2024-03-14 20:54:45 +01:00
508014a73e
fix: revert description handling
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful
ci/woodpecker/tag/build-package Pipeline was successful
2024-01-22 22:20:47 +01:00
5 changed files with 36 additions and 15 deletions

View File

@ -16,9 +16,9 @@ steps:
commands:
- tflint --color
- name: terraform
image: docker.io/jmccann/drone-terraform:8
- name: tofu
image: quay.io/thegeeklab/wp-opentofu
settings:
actions:
action:
- validate
tf_version: 1.5.0
tofu_version: 1.6.1

27
main.tf
View File

@ -1,8 +1,26 @@
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" {
for_each = { for row in var.server : row.name => row }
name = "${each.value.name}.${try(each.value.dns_zone, var.server_dns_zone)}"
description = try(each.value.description, " ")
description = try(each.value.description, null)
tags = concat(
[
"provisioner_terraform",
@ -95,12 +113,7 @@ resource "restapi_object" "ucs_server" {
"position" : var.ucs_zones[try(each.value.dns_zone, var.server_dns_zone)],
"properties" : {
"name" : each.value.name,
"a" : concat(
[
for k, v in flatten(coalesce(proxmox_virtual_environment_vm.server[each.value.name].ipv4_addresses, [])) :
v if k != try(index(proxmox_virtual_environment_vm.server[each.value.name].network_interface_names, "lo"), -1)
],
),
"a" : concat(local.ipv4_addresses[each.key]),
}
})
}

View File

@ -1,5 +1,8 @@
output "output" {
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] },
)
}
}

View File

@ -43,3 +43,8 @@ variable "server_guest_agent" {
type = bool
default = false
}
variable "server_netif_filter" {
type = string
default = "^(eth|ens|enp).+"
}

View File

@ -1,13 +1,13 @@
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
source = "registry.opentofu.org/cloudflare/cloudflare"
}
proxmox = {
source = "bpg/proxmox"
source = "registry.opentofu.org/bpg/proxmox"
}
restapi = {
source = "mastercard/restapi"
source = "registry.opentofu.org/thegeeklab/restapi"
}
}
}