github.com/SUSE/skuba@v1.4.17/ci/infra/aws/cloud-init.tf (about) 1 data "template_file" "register_rmt" { 2 template = file("cloud-init/register-rmt.tpl") 3 count = var.rmt_server_name == "" ? 0 : 1 4 5 vars = { 6 rmt_server_name = var.rmt_server_name 7 } 8 } 9 10 data "template_file" "register_scc" { 11 # register with SCC iff an RMT has not been provided 12 count = var.caasp_registry_code != "" && var.rmt_server_name == "" ? 1 : 0 13 template = file("cloud-init/register-scc.tpl") 14 15 vars = { 16 caasp_registry_code = var.caasp_registry_code 17 } 18 } 19 20 data "template_file" "register_suma" { 21 template = file("cloud-init/register-suma.tpl") 22 count = var.suma_server_name == "" ? 0 : 1 23 24 vars = { 25 suma_server_name = var.suma_server_name 26 } 27 } 28 29 data "template_file" "repositories" { 30 count = length(var.repositories) 31 template = file("cloud-init/repository.tpl") 32 33 vars = { 34 repository_url = var.repositories[count.index] 35 repository_name = var.repositories[count.index] 36 } 37 } 38 39 data "template_file" "commands" { 40 template = file("cloud-init/commands.tpl") 41 count = length(var.packages) == 0 ? 0 : 1 42 43 vars = { 44 packages = join(", ", var.packages) 45 } 46 } 47 48 data "template_file" "cloud-init" { 49 template = file("cloud-init/cloud-init.yaml.tpl") 50 51 vars = { 52 authorized_keys = join("\n", formatlist(" - %s", var.authorized_keys)) 53 commands = join("\n", data.template_file.commands.*.rendered) 54 repositories = length(var.repositories) == 0 ? "\n" : join("\n", data.template_file.repositories.*.rendered) 55 register_scc = var.caasp_registry_code != "" && var.rmt_server_name == "" ? join("\n", data.template_file.register_scc.*.rendered) : "" 56 register_rmt = var.rmt_server_name != "" ? join("\n", data.template_file.register_rmt.*.rendered) : "" 57 register_suma = var.suma_server_name != "" ? join("\n", data.template_file.register_suma.*.rendered) : "" 58 } 59 } 60 61 data "template_cloudinit_config" "cfg" { 62 gzip = false 63 base64_encode = false 64 65 part { 66 content_type = "text/cloud-config" 67 content = data.template_file.cloud-init.rendered 68 } 69 } 70