diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a06e108..95d0828 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,7 +45,7 @@ default: stage: terraform-apply resource_group: tf/$TF_STATE_NAME script: - - gitlab-terraform apply | tee output + - gitlab-terraform apply $TF_ARGS | tee output - | echo -e "\e[0Ksection_start:`date +%s`:glpa_summary\r\e[0KHeader of the summary" grep "Apply complete!" output | sed -r "s/[[:cntrl:]]\[[0-9]{1,3}m//g" @@ -81,6 +81,7 @@ tf-plan:server_administration: variables: TF_STATE_NAME: server_administration TF_ROOT: 'envs/server_administration' + TF_ARGS: '-parallelism=1' tf-apply:server_administration: extends: diff --git a/envs/server_administration/main.tf b/envs/server_administration/main.tf index 73478df..340386b 100644 --- a/envs/server_administration/main.tf +++ b/envs/server_administration/main.tf @@ -23,6 +23,9 @@ provider "docker" { cert_path = "" } -resource "docker_network" "test" { - name = "test" +module "administration" { + source = "../../system/administration" + + cloudflare_account_id = var.cloudflare_account_id + server_administration_ip = var.server_administration_ip } diff --git a/system/administration/main.tf b/system/administration/main.tf new file mode 100644 index 0000000..d4c3ff0 --- /dev/null +++ b/system/administration/main.tf @@ -0,0 +1,56 @@ +terraform { + required_providers { + cloudflare = { + source = "cloudflare/cloudflare" + version = "4.37.0" + } + docker = { + source = "kreuzwerker/docker" + version = "3.0.2" + } + } +} + +data "cloudflare_zone" "main_domain" { + account_id = var.cloudflare_account_id + name = "code0.tech" +} + +module "proxy" { + source = "../../modules/docker/proxy" + + certificate_hostnames = [ + "plane.code0.tech", + ] +} + +module "plane" { + source = "../../modules/docker/plane" + + web_url = "plane.code0.tech" + docker_proxy_network_id = module.proxy.docker_proxy_network_id +} + +resource "cloudflare_record" "server_ip" { + name = "server_administration" + type = "A" + zone_id = data.cloudflare_zone.main_domain.id + value = var.server_administration_ip + proxied = true + + comment = "Managed by Terraform" +} + +resource "cloudflare_record" "server_cname" { + for_each = toset([ + "plane" + ]) + + name = each.value + type = "CNAME" + zone_id = data.cloudflare_zone.main_domain.id + value = cloudflare_record.server_ip.hostname + proxied = true + + comment = "Managed by Terraform" +} diff --git a/system/administration/variables.tf b/system/administration/variables.tf new file mode 100644 index 0000000..0d8e1a2 --- /dev/null +++ b/system/administration/variables.tf @@ -0,0 +1,9 @@ +variable "cloudflare_account_id" { + type = string + sensitive = true +} + +variable "server_administration_ip" { + type = string + sensitive = true +}