Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from mrlesmithjr/add-timestamp-to-build
Browse files Browse the repository at this point in the history
Implemented timestamps on builds
  • Loading branch information
mrlesmithjr authored May 2, 2018
2 parents 4410007 + 32bcfc8 commit 6d96a64
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 75 deletions.
99 changes: 57 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,51 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->

<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Packer For vSphere and More](#packer-for-vsphere-and-more)
- [Requirements](#requirements)
- [Required Software](#required-software)
- [Updating/Creating Environment Variables and Etc. Using Ansible](#updatingcreating-environment-variables-and-etc-using-ansible)
- [Required ESXi Tweaks](#required-esxi-tweaks)
- [Usage](#usage)
- [KVM](#kvm)
- [Ubuntu 12.04](#ubuntu-1204)
- [Ubuntu 14.04](#ubuntu-1404)
- [Ubuntu 16.04](#ubuntu-1604)
- [Ubuntu 18.04](#ubuntu-1804)
- [VMware Fusion And VirtualBox](#vmware-fusion-and-virtualbox)
- [CentOS 6](#centos-6)
- [CentOS 7](#centos-7)
- [Debian 8](#debian-8)
- [Debian 9](#debian-9)
- [Ubuntu 12.04](#ubuntu-1204-1)
- [Ubuntu 14.04](#ubuntu-1404-1)
- [Ubuntu 16.04](#ubuntu-1604-1)
- [Ubuntu 18.04](#ubuntu-1804-1)
- [Using Vagrant](#using-vagrant)
- [Vagrant Boxes](#vagrant-boxes)
- [Importing Vagrant Boxes](#importing-vagrant-boxes)
- [Consuming Vagrant Boxes](#consuming-vagrant-boxes)
- [VMware Fusion Export To vSphere](#vmware-fusion-export-to-vsphere)
- [CentOS 6](#centos-6-1)
- [CentOS 7](#centos-7-1)
- [Ubuntu 12.04](#ubuntu-1204-2)
- [Ubuntu 14.04](#ubuntu-1404-2)
- [Ubuntu 16.04](#ubuntu-1604-2)
- [Ubuntu 18.04](#ubuntu-1804-2)
- [VMware vSphere](#vmware-vsphere)
- [CentOS 6](#centos-6-2)
- [CentOS 7](#centos-7-2)
- [Debian 8](#debian-8-1)
- [Debian 9](#debian-9-1)
- [Ubuntu 12.04](#ubuntu-1204-3)
- [Ubuntu 14.04](#ubuntu-1404-3)
- [Ubuntu 16.04](#ubuntu-1604-3)
- [Ubuntu 18.04](#ubuntu-1804-3)
- [License](#license)
- [Author Information](#author-information)
- [Packer For vSphere and More](#packer-for-vsphere-and-more)
- [Requirements](#requirements)
- [Required Software](#required-software)
- [Updating/Creating Environment Variables and Etc. Using Ansible](#updatingcreating-environment-variables-and-etc-using-ansible)
- [Required ESXi Tweaks](#required-esxi-tweaks)
- [Usage](#usage)
- [KVM](#kvm)
- [Ubuntu 12.04](#ubuntu-1204)
- [Ubuntu 14.04](#ubuntu-1404)
- [Ubuntu 16.04](#ubuntu-1604)
- [Ubuntu 18.04](#ubuntu-1804)
- [VMware Fusion And VirtualBox](#vmware-fusion-and-virtualbox)
- [CentOS 6](#centos-6)
- [CentOS 7](#centos-7)
- [Debian 8](#debian-8)
- [Debian 9](#debian-9)
- [Ubuntu 12.04](#ubuntu-1204-1)
- [Ubuntu 14.04](#ubuntu-1404-1)
- [Ubuntu 16.04](#ubuntu-1604-1)
- [Ubuntu 18.04](#ubuntu-1804-1)
- [Using Vagrant](#using-vagrant)
- [Vagrant Boxes](#vagrant-boxes)
- [Importing Vagrant Boxes](#importing-vagrant-boxes)
- [Consuming Vagrant Boxes](#consuming-vagrant-boxes)
- [VMware Fusion Export To vSphere](#vmware-fusion-export-to-vsphere)
- [CentOS 6](#centos-6-1)
- [CentOS 7](#centos-7-1)
- [Ubuntu 12.04](#ubuntu-1204-2)
- [Ubuntu 14.04](#ubuntu-1404-2)
- [Ubuntu 16.04](#ubuntu-1604-2)
- [Ubuntu 18.04](#ubuntu-1804-2)
- [VMware vSphere](#vmware-vsphere)
- [CentOS 6](#centos-6-2)
- [CentOS 7](#centos-7-2)
- [Debian 8](#debian-8-1)
- [Debian 9](#debian-9-1)
- [Ubuntu 12.04](#ubuntu-1204-3)
- [Ubuntu 14.04](#ubuntu-1404-3)
- [Ubuntu 16.04](#ubuntu-1604-3)
- [Ubuntu 18.04](#ubuntu-1804-3)
- [License](#license)
- [Author Information](#author-information)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -120,6 +122,19 @@ be used to configure your vSphere hosts to allow Packer to build.
> platform you choose to deploy to. This ensures that the underlying VM image is
> consistent across environments.
### Image Versions Based On Timestamps

We have implemented the `{{ timestamp }}` function within Packer to append the
timestamp to each image being built. This will allow for images to be continually
built based on timestamp in order to properly select an image that you would like
to consume.

Example image built:

```bash
Build 'ubuntu1604-packer-template-1525281143' finished.
```

### KVM

This method will build VM templates for KVM usage. You will need to run these
Expand Down
10 changes: 5 additions & 5 deletions centos.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}-{{ timestamp }}",
"shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'packer'|sudo -S bash 'shutdown.sh'",
"ssh_password": "{{ user `vm_ssh_password` }}",
"ssh_username": "{{ user `vm_ssh_username` }}",
Expand All @@ -35,7 +35,7 @@
["modifyvm", "{{.Name}}", "--memory", "{{ user `vm_memory` }}"],
["modifyvm", "{{.Name}}", "--cpus", "{{ user `vm_vcpu` }}"]
],
"vm_name": "{{ user `vm_name` }}"
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}"
},
{
"boot_command": [
Expand All @@ -50,13 +50,13 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}-{{ timestamp }}",
"shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'packer'|sudo -S bash 'shutdown.sh'",
"ssh_password": "{{ user `vm_ssh_password` }}",
"ssh_username": "{{ user `vm_ssh_username` }}",
"ssh_wait_timeout": "60m",
"type": "vmware-iso",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vmx_data": {
"memsize": "{{ user `vm_memory` }}",
"numvcpus": "{{ user `vm_vcpu` }}"
Expand All @@ -76,7 +76,7 @@
"post-processors": [
[{
"compression_level": "{{user `compression_level`}}",
"output": "{{ user `vm_name` }}-{{.Provider}}.box",
"output": "{{ user `vm_name` }}-{{.Provider}}-{{ timestamp }}.box",
"type": "vagrant"
}]
]
Expand Down
6 changes: 3 additions & 3 deletions centos_esx.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"name": "{{ user `vm_name` }}",
"output_directory": "{{ user `vm_name` }}",
"name": "{{ user `vm_name` }}-{{ timestamp }}",
"output_directory": "{{ user `vm_name` }}-{{ timestamp }}",
"remote_datastore": "{{ user `vcenter_datastore` }}",
"remote_host": "{{ user `esxi_remote_host` }}",
"remote_password": "{{ user `esxi_remote_password` }}",
Expand All @@ -47,7 +47,7 @@
"ssh_username": "{{ user `vm_ssh_username` }}",
"ssh_wait_timeout": "60m",
"type": "vmware-iso",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vmx_data": {
"memsize": "{{ user `vm_memory` }}",
"numvcpus": "{{ user `vm_vcpu` }}",
Expand Down
6 changes: 3 additions & 3 deletions centos_fusion_esx.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"name": "{{ user `vm_name` }}",
"name": "{{ user `vm_name` }}-{{ timestamp }}",
"shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'packer'|sudo -S bash 'shutdown.sh'",
"ssh_password": "{{ user `vm_ssh_password` }}",
"ssh_username": "{{ user `vm_ssh_username` }}",
"ssh_wait_timeout": "60m",
"type": "vmware-iso",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vmx_data": {
"memsize": "{{ user `vm_memory` }}",
"numvcpus": "{{ user `vm_vcpu` }}"
Expand All @@ -64,7 +64,7 @@
"password": "{{ user `vcenter_password` }}",
"type": "vsphere",
"username": "{{ user `vcenter_username` }}",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vm_network": "{{ user `vm_network` }}"
},
{
Expand Down
10 changes: 5 additions & 5 deletions debian.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}-{{ timestamp }}",
"shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'packer'|sudo -S bash 'shutdown.sh'",
"ssh_password": "{{ user `vm_ssh_password` }}",
"ssh_username": "{{ user `vm_ssh_username` }}",
Expand All @@ -49,7 +49,7 @@
["modifyvm", "{{.Name}}", "--memory", "{{ user `vm_memory` }}"],
["modifyvm", "{{.Name}}", "--cpus", "{{ user `vm_vcpu` }}"]
],
"vm_name": "{{ user `vm_name` }}"
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}"
},
{
"boot_command": [
Expand Down Expand Up @@ -78,13 +78,13 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}-{{ timestamp }}",
"shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'packer'|sudo -S bash 'shutdown.sh'",
"ssh_password": "{{ user `vm_ssh_password` }}",
"ssh_username": "{{ user `vm_ssh_username` }}",
"ssh_wait_timeout": "60m",
"type": "vmware-iso",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vmx_data": {
"memsize": "{{ user `vm_memory` }}",
"numvcpus": "{{ user `vm_vcpu` }}"
Expand All @@ -104,7 +104,7 @@
"post-processors": [
[{
"compression_level": "{{ user `compression_level` }}",
"output": "{{ user `vm_name` }}-{{.Provider}}.box",
"output": "{{ user `vm_name` }}-{{.Provider}}-{{ timestamp }}.box",
"type": "vagrant"
}]
]
Expand Down
6 changes: 3 additions & 3 deletions debian_esx.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"name": "{{ user `vm_name` }}",
"output_directory": "{{ user `vm_name` }}",
"name": "{{ user `vm_name` }}-{{ timestamp }}",
"output_directory": "{{ user `vm_name` }}-{{ timestamp }}",
"remote_datastore": "{{ user `vcenter_datastore` }}",
"remote_host": "{{ user `esxi_remote_host` }}",
"remote_password": "{{ user `esxi_remote_password` }}",
Expand All @@ -61,7 +61,7 @@
"ssh_username": "{{ user `vm_ssh_username` }}",
"ssh_wait_timeout": "60m",
"type": "vmware-iso",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vmx_data": {
"memsize": "{{ user `vm_memory` }}",
"numvcpus": "{{ user `vm_vcpu` }}",
Expand Down
10 changes: 5 additions & 5 deletions ubuntu.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}-{{ timestamp }}",
"shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'packer'|sudo -S bash 'shutdown.sh'",
"ssh_password": "{{ user `vm_ssh_password` }}",
"ssh_username": "{{ user `vm_ssh_username` }}",
Expand All @@ -55,7 +55,7 @@
["modifyvm", "{{.Name}}", "--memory", "{{ user `vm_memory` }}"],
["modifyvm", "{{.Name}}", "--cpus", "{{ user `vm_vcpu` }}"]
],
"vm_name": "{{ user `vm_name` }}"
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}"
},
{
"boot_command": [
Expand Down Expand Up @@ -90,13 +90,13 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}",
"output_directory": "output-{{ user `vm_name` }}-{{ build_type }}-{{ timestamp }}",
"shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'packer'|sudo -S bash 'shutdown.sh'",
"ssh_password": "{{ user `vm_ssh_password` }}",
"ssh_username": "{{ user `vm_ssh_username` }}",
"ssh_wait_timeout": "60m",
"type": "vmware-iso",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vmx_data": {
"memsize": "{{ user `vm_memory` }}",
"numvcpus": "{{ user `vm_vcpu` }}"
Expand All @@ -116,7 +116,7 @@
"post-processors": [
[{
"compression_level": "{{ user `compression_level` }}",
"output": "{{ user `vm_name` }}-{{.Provider}}.box",
"output": "{{ user `vm_name` }}-{{.Provider}}-{{ timestamp }}.box",
"type": "vagrant"
}]
]
Expand Down
6 changes: 3 additions & 3 deletions ubuntu_esx.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"name": "{{ user `vm_name` }}",
"output_directory": "{{ user `vm_name` }}",
"name": "{{ user `vm_name` }}-{{ timestamp }}",
"output_directory": "{{ user `vm_name` }}-{{ timestamp }}",
"remote_datastore": "{{ user `vcenter_datastore` }}",
"remote_host": "{{ user `esxi_remote_host` }}",
"remote_password": "{{ user `esxi_remote_password` }}",
Expand All @@ -67,7 +67,7 @@
"ssh_username": "{{ user `vm_ssh_username` }}",
"ssh_wait_timeout": "60m",
"type": "vmware-iso",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vmx_data": {
"memsize": "{{ user `vm_memory` }}",
"numvcpus": "{{ user `vm_vcpu` }}",
Expand Down
6 changes: 3 additions & 3 deletions ubuntu_fusion_esx.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"name": "{{ user `vm_name` }}",
"name": "{{ user `vm_name` }}-{{ timestamp }}",
"shutdown_command": "echo '/sbin/halt -h -p' > shutdown.sh; echo 'packer'|sudo -S bash 'shutdown.sh'",
"ssh_password": "{{ user `vm_ssh_password` }}",
"ssh_username": "{{ user `vm_ssh_username` }}",
"ssh_wait_timeout": "60m",
"type": "vmware-iso",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vmx_data": {
"memsize": "{{ user `vm_memory` }}",
"numvcpus": "{{ user `vm_vcpu` }}"
Expand All @@ -84,7 +84,7 @@
"password": "{{ user `vcenter_password` }}",
"type": "vsphere",
"username": "{{ user `vcenter_username` }}",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vm_network": "{{ user `vm_network` }}"
},
{
Expand Down
6 changes: 3 additions & 3 deletions ubuntu_kvm.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"iso_checksum_type": "{{ user `iso_checksum_type` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}",
"name": "{{ user `vm_name` }}",
"output_directory": "{{ user `vm_name` }}",
"name": "{{ user `vm_name` }}-{{ timestamp }}",
"output_directory": "{{ user `vm_name` }}-{{ timestamp }}",
"qemuargs": [
["-m", "{{ user `vm_memory` }}"],
["-smp", "{{ user `vm_vcpu` }}"]
Expand All @@ -54,7 +54,7 @@
"ssh_username": "{{ user `vm_ssh_username` }}",
"ssh_wait_timeout": "60m",
"type": "qemu",
"vm_name": "{{ user `vm_name` }}",
"vm_name": "{{ user `vm_name` }}-{{ timestamp }}",
"vnc_bind_address": "{{ user `vnc_bind_address` }}"
}],
"provisioners": [{
Expand Down

0 comments on commit 6d96a64

Please sign in to comment.