{"id":20521565,"url":"https://github.com/tedivm/terraform-general-cloudinit","last_synced_at":"2025-04-14T02:36:11.233Z","repository":{"id":145202541,"uuid":"467197720","full_name":"tedivm/terraform-general-cloudinit","owner":"tedivm","description":"A cloudinit wrapper module that enables quick machine configuration","archived":false,"fork":false,"pushed_at":"2023-03-30T12:34:24.000Z","size":18,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-14T02:35:50.402Z","etag":null,"topics":["cloud-init","terraform","terraform-module"],"latest_commit_sha":null,"homepage":"https://registry.terraform.io/modules/tedivm/cloudinit/general/latest","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tedivm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-07T17:41:37.000Z","updated_at":"2025-03-08T14:28:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"2e5a72a3-9605-4b56-a1e4-6cb427eab8ae","html_url":"https://github.com/tedivm/terraform-general-cloudinit","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedivm%2Fterraform-general-cloudinit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedivm%2Fterraform-general-cloudinit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedivm%2Fterraform-general-cloudinit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedivm%2Fterraform-general-cloudinit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tedivm","download_url":"https://codeload.github.com/tedivm/terraform-general-cloudinit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248812009,"owners_count":21165353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud-init","terraform","terraform-module"],"created_at":"2024-11-15T22:29:56.515Z","updated_at":"2025-04-14T02:36:11.227Z","avatar_url":"https://github.com/tedivm.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cloud Init Module\n\nThis module creates a multi-part mime encoded cloud init userdata blob.\n\nIn other words, it can be used to configure EC2 (or other cloudinit enabled) machines.\n\nIt has two components- a \"cloud-config\" formatted file based off of the inputs to the module, and the ability to take in arbitrary \"parts\" that can be added as separate files. The cloud-config section should be good enough for pretty much everything though.\n\nThis module even automatically compresses the userdata if it gets too large, so that it's easily readable if small while still allowing larger files when needed.\n\n## Usage\n\n### Example\n\nThis first example enables two services, runs a bunch of commands, and adds two configuration files.\n\n```terraform\nmodule \"cloudinit\" {\n  source  = \"tedivm/cloudinit/general\"\n  version = \"~\u003e 1.0\n\n  services = [\"consul\", \"nomad\"]\n\n  runcmd = [\n    \"sed -i 's/After=network-online.target/After=opt.mount network-online.target consul.service/' /lib/systemd/system/nomad.service\",\n    \"sed -i 's/After=network-online.target/After=opt.mount network-online.target/' /lib/systemd/system/consul.service\",\n    \"mkdir -p /opt/consul\",\n    \"chown consul:consul /opt/consul\",\n    \"mkdir -p /opt/nomad\",\n    \"chown nomad:nomad /opt/nomad\"\n  ]\n\n  config_files = {\n    \"/etc/nomad.d/nomad.hcl\" : templatefile(\"${path.module}/templates/nomad.hcl\", local.template_vars),\n    \"/etc/consul.d/consul.hcl\" : templatefile(\"${path.module}/templates/consul.hcl\", local.template_vars),\n  }\n}\n\n```\n\n\nThis version is a big more complex- it installs packages, enables and starts services, installs script files (with execution permissions), mounts an EBS volume with partition growth enabled, and then after everything else is done it runs a command to launch nomad jobs.\n\n```terraform\n\nlocals {\n  service_template_vars = {\n    controller_count : var.controller_count,\n    cluster_id : var.cluster_id,\n    advertise_address : tolist(aws_network_interface.main.private_ips)[0]\n  }\n\n  service_files = {\n    \"/etc/nomad.d/nomad.hcl\" : templatefile(\"${path.module}/templates/nomad.hcl\", local.service_template_vars),\n    \"/etc/consul.d/consul.hcl\" : templatefile(\"${path.module}/templates/consul.hcl\", local.service_template_vars),\n  }\n\n  cron_files = {\n    \"/etc/cron.d/nomad_submit\" : templatefile(\"${path.module}/templates/nomad_cron\", { \"config_bucket\" : var.config_bucket })\n  }\n\n  script_files = {\n    \"/opt/nomad_core_jobs.sh\" : templatefile(\"${path.module}/templates/nomad_core_jobs.sh\",\n      {\n        \"config_bucket\" : var.config_bucket,\n        \"cluster_id\" : var.cluster_id\n      }\n    ),\n    \"/opt/awscli_install.sh\" : templatefile(\"${path.module}/templates/awscli_installer.sh\", {}),\n  }\n\n}\n\n\nmodule \"cloudinit\" {\n  source  = \"tedivm/cloudinit/general\"\n  version = \"~\u003e 1.0\n  \n  package_update = true\n\n  packages = [\"unzip\", \"jq\"]\n\n  services = [\"consul\", \"nomad\"]\n\n  script_files = local.script_files\n\n  config_files = merge(local.service_files, local.cron_files)\n\n  mounts = [\n    [\"/dev/disk/by-id/nvme-Amazon_Elastic_Block_Store_${replace(aws_ebs_volume.opt.id, \"-\", \"\")}\", \"/opt/data\", \"xfs\", \"defaults,x-systemd.makefs,x-systemd.required-by=consul.service,x-systemd.required-by=nomad.service\", \"0\", \"1\"]\n  ]\n\n  grow_partition_devices = [\n    \"/opt/data\"\n  ]\n\n  runcmd = [\n    \"systemctl start opt-data.mount\",\n    \"/opt/awscli_install.sh\",\n    \"mkdir -p /opt/jobspecs\",\n    \"mkdir -p /opt/data/consul\",\n    \"chown consul:consul /opt/data/consul\",\n    \"mkdir -p /opt/data/nomad\",\n    \"chown nomad:nomad /opt/data/nomad\"\n  ]\n\n  endcmd = [\n    \"/opt/nomad_core_jobs.sh\"\n  ]\n\n}\n```\n\n### Outputs\n\n* `rendered` - The string containing the `user_data` to pass to the EC2 instances or Launch Templates.\n\n\n## Resources Affected\n\nThis module only creates data- no resources are actually created by it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftedivm%2Fterraform-general-cloudinit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftedivm%2Fterraform-general-cloudinit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftedivm%2Fterraform-general-cloudinit/lists"}