Skip to content

Commit

Permalink
[debian-*] Improve DRYness, correctness, & speed of Debian templates.
Browse files Browse the repository at this point in the history
The following improvements are made in this commit:

* Ensure that all related provisioner shell scripts are written using
  more conservative bourne code idioms
* Call all provisioner scripts with `sh -eux` which will (e) exit
  immediately if a command exits with a non-zero exit status, (u) treats
  unset variables as an error, and (x) outputs the command and its
  expanded arguments or associated word list
* Use the `template` user variable to replace repetition of `"debian-*"`
  style strings throughout
* Support a `HOME_DIR` environment variable for provisioner scripts to
  use
* Remove now-unused user variable `arch`
* Extract the `iso_checksum` and `iso_checksum_type` values into user
  variables and reference them in the templates
* Construct the `iso_url` value from the `mirror`, `mirror_directory`,
  and `iso_name` user variables
* Add an `install_path` user variable and use it throughout the
  templates
* Add an `iso_name` user variable and use it throughout the templates
* Use the `http_proxy`, `https_proxy`, and `no_proxy` environment
  variables if set on the workstation and make them available to the
  provisioner shell scripts to speed up package installations, etc.
* Improve the `scripts/debian/cleanup.sh` implementation to more closely
  match the Ubuntu version
* Attempt to upgrade the version of the kernel in
  `scripts/debian/update.sh`
  • Loading branch information
fnichol committed Jul 13, 2015
1 parent 5764967 commit 250efaa
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 155 deletions.
58 changes: 35 additions & 23 deletions debian-6.0.10-amd64.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-6.0/preseed.cfg <wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",
"debian-installer=en_US <wait>",
"auto <wait>",
"locale=en_US <wait>",
Expand All @@ -25,11 +25,11 @@
"hard_drive_interface": "sata",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "f3e70528664f174a121b26491c59cd66daaf8274",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/6.0.10/amd64/iso-cd/debian-6.0.10-amd64-CD-1.iso",
"output_directory": "packer-debian-6.0.10-amd64-virtualbox",
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/shutdown -hP now",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "packer-{{user `template`}}-virtualbox",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
Expand All @@ -56,7 +56,7 @@
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-6.0/preseed.cfg <wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",
"debian-installer=en_US <wait>",
"auto <wait>",
"locale=en_US <wait>",
Expand All @@ -75,11 +75,11 @@
"guest_os_type": "debian5-64",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "f3e70528664f174a121b26491c59cd66daaf8274",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/6.0.10/amd64/iso-cd/debian-6.0.10-amd64-CD-1.iso",
"output_directory": "packer-debian-6.0.10-amd64-vmware",
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/shutdown -hP now",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "packer-{{user `template`}}-vmware",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
Expand All @@ -97,7 +97,7 @@
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-6.0/preseed.cfg <wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",
"debian-installer=en_US <wait>",
"auto <wait>",
"locale=en_US <wait>",
Expand All @@ -116,10 +116,10 @@
"guest_os_type": "debian",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "f3e70528664f174a121b26491c59cd66daaf8274",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/6.0.10/amd64/iso-cd/debian-6.0.10-amd64-CD-1.iso",
"output_directory": "packer-debian-6.0.10-amd64-parallels",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "packer-{{user `template`}}-parallels",
"parallels_tools_flavor": "lin",
"prlctl": [
[
Expand All @@ -136,7 +136,7 @@
]
],
"prlctl_version_file": ".prlctl_version",
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/shutdown -hP now",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
Expand All @@ -158,8 +158,13 @@
"type": "file"
},
{
"environment_vars": [],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"environment_vars": [
"HOME_DIR=/home/vagrant",
"http_proxy={{user `http_proxy`}}",
"https_proxy={{user `https_proxy`}}",
"no_proxy={{user `no_proxy`}}"
],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"scripts": [
"scripts/common/metadata.sh",
"scripts/debian/update.sh",
Expand All @@ -175,16 +180,23 @@
}
],
"variables": {
"arch": "64",
"box_basename": "debian-6.0.10",
"box_basename": "__unset_box_basename__",
"build_timestamp": "{{isotime \"20060102150405\"}}",
"git_revision": "__unknown_git_revision__",
"headless": "",
"http_proxy": "{{env `http_proxy`}}",
"https_proxy": "{{env `https_proxy`}}",
"iso_checksum": "f3e70528664f174a121b26491c59cd66daaf8274",
"iso_checksum_type": "sha1",
"iso_name": "debian-6.0.10-amd64-CD-1.iso",
"metadata": "floppy/dummy_metadata.json",
"mirror": "http://cdimage.debian.org/cdimage/archive",
"mirror_directory": "6.0.10/amd64/iso-cd",
"name": "debian-6.0.10",
"no_proxy": "{{env `no_proxy`}}",
"preseed_path": "debian-6.0/preseed.cfg",
"template": "debian-6.0.10-amd64",
"version": "2.0.TIMESTAMP"
"version": "2.1.TIMESTAMP"
}
}

