Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRY #49

Closed
dusek opened this issue Nov 21, 2015 · 3 comments
Closed

DRY #49

dusek opened this issue Nov 21, 2015 · 3 comments
Assignees
Labels
duplicate This is a duplicate of a closed or already existing issue stale This issue has had no recent or new discussion and will be forcefully closed in 1 month

Comments

@dusek
Copy link
Contributor

dusek commented Nov 21, 2015

DRY=Don't Repeat Yourself

There is lost of repetition in json files, templates (tpl), and autounattend.xml files.

Have you considered creating some script that would know about all the differences between different axes (see below) and be able to generate all these files?

The axes are:

  • A: windows version (7, 8, 8.1, 10, 2008, 2012, 2012r2 etc.)
  • B: windows edition (Pro, Enterprise, Standard, Web, Datacenter etc.)
  • C: platform (x86, x64)
  • D: winrm vs. ssh vs. cygwin

It feels like each axis presents a unique type of difference for all 3 types of files. It also feels like that the only significant differences are resulting from axis D (though I have not done a thorough look to verify this).

I was thinking there could be a script that would be passed parameters specifying value for each axis. It would then generate the .json template, the vagrant template in tpl, and Autounattend.xml.

These generated files could also be in the repository (e.g. to set up an automatic push to atlas in the future, or to make it easier to use for casual users) and in such case automated test (e.g. through Travis CI) could verify that all .json, .tpl and Autounattend.xml files committed to the repository are identical to the ones that would be generated from the script. I.e. development would really happen only inside this script, and before each commit, all files would be regenerated (but there could also be a variant where only the script is kept in the repository, not the .json, .tpl and Autounattend.xml files).

Current development effort is e.g. that if something needs to be changed for all ssh templates, then A×B×C modifications need to be made (which is tiresome and does lead to errors - as I just experienced in #48). With the script, only 1 modification would need to be made.

I was also thinking that maybe some of this could be achieved that there would be only one "universal" .json file, and all the differences would be expressed by variables passed to packer build, some of which would influence the packer template itself, and some of which would influence environment variables passed to provisioning scripts. The scripts run in VM would also be "universal" and use runtime detection and environment variables passed to them to do different things.

Finally, the Vagrantfiles in tpl are Ruby code, so maybe there could be some "library" of parameterized Ruby functions in one file which would then be used in the individual tpl templates, just with different parameters (but I am not sure whether such thing is possible in vagrant)?

OK, this is all that I had on my mind (sorry for the extensive braindump).

@rasa
Copy link
Member

rasa commented Nov 28, 2015

Great ideas. See https://github.com/boxcutter/windows/blob/master/bin/tweak-json.py

@arizvisa
Copy link
Contributor

arizvisa commented Jan 5, 2020

These are great ideas. Despite having tweak-json.py, I personally have found jq significantly awesome for manipulating our json Packer templates. One issue I personally have w/ regards to fragmenting the templates or Autounattends, however, is that users won't be able to use the templates directly with Packer which requires having one of these languages to build them.

Although it might be beneficial to allow users to build their own templates from the 4 axes that you mentioned, I believe this to out of scope for this project.

Nonetheless, this issue seems to have gone stale. I've marked it as such, so unless anybody has any objections I'll close it in a month.

@arizvisa arizvisa self-assigned this Jan 5, 2020
@arizvisa arizvisa added stale This issue has had no recent or new discussion and will be forcefully closed in 1 month duplicate This is a duplicate of a closed or already existing issue labels Jan 5, 2020
@arizvisa
Copy link
Contributor

Actually, I'm going to close this as a duplicate of #175 as it's significantly more recent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This is a duplicate of a closed or already existing issue stale This issue has had no recent or new discussion and will be forcefully closed in 1 month
Projects
None yet
Development

No branches or pull requests

3 participants