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

Update all the templates so that the vm_name and suffix are defined in user variables #217

Merged
merged 4 commits into from
Jan 13, 2020

Conversation

arizvisa
Copy link
Contributor

@arizvisa arizvisa commented Jan 13, 2020

This PR simply replaces all of the vm_name keys defined in the builders with a user-variable vm_name. This makes it easier to change the "vm_name" by only needing to update it in one place.

The suffix for the *-cygwin.json and *-ssh.json templates was also made into a user variable (vm_suffix) in case the full name is desired to be controlled. As another benefit, this gives the user the ability to fully control the name of the box that is emitted.

The vagrantfile_template and any files that re-use the template name are not included as these are specific to the the template and so were considered part of the actual template. The output name in the post-processors is now 100% controlled by the user variables (excluding the hyphens).

…e user variables in all of the templates so that they're grouped together.
…o use the vm_name and vm_suffix user variables.
…in.json templates into the vm_suffix user variable.
@arizvisa arizvisa added the enhancement This will introduce or improve an already existing capability label Jan 13, 2020
@arizvisa
Copy link
Contributor Author

All of the templates seem to validate w/o issue, just need to do a few test builds to 100% confirm the paths are the same.

@arizvisa arizvisa changed the title [WIP] Update all the templates so that the vm_name and suffix are defined in user variables Update all the templates so that the vm_name and suffix are defined in user variables Jan 13, 2020
@arizvisa
Copy link
Contributor Author

arizvisa commented Jan 13, 2020

Seems to work. Original template name was defined as the following which should emit the box under box/vmware/whatever.box. In the following tests, cm=salt (or cm=nocm), cm_version is undefined, and version=0.1.0. The value for the Provider template variabale is vmware (for the vmware-iso builder), and box_directory=box/.

      "output": "{{ user `box_directory` }}{{.Provider}}/eval-win7x86-enterprise-{{user `cm`}}{{user `cm_version`}}-{{user `version`}}.box",

Here's an example of the emitted box when using a template that specifies an empty vm_suffix.

$ packer build -only vmware-iso -var cpus=1 -var disk_size=102400 -var cm=salt eval-win7x86-enterprise.json
...
$ ls -l box/vmware/*.box
-rw-r--r-- 1 user None 3168410082 Jan 13 03:23 box/vmware/eval-win7x86-enterprise-salt-0.1.0.box

Here's an example of the emitted box when using a template that specifies a default vm_suffix (-ssh)

$ packer build -only vmware-iso -var cpus=1 -var disk_size=102400 -var cm=salt eval-win7x86-enterprise-ssh.json
...
$ ls -l box/vmware/*.box
-rw-r--r-- 1 user None 3168410082 Jan 13 03:23 box/vmware/eval-win7x86-enterprise-salt-0.1.0.box
-rw-r--r-- 1 user None 3144674582 Jan 13 03:42 box/vmware/eval-win7x86-enterprise-ssh-salt-0.1.0.box

And here's an example of the emitted box with an explicitly specified vm_suffix (-hithere). Ftr this build had to be pushed along by starting ssh due to issue #218 for the cygwin templates.

$ packer build -only vmware-iso -var cpus=1 -var disk_size=102400 -var cm=nocm -var vm_suffix=-hithere eval-win7x86-enterprise-cygwin.json
...
$ ls -l box/vmware/*.box
-rw-r--r-- 1 user None 5660928617 Jan 13 06:23 box/vmware/eval-win7x86-enterprise-hithere-nocm-0.1.0.box
-rw-r--r-- 1 user None 3168410082 Jan 13 03:23 box/vmware/eval-win7x86-enterprise-salt-0.1.0.box
-rw-r--r-- 1 user None 3144674582 Jan 13 03:42 box/vmware/eval-win7x86-enterprise-ssh-salt-0.1.0.box

@arizvisa
Copy link
Contributor Author

...and to demonstrate fully controlling the name (after rm'ing the boxes made by the prior tests):

$ packer build -only vmware-iso -var cpus=1 -var disk_size=102400 -var cm=nocm -var vm_suffix=-mysuffix -var vm_name=myprefix-w7x64 eval-win7x64-enterprise-ssh.json
...
$ ls -l box/vmware/*.box
-rw-r--r-- 1 user None 4189152572 Jan 13 07:00 box/vmware/myprefix-w7x64-mysuffix-nocm-0.1.0.box

@arizvisa arizvisa merged commit 6175b9e into boxcutter:master Jan 13, 2020
daxgames pushed a commit to daxgames/boxcutter_windows that referenced this pull request Feb 26, 2020
Update all the templates so that the vm_name and suffix are defined in user variables that can be controlled by the user.

This closes issue boxcutter#216.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This will introduce or improve an already existing capability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant