diff --git a/README.md b/README.md index 00ecd3c..3b029fe 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,51 @@ + + -- [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) @@ -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 diff --git a/centos.json b/centos.json index e6128b1..6c7c499 100644 --- a/centos.json +++ b/centos.json @@ -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` }}", @@ -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": [ @@ -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` }}" @@ -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" }] ] diff --git a/centos_esx.json b/centos_esx.json index 5f60b66..3ae82ab 100644 --- a/centos_esx.json +++ b/centos_esx.json @@ -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` }}", @@ -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` }}", diff --git a/centos_fusion_esx.json b/centos_fusion_esx.json index f1934dc..2410f47 100644 --- a/centos_fusion_esx.json +++ b/centos_fusion_esx.json @@ -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` }}" @@ -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` }}" }, { diff --git a/debian.json b/debian.json index dbfb073..d60f8c0 100644 --- a/debian.json +++ b/debian.json @@ -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` }}", @@ -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": [ @@ -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` }}" @@ -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" }] ] diff --git a/debian_esx.json b/debian_esx.json index 7c804b0..ab214d1 100644 --- a/debian_esx.json +++ b/debian_esx.json @@ -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` }}", @@ -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` }}", diff --git a/ubuntu.json b/ubuntu.json index cb1ac07..cd93d77 100644 --- a/ubuntu.json +++ b/ubuntu.json @@ -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` }}", @@ -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": [ @@ -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` }}" @@ -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" }] ] diff --git a/ubuntu_esx.json b/ubuntu_esx.json index 0161d06..38e2608 100644 --- a/ubuntu_esx.json +++ b/ubuntu_esx.json @@ -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` }}", @@ -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` }}", diff --git a/ubuntu_fusion_esx.json b/ubuntu_fusion_esx.json index 1fe66b5..93d69f8 100644 --- a/ubuntu_fusion_esx.json +++ b/ubuntu_fusion_esx.json @@ -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` }}" @@ -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` }}" }, { diff --git a/ubuntu_kvm.json b/ubuntu_kvm.json index 52d5ad1..7939708 100644 --- a/ubuntu_kvm.json +++ b/ubuntu_kvm.json @@ -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` }}"] @@ -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": [{