terraform-google-modules / terraform-google-startup-scripts

Provides a library of useful startup scripts to embed in VMs
https://registry.terraform.io/modules/terraform-google-modules/startup-scripts/google
Apache License 2.0
73 stars 36 forks source link

Assemble stdlib.content from snippets #12

Closed jeffmccune closed 5 years ago

jeffmccune commented 5 years ago

Without this patch the stdlib script is a single flat file. In [1] the idea of splitting functionality out, to be opted-in using Terraform input variables has been proposed.

The remaining functionality to be ported to stdlib is somewhat platform-specific. Managing sudoers, configuring init scripts, and setting up gsutil with crcmod. Pluggable functionality to opt-in to platform specific behavior should be added ahead of these features so they are not forced on everyone.

This patch envisions two approaches to opt-in behavior. Neither approach is implemented by this patch, only the groundwork to assemble the complete stdlib content from fragments.

  1. Feature flags such as enable_init_gsutil_crcmod_el for functionality maintained directly in the startup-scripts module.
  2. A general purpose user_content to serve the use case of centralizing project specific functionality. The intended use case is to provide a single place for multiple teams working together to add org-wide changes and functionality. An example of this use case is one organization using a set_dns() function to manage DNS across many teams. While this could be accomplished with the accounts module, the use case remains, to provide a single place to make broad changes in behavior. NOTE: perhaps this use case is better served by the module taking in a URL to a GCS bucket and sourcing org-specific functionality from that location.

Note, templates have not been used because file fragments accomplish the same goal, Terraform template behavior is changing soon in version 0.12, and the *.sh files allow the automated shellcheck checks to run unmodified.

[1]: https://github.com/terraform-google-modules/terraform-google-startup-scripts/pull/11#issuecomment-456855295

morgante commented 5 years ago

Note, templates have not been used because file fragments accomplish the same goal, Terraform template behavior is changing soon in version 0.12, and the *.sh files allow the automated shellcheck checks to run unmodified.

Just a note that I think we might need templates eventually, but fine with this approach to start.

Overall looks like a good framework.

jeffmccune commented 5 years ago

Agreed, I too think we'll likely need templates. I'm hoping we can find a use case to build the functionality at the right time.

Thanks for looking into this Morgante.

jeffmccune commented 5 years ago

LGTM so far, will give a formal 👍 once the PR is completed.

@adrienthebo This is completed, please see overall plan I proposed in the bug, "Make startup-scripts pluggable using module input variables"