diff options
author | pmikus <pmikus@cisco.com> | 2020-12-09 20:11:42 +0000 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2020-12-12 07:59:30 +0000 |
commit | fd4d85865e145f12330a4266be48fbdd6e919cf4 (patch) | |
tree | a94252782163c250a29a0551ba48df2e023d0692 /terraform-ci-infra/1n_nmd/minio/main.tf | |
parent | 688a68a8f6d8a69a85cb76421a16dff9c4105c52 (diff) |
Refactor storage solution
+ Minio terraform module
+ XL mode enabled with erasure code
+ Upload script as a sample
+ Nginx terraform module
+ Updating ansible to reflect changes
Signed-off-by: pmikus <pmikus@cisco.com>
Change-Id: Ia8c439b749aa0de82bd6f1d0cfbecce4d7000a8f
Diffstat (limited to 'terraform-ci-infra/1n_nmd/minio/main.tf')
-rw-r--r-- | terraform-ci-infra/1n_nmd/minio/main.tf | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/terraform-ci-infra/1n_nmd/minio/main.tf b/terraform-ci-infra/1n_nmd/minio/main.tf new file mode 100644 index 0000000000..6877211e6a --- /dev/null +++ b/terraform-ci-infra/1n_nmd/minio/main.tf @@ -0,0 +1,82 @@ +locals { + datacenters = join(",", var.nomad_datacenters) + minio_env_vars = join("\n", + concat([ + ], var.minio_envs) + ) + mc_env_vars = join("\n", + concat([ + ], var.mc_envs) + ) + mc_formatted_bucket_list = formatlist("LOCALMINIO/%s", var.minio_buckets) + mc_add_config_command = concat( + [ + "mc", + "config", + "host", + "add", + "LOCALMINIO", + "http://${var.minio_service_name}.service.consul:${var.minio_port}", + "$MINIO_ACCESS_KEY", + "$MINIO_SECRET_KEY", + ]) + mc_create_bucket_command = concat(["mc", "mb", "-p"], local.mc_formatted_bucket_list) + command = join(" ", concat(local.mc_add_config_command, ["&&"], local.mc_create_bucket_command, [";"], concat(var.mc_extra_commands))) +} + +data "template_file" "nomad_job_minio" { + template = file("${path.module}/conf/nomad/minio.hcl") + vars = { + job_name = var.minio_job_name + datacenters = local.datacenters + use_canary = var.minio_use_canary + group_count = var.minio_group_count + use_host_volume = var.minio_use_host_volume + host_volume = var.nomad_host_volume + service_name = var.minio_service_name + host = var.minio_host + port = var.minio_port + upstreams = jsonencode(var.minio_upstreams) + cpu_proxy = var.minio_resource_proxy.cpu + memory_proxy = var.minio_resource_proxy.memory + use_vault_provider = var.minio_vault_secret.use_vault_provider + image = var.minio_container_image + access_key = var.minio_access_key + secret_key = var.minio_secret_key + data_dir = var.minio_data_dir + envs = local.minio_env_vars + cpu = var.minio_cpu + memory = var.minio_memory + } +} + +data "template_file" "nomad_job_mc" { + template = file("${path.module}/conf/nomad/mc.hcl") + vars = { + job_name = var.mc_job_name + service_name = var.mc_service_name + datacenters = local.datacenters + minio_service_name = var.minio_service_name + minio_port = var.minio_port + image = var.mc_container_image + access_key = var.minio_access_key + secret_key = var.minio_secret_key + use_vault_provider = var.minio_vault_secret.use_vault_provider + envs = local.mc_env_vars + command = local.command + } +} + +resource "nomad_job" "nomad_job_minio" { + jobspec = data.template_file.nomad_job_minio.rendered + detach = false +} + +resource "nomad_job" "nomad_job_mc" { + jobspec = data.template_file.nomad_job_mc.rendered + detach = false + + depends_on = [ + nomad_job.nomad_job_minio + ] +}
\ No newline at end of file |