58 changes: 35 additions & 23 deletions debian-6.0.10-i386.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-6.0/preseed.cfg <wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",
"debian-installer=en_US <wait>",
"auto <wait>",
"locale=en_US <wait>",
Expand All @@ -25,11 +25,11 @@
"hard_drive_interface": "sata",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "e8f77720e30f669e731fe3166ad6c3d2da33d93a",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/6.0.10/i386/iso-cd/debian-6.0.10-i386-CD-1.iso",
"output_directory": "packer-debian-6.0.10-i386-virtualbox",
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/shutdown -hP now",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "packer-{{user `template`}}-virtualbox",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
Expand All @@ -56,7 +56,7 @@
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-6.0/preseed.cfg <wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",
"debian-installer=en_US <wait>",
"auto <wait>",
"locale=en_US <wait>",
Expand All @@ -75,11 +75,11 @@
"guest_os_type": "debian5",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "e8f77720e30f669e731fe3166ad6c3d2da33d93a",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/6.0.10/i386/iso-cd/debian-6.0.10-i386-CD-1.iso",
"output_directory": "packer-debian-6.0.10-i386-vmware",
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/shutdown -hP now",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "packer-{{user `template`}}-vmware",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
Expand All @@ -97,7 +97,7 @@
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-6.0/preseed.cfg <wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",
"debian-installer=en_US <wait>",
"auto <wait>",
"locale=en_US <wait>",
Expand All @@ -116,10 +116,10 @@
"guest_os_type": "debian",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "e8f77720e30f669e731fe3166ad6c3d2da33d93a",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/6.0.10/i386/iso-cd/debian-6.0.10-i386-CD-1.iso",
"output_directory": "packer-debian-6.0.10-i386-parallels",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "packer-{{user `template`}}-parallels",
"parallels_tools_flavor": "lin",
"prlctl": [
[
Expand All @@ -136,7 +136,7 @@
]
],
"prlctl_version_file": ".prlctl_version",
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/shutdown -hP now",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
Expand All @@ -158,8 +158,13 @@
"type": "file"
},
{
"environment_vars": [],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"environment_vars": [
"HOME_DIR=/home/vagrant",
"http_proxy={{user `http_proxy`}}",
"https_proxy={{user `https_proxy`}}",
"no_proxy={{user `no_proxy`}}"
],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"scripts": [
"scripts/common/metadata.sh",
"scripts/debian/update.sh",
Expand All @@ -175,16 +180,23 @@
}
],
"variables": {
"arch": "32",
"box_basename": "debian-6.0.10-i386",
"box_basename": "__unset_box_basename__",
"build_timestamp": "{{isotime \"20060102150405\"}}",
"git_revision": "__unknown_git_revision__",
"headless": "",
"http_proxy": "{{env `http_proxy`}}",
"https_proxy": "{{env `https_proxy`}}",
"iso_checksum": "e8f77720e30f669e731fe3166ad6c3d2da33d93a",
"iso_checksum_type": "sha1",
"iso_name": "debian-6.0.10-i386-CD-1.iso",
"metadata": "floppy/dummy_metadata.json",
"mirror": "http://cdimage.debian.org/cdimage/archive",
"mirror_directory": "6.0.10/i386/iso-cd",
"name": "debian-6.0.10-i386",
"no_proxy": "{{env `no_proxy`}}",
"preseed_path": "debian-6.0/preseed.cfg",
"template": "debian-6.0.10-i386",
"version": "2.0.TIMESTAMP"
"version": "2.1.TIMESTAMP"
}
}

58 changes: 35 additions & 23 deletions debian-7.8-amd64.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-7/preseed.cfg <wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",
"debian-installer=en_US <wait>",
"auto <wait>",
"locale=en_US <wait>",
Expand All @@ -25,11 +25,11 @@
"hard_drive_interface": "sata",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "5f611b40b0803f8be1180da561cfbc159e381599",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/7.8.0/amd64/iso-cd/debian-7.8.0-amd64-CD-1.iso",
"output_directory": "packer-debian-7.8-amd64-virtualbox",
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/shutdown -hP now",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "packer-{{user `template`}}-virtualbox",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
Expand All @@ -56,7 +56,7 @@
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-7/preseed.cfg <wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",
"debian-installer=en_US <wait>",
"auto <wait>",
"locale=en_US <wait>",
Expand All @@ -75,11 +75,11 @@
"guest_os_type": "debian7-64",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "5f611b40b0803f8be1180da561cfbc159e381599",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/7.8.0/amd64/iso-cd/debian-7.8.0-amd64-CD-1.iso",
"output_directory": "packer-debian-7.8-amd64-vmware",
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/shutdown -hP now",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "packer-{{user `template`}}-vmware",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
Expand All @@ -97,7 +97,7 @@
"boot_command": [
"<esc><wait>",
"install <wait>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-7/preseed.cfg <wait>",
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `preseed_path`}} <wait>",
"debian-installer=en_US <wait>",
"auto <wait>",
"locale=en_US <wait>",
Expand All @@ -116,10 +116,10 @@
"guest_os_type": "debian",
"headless": "{{ user `headless` }}",
"http_directory": "http",
"iso_checksum": "5f611b40b0803f8be1180da561cfbc159e381599",
"iso_checksum_type": "sha1",
"iso_url": "{{user `mirror`}}/7.8.0/amd64/iso-cd/debian-7.8.0-amd64-CD-1.iso",
"output_directory": "packer-debian-7.8-amd64-parallels",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "packer-{{user `template`}}-parallels",
"parallels_tools_flavor": "lin",
"prlctl": [
[
Expand All @@ -136,7 +136,7 @@
]
],
"prlctl_version_file": ".prlctl_version",
"shutdown_command": "echo 'vagrant'|sudo -S /sbin/shutdown -hP now",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_username": "vagrant",
Expand All @@ -158,8 +158,13 @@
"type": "file"
},
{
"environment_vars": [],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"environment_vars": [
"HOME_DIR=/home/vagrant",
"http_proxy={{user `http_proxy`}}",
"https_proxy={{user `https_proxy`}}",
"no_proxy={{user `no_proxy`}}"
],
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"scripts": [
"scripts/common/metadata.sh",
"scripts/debian/update.sh",
Expand All @@ -175,16 +180,23 @@
}
],
"variables": {
"arch": "64",
"box_basename": "debian-7.8",
"box_basename": "__unset_box_basename__",
"build_timestamp": "{{isotime \"20060102150405\"}}",
"git_revision": "__unknown_git_revision__",
"headless": "",
"http_proxy": "{{env `http_proxy`}}",
"https_proxy": "{{env `https_proxy`}}",
"iso_checksum": "5f611b40b0803f8be1180da561cfbc159e381599",
"iso_checksum_type": "sha1",
"iso_name": "debian-7.8.0-amd64-CD-1.iso",
"metadata": "floppy/dummy_metadata.json",
"mirror": "http://cdimage.debian.org/cdimage/archive",
"mirror_directory": "7.8.0/amd64/iso-cd",
"name": "debian-7.8",
"no_proxy": "{{env `no_proxy`}}",
"preseed_path": "debian-7/preseed.cfg",
"template": "debian-7.8-amd64",
"version": "2.0.TIMESTAMP"
"version": "2.1.TIMESTAMP"
}
}

Loading

0 comments on commit 250efaa

Please sign in to comment.