🎨 add testing and put as optional many varaibles

This commit is contained in:
2024-07-30 15:52:05 +01:00
parent 05fc32f18a
commit 89c5666074
5 changed files with 946 additions and 229 deletions
+22 -9
View File
@@ -5,24 +5,23 @@ terraform {
variable "nginx_sites" {
type = map(object({
service = string
proxy_cache = bool
extra-value = string
extra_value_bool = bool
http2_bool = bool
proxy_pass_https = bool
authentication_required = bool
enabled = optional(bool,true)
proxy_cache = optional(bool,false)
extra-value = optional(string,"")
http2_bool = optional(bool,false)
proxy_pass_https = optional(bool,false)
authentication_required = optional(bool,false)
}))
}
resource "local_file" "nginx"{
for_each = var.nginx_sites
# for_each = var.nginx_sites
for_each = { for key, value in var.nginx_sites : key => value if value.enabled == true}
content = templatefile("nginx_config.tftpl", {
name_site = each.key
name_service = each.value.service
proxy_cache = each.value.proxy_cache
extra_value_bool = each.value.extra_value_bool
extra-value = each.value.extra-value
http2_bool = each.value.http2_bool
proxy_pass_https = each.value.proxy_pass_https
@@ -30,5 +29,19 @@ resource "local_file" "nginx"{
})
filename = "../conf.d/${each.key}.tryton.geeraert.eu.conf"
file_permission = "0600"
provisioner "local-exec" {
command = "kubectl exec -it deploy/reverse-proxy -n reverse-proxy -- nginx -s reload"
quiet = true
}
}
output "Nginx_status" {
value = "Nginx pod restarted"
}
provider "kubernetes" {
config_path = "~/.kube/config"
}