From 8951b152ee049f97257595d47fb9ac5c9639c2af Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Sat, 23 Mar 2024 22:45:44 -0400 Subject: [PATCH] docs: technical debt - General cleanup of the documentation. - Standardize heading for Required and Optional. - Standardize headings for HCL and JSON. - Standardize leading with HCL examples. - Format for cleanliness. - Moves `builder/vsphere/examples/` to `examples/`. Signed-off-by: Ryan Johnson --- .../builder/vsphere-clone/README.md | 51 ++++++++------ .../components/builder/vsphere-iso/README.md | 57 ++++++++------- .../builder/vsphere-supervisor/README.md | 34 ++++----- .../post-processor/vsphere-template/README.md | 5 ++ .../post-processor/vsphere/README.md | 7 +- builder/vsphere/common/storage_config.go | 43 +++++++----- builder/vsphere/iso/step_create.go | 2 +- .../builder/vsphere/common/DiskConfig.mdx | 49 +++++++------ .../vsphere/iso/CreateConfig-not-required.mdx | 2 +- docs/builders/vsphere-clone.mdx | 2 +- docs/builders/vsphere-iso.mdx | 6 +- docs/builders/vsphere-supervisor.mdx | 34 ++++----- docs/post-processors/vsphere-template.mdx | 5 ++ docs/post-processors/vsphere.mdx | 7 +- example/README.md | 43 ------------ example/build.pkr.hcl | 22 ------ example/preseed_hardcoded_ip.cfg | 69 ------------------- example/source.pkr.hcl | 63 ----------------- example/variables.pkr.hcl | 50 -------------- .../builder/vsphere-clone/alpine}/alpine.json | 0 .../vsphere-clone/alpine}/alpine.pkr.hcl | 0 .../vsphere-iso}/alpine/alpine-3.8.json | 0 .../vsphere-iso}/alpine/alpine-3.8.pkr.hcl | 0 .../builder/vsphere-iso}/alpine/answerfile | 0 .../builder/vsphere-iso}/alpine/setup.sh | 0 .../builder/vsphere-iso}/ubuntu/preseed.cfg | 0 .../vsphere-iso}/ubuntu/ubuntu-16.04.json | 0 .../vsphere-iso}/ubuntu/ubuntu-16.04.pkr.hcl | 0 .../vsphere-iso}/windows/.gitattributes | 0 .../windows/setup/Autounattend.xml | 0 .../vsphere-iso}/windows/setup/setup.ps1 | 0 .../vsphere-iso}/windows/setup/vmtools.cmd | 0 .../vsphere-iso}/windows/windows-10.json | 0 .../vsphere-iso}/windows/windows-10.pkr.hcl | 0 .../vsphere-supervisor}/cleanup-playbook.yml | 0 .../general-template.pkr.hcl | 0 .../jenkins-template.pkr.hcl | 0 .../nginx-template.pkr.hcl | 0 .../sysprep-unattend-data.yml | 0 .../windows-template.pkr.hcl | 0 .../examples => examples}/driver/main.go | 0 41 files changed, 181 insertions(+), 370 deletions(-) delete mode 100644 example/README.md delete mode 100644 example/build.pkr.hcl delete mode 100644 example/preseed_hardcoded_ip.cfg delete mode 100644 example/source.pkr.hcl delete mode 100644 example/variables.pkr.hcl rename {builder/vsphere/examples/clone => examples/builder/vsphere-clone/alpine}/alpine.json (100%) rename {builder/vsphere/examples/clone => examples/builder/vsphere-clone/alpine}/alpine.pkr.hcl (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/alpine/alpine-3.8.json (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/alpine/alpine-3.8.pkr.hcl (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/alpine/answerfile (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/alpine/setup.sh (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/ubuntu/preseed.cfg (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/ubuntu/ubuntu-16.04.json (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/ubuntu/ubuntu-16.04.pkr.hcl (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/windows/.gitattributes (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/windows/setup/Autounattend.xml (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/windows/setup/setup.ps1 (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/windows/setup/vmtools.cmd (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/windows/windows-10.json (100%) rename {builder/vsphere/examples => examples/builder/vsphere-iso}/windows/windows-10.pkr.hcl (100%) rename {builder/vsphere/examples/supervisor => examples/builder/vsphere-supervisor}/cleanup-playbook.yml (100%) rename {builder/vsphere/examples/supervisor => examples/builder/vsphere-supervisor}/general-template.pkr.hcl (100%) rename {builder/vsphere/examples/supervisor => examples/builder/vsphere-supervisor}/jenkins-template.pkr.hcl (100%) rename {builder/vsphere/examples/supervisor => examples/builder/vsphere-supervisor}/nginx-template.pkr.hcl (100%) rename {builder/vsphere/examples/supervisor => examples/builder/vsphere-supervisor}/sysprep-unattend-data.yml (100%) rename {builder/vsphere/examples/supervisor => examples/builder/vsphere-supervisor}/windows-template.pkr.hcl (100%) rename {builder/vsphere/examples => examples}/driver/main.go (100%) diff --git a/.web-docs/components/builder/vsphere-clone/README.md b/.web-docs/components/builder/vsphere-clone/README.md index 98dbccb4a..17dd22b53 100644 --- a/.web-docs/components/builder/vsphere-clone/README.md +++ b/.web-docs/components/builder/vsphere-clone/README.md @@ -122,12 +122,13 @@ disk controller plus the new configured ones. -The following example that will create a 15GB and a 20GB disk on the virtual machine. -The second disk will be thin provisioned: +The following example that will create a 15GB and a 20GB disk on the virtual +machine. The second disk will be thin provisioned: HCL Example: ```hcl + storage { disk_size = 15000 } @@ -135,11 +136,13 @@ HCL Example: disk_size = 20000 disk_thin_provisioned = true } + ``` JSON Example: ```json + "storage": [ { "disk_size": 15000 @@ -149,35 +152,40 @@ JSON Example: "disk_thin_provisioned": true } ], + ``` -The following example will use two PVSCSI controllers and two disks on each controller. +The following example will use two PVSCSI controllers and two disks on each +controller. HCL Example: ```hcl - disk_controller_type = ["pvscsi", "pvscsi"] - storage { - disk_size = 15000, - disk_controller_index = 0 - } - storage { - disk_size = 15000 - disk_controller_index = 0 - } - storage { - disk_size = 15000 - disk_controller_index = 1 - } - storage { - disk_size = 15000 - disk_controller_index = 1 - } + + disk_controller_type = ["pvscsi", "pvscsi"] + storage { + disk_size = 15000, + disk_controller_index = 0 + } + storage { + disk_size = 15000 + disk_controller_index = 0 + } + storage { + disk_size = 15000 + disk_controller_index = 1 + } + storage { + disk_size = 15000 + disk_controller_index = 1 + } + ``` JSON Example: ```json + "disk_controller_type": ["pvscsi", "pvscsi"], "storage": [ { @@ -197,6 +205,7 @@ JSON Example: "disk_controller_index": 1 } ], + ``` @@ -1659,7 +1668,7 @@ HCL Example: ```hcl content_library_destination { - library = "Example Content Library" + library = "Example Content Library" } ``` diff --git a/.web-docs/components/builder/vsphere-iso/README.md b/.web-docs/components/builder/vsphere-iso/README.md index af268f6eb..512af192f 100644 --- a/.web-docs/components/builder/vsphere-iso/README.md +++ b/.web-docs/components/builder/vsphere-iso/README.md @@ -11,11 +11,11 @@ their respective End of General Support dates. For detailed information, refer t ## Examples -- Basic examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/builder/vsphere/examples/) -directory of the GitHub repository. +- Basic examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/examples/) + directory of the GitHub repository. - Additional examples are available in the [`vmware-samples/packer-examples-for-vsphere`](https://github.com/vmware-samples/packer-examples-for-vsphere) -GitHub repository maintained by VMware by Broadcom. + GitHub repository maintained by VMware by Broadcom. ## Configuration Reference @@ -264,7 +264,7 @@ wget http://{{ .HTTPIP }}:{{ .HTTPPort }}/foo/bar/preseed.cfg ESXi host, run the following PowerShell command using `VMware.PowerCLI`: ```powershell - Connect-VIServer -Server "vcenter.example.com" -User "administrator@vsphere" -Password "password" + Connect-VIServer -Server "vcenter.example.com" -User "administrator@vsphere.local" -Password "password" $esxiHost = Get-VMHost -Name "esxi-01.example.com" $environmentBrowser = Get-View -Id $esxiHost.ExtensionData.Parent.ExtensionData.ConfigManager.EnvironmentBrowser $vmxVersion = ($environmentBrowser.QueryConfigOptionDescriptor() | Where-Object DefaultConfigOption).Key @@ -736,12 +736,13 @@ JSON Example: -The following example that will create a 15GB and a 20GB disk on the virtual machine. -The second disk will be thin provisioned: +The following example that will create a 15GB and a 20GB disk on the virtual +machine. The second disk will be thin provisioned: HCL Example: ```hcl + storage { disk_size = 15000 } @@ -749,11 +750,13 @@ HCL Example: disk_size = 20000 disk_thin_provisioned = true } + ``` JSON Example: ```json + "storage": [ { "disk_size": 15000 @@ -763,35 +766,40 @@ JSON Example: "disk_thin_provisioned": true } ], + ``` -The following example will use two PVSCSI controllers and two disks on each controller. +The following example will use two PVSCSI controllers and two disks on each +controller. HCL Example: ```hcl - disk_controller_type = ["pvscsi", "pvscsi"] - storage { - disk_size = 15000, - disk_controller_index = 0 - } - storage { - disk_size = 15000 - disk_controller_index = 0 - } - storage { - disk_size = 15000 - disk_controller_index = 1 - } - storage { - disk_size = 15000 - disk_controller_index = 1 - } + + disk_controller_type = ["pvscsi", "pvscsi"] + storage { + disk_size = 15000, + disk_controller_index = 0 + } + storage { + disk_size = 15000 + disk_controller_index = 0 + } + storage { + disk_size = 15000 + disk_controller_index = 1 + } + storage { + disk_size = 15000 + disk_controller_index = 1 + } + ``` JSON Example: ```json + "disk_controller_type": ["pvscsi", "pvscsi"], "storage": [ { @@ -811,6 +819,7 @@ JSON Example: "disk_controller_index": 1 } ], + ``` diff --git a/.web-docs/components/builder/vsphere-supervisor/README.md b/.web-docs/components/builder/vsphere-supervisor/README.md index 9aec07d46..ec38765ee 100644 --- a/.web-docs/components/builder/vsphere-supervisor/README.md +++ b/.web-docs/components/builder/vsphere-supervisor/README.md @@ -21,7 +21,7 @@ their respective End of General Support dates. For detailed information, refer t ## Examples -Examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/builder/vsphere/examples/) +Examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/examples/) directory of the GitHub repository. HCL Example: @@ -358,8 +358,8 @@ Content of `cleanup-playbook.yml`: group: root mode: "{{ item.mode }}" loop: - - { path: /etc/machine-id, state: absent, mode: "0644" } - - { path: /etc/machine-id, state: touch, mode: "0644" } + - { path: /etc/machine-id, state: absent, mode: "0644" } + - { path: /etc/machine-id, state: touch, mode: "0644" } - name: Truncate audit logs file: @@ -369,20 +369,20 @@ Content of `cleanup-playbook.yml`: group: utmp mode: "{{ item.mode }}" loop: - - { path: /var/log/wtmp, state: absent, mode: "0664" } - - { path: /var/log/lastlog, state: absent, mode: "0644" } - - { path: /var/log/wtmp, state: touch, mode: "0664" } - - { path: /var/log/lastlog, state: touch, mode: "0644" } + - { path: /var/log/wtmp, state: absent, mode: "0664" } + - { path: /var/log/lastlog, state: absent, mode: "0644" } + - { path: /var/log/wtmp, state: touch, mode: "0664" } + - { path: /var/log/lastlog, state: touch, mode: "0644" } - name: Remove cloud-init lib dir and logs file: state: absent path: "{{ item }}" loop: - - /var/lib/cloud - - /var/log/cloud-init.log - - /var/log/cloud-init-output.log - - /var/run/cloud-init + - /var/lib/cloud + - /var/log/cloud-init.log + - /var/log/cloud-init-output.log + - /var/run/cloud-init - name: Truncate all remaining log files in /var/log shell: @@ -399,9 +399,9 @@ Content of `cleanup-playbook.yml`: depth: 1 file_type: any paths: - - /tmp - - /var/tmp - pattern: '*' + - /tmp + - /var/tmp + pattern: "*" register: temp_files - name: Reset temp space @@ -415,6 +415,8 @@ Content of `cleanup-playbook.yml`: state: absent path: "{{ item.path }}" loop: - - { path: /root/.bash_history } - - { path: "/home/{{ ansible_env.SUDO_USER | default(ansible_user_id) }}/.bash_history" } + - { path: /root/.bash_history } + - { + path: "/home/{{ ansible_env.SUDO_USER | default(ansible_user_id) }}/.bash_history", + } ``` diff --git a/.web-docs/components/post-processor/vsphere-template/README.md b/.web-docs/components/post-processor/vsphere-template/README.md index 1cd63a5c9..f65d78009 100644 --- a/.web-docs/components/post-processor/vsphere-template/README.md +++ b/.web-docs/components/post-processor/vsphere-template/README.md @@ -10,6 +10,11 @@ the virtual machine as a template and moves it to your specified path. their respective End of General Support dates. For detailed information, refer to the [Broadcom Product Lifecycle](https://support.broadcom.com/group/ecx/productlifecycle). +## Examples + +Examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/examples/) +directory of the GitHub repository. + ## Configuration Reference The following configuration options are available for the post-processor. diff --git a/.web-docs/components/post-processor/vsphere/README.md b/.web-docs/components/post-processor/vsphere/README.md index 90bd1231a..b33cf15b3 100644 --- a/.web-docs/components/post-processor/vsphere/README.md +++ b/.web-docs/components/post-processor/vsphere/README.md @@ -10,6 +10,11 @@ The artifact must be a VMX, OVA, or OVF file. their respective End of General Support dates. For detailed information, refer to the [Broadcom Product Lifecycle](https://support.broadcom.com/group/ecx/productlifecycle). +## Examples + +Examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/examples/) +directory of the GitHub repository. + ## Configuration Reference The following configuration options are available for the post-processor. @@ -146,7 +151,7 @@ JSON Example: "cluster": "cluster-01", "datastore": "datastore-01", "vm_network": "VM Network", - "keep_input_artifact": true, + "keep_input_artifact": true } ] ] diff --git a/builder/vsphere/common/storage_config.go b/builder/vsphere/common/storage_config.go index ba03dcf42..9ab0f2865 100644 --- a/builder/vsphere/common/storage_config.go +++ b/builder/vsphere/common/storage_config.go @@ -16,6 +16,7 @@ import ( // HCL Example: // // ```hcl +// // storage { // disk_size = 15000 // } @@ -23,11 +24,13 @@ import ( // disk_size = 20000 // disk_thin_provisioned = true // } +// // ``` // // JSON Example: // // ```json +// // "storage": [ // { // "disk_size": 15000 @@ -37,6 +40,7 @@ import ( // "disk_thin_provisioned": true // } // ], +// // ``` // // The following example will use two PVSCSI controllers and two disks on each @@ -45,28 +49,31 @@ import ( // HCL Example: // // ```hcl -// disk_controller_type = ["pvscsi", "pvscsi"] -// storage { -// disk_size = 15000, -// disk_controller_index = 0 -// } -// storage { -// disk_size = 15000 -// disk_controller_index = 0 -// } -// storage { -// disk_size = 15000 -// disk_controller_index = 1 -// } -// storage { -// disk_size = 15000 -// disk_controller_index = 1 -// } +// +// disk_controller_type = ["pvscsi", "pvscsi"] +// storage { +// disk_size = 15000, +// disk_controller_index = 0 +// } +// storage { +// disk_size = 15000 +// disk_controller_index = 0 +// } +// storage { +// disk_size = 15000 +// disk_controller_index = 1 +// } +// storage { +// disk_size = 15000 +// disk_controller_index = 1 +// } +// // ``` // // JSON Example: // // ```json +// // "disk_controller_type": ["pvscsi", "pvscsi"], // "storage": [ // { @@ -86,8 +93,8 @@ import ( // "disk_controller_index": 1 // } // ], +// // ``` - type DiskConfig struct { // The size of the disk in MiB. DiskSize int64 `mapstructure:"disk_size" required:"true"` diff --git a/builder/vsphere/iso/step_create.go b/builder/vsphere/iso/step_create.go index faa5e31f7..a54b43742 100644 --- a/builder/vsphere/iso/step_create.go +++ b/builder/vsphere/iso/step_create.go @@ -95,7 +95,7 @@ type CreateConfig struct { // ESXi host, run the following PowerShell command using `VMware.PowerCLI`: // // ```powershell - // Connect-VIServer -Server "vcenter.example.com" -User "administrator@vsphere" -Password "password" + // Connect-VIServer -Server "vcenter.example.com" -User "administrator@vsphere.local" -Password "password" // $esxiHost = Get-VMHost -Name "esxi-01.example.com" // $environmentBrowser = Get-View -Id $esxiHost.ExtensionData.Parent.ExtensionData.ConfigManager.EnvironmentBrowser // $vmxVersion = ($environmentBrowser.QueryConfigOptionDescriptor() | Where-Object DefaultConfigOption).Key diff --git a/docs-partials/builder/vsphere/common/DiskConfig.mdx b/docs-partials/builder/vsphere/common/DiskConfig.mdx index 61204b1c6..0902189c0 100644 --- a/docs-partials/builder/vsphere/common/DiskConfig.mdx +++ b/docs-partials/builder/vsphere/common/DiskConfig.mdx @@ -1,11 +1,12 @@ -The following example that will create a 15GB and a 20GB disk on the virtual machine. -The second disk will be thin provisioned: +The following example that will create a 15GB and a 20GB disk on the virtual +machine. The second disk will be thin provisioned: HCL Example: ```hcl + storage { disk_size = 15000 } @@ -13,11 +14,13 @@ HCL Example: disk_size = 20000 disk_thin_provisioned = true } + ``` JSON Example: ```json + "storage": [ { "disk_size": 15000 @@ -27,35 +30,40 @@ JSON Example: "disk_thin_provisioned": true } ], + ``` -The following example will use two PVSCSI controllers and two disks on each controller. +The following example will use two PVSCSI controllers and two disks on each +controller. HCL Example: ```hcl - disk_controller_type = ["pvscsi", "pvscsi"] - storage { - disk_size = 15000, - disk_controller_index = 0 - } - storage { - disk_size = 15000 - disk_controller_index = 0 - } - storage { - disk_size = 15000 - disk_controller_index = 1 - } - storage { - disk_size = 15000 - disk_controller_index = 1 - } + + disk_controller_type = ["pvscsi", "pvscsi"] + storage { + disk_size = 15000, + disk_controller_index = 0 + } + storage { + disk_size = 15000 + disk_controller_index = 0 + } + storage { + disk_size = 15000 + disk_controller_index = 1 + } + storage { + disk_size = 15000 + disk_controller_index = 1 + } + ``` JSON Example: ```json + "disk_controller_type": ["pvscsi", "pvscsi"], "storage": [ { @@ -75,6 +83,7 @@ JSON Example: "disk_controller_index": 1 } ], + ``` diff --git a/docs-partials/builder/vsphere/iso/CreateConfig-not-required.mdx b/docs-partials/builder/vsphere/iso/CreateConfig-not-required.mdx index b17504a38..44771363c 100644 --- a/docs-partials/builder/vsphere/iso/CreateConfig-not-required.mdx +++ b/docs-partials/builder/vsphere/iso/CreateConfig-not-required.mdx @@ -12,7 +12,7 @@ ESXi host, run the following PowerShell command using `VMware.PowerCLI`: ```powershell - Connect-VIServer -Server "vcenter.example.com" -User "administrator@vsphere" -Password "password" + Connect-VIServer -Server "vcenter.example.com" -User "administrator@vsphere.local" -Password "password" $esxiHost = Get-VMHost -Name "esxi-01.example.com" $environmentBrowser = Get-View -Id $esxiHost.ExtensionData.Parent.ExtensionData.ConfigManager.EnvironmentBrowser $vmxVersion = ($environmentBrowser.QueryConfigOptionDescriptor() | Where-Object DefaultConfigOption).Key diff --git a/docs/builders/vsphere-clone.mdx b/docs/builders/vsphere-clone.mdx index 9464dba9f..7cc0aa4fb 100644 --- a/docs/builders/vsphere-clone.mdx +++ b/docs/builders/vsphere-clone.mdx @@ -327,7 +327,7 @@ HCL Example: ```hcl content_library_destination { - library = "Example Content Library" + library = "Example Content Library" } ``` diff --git a/docs/builders/vsphere-iso.mdx b/docs/builders/vsphere-iso.mdx index f1b607904..874684f15 100644 --- a/docs/builders/vsphere-iso.mdx +++ b/docs/builders/vsphere-iso.mdx @@ -23,11 +23,11 @@ their respective End of General Support dates. For detailed information, refer t ## Examples -- Basic examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/builder/vsphere/examples/) -directory of the GitHub repository. +- Basic examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/examples/) + directory of the GitHub repository. - Additional examples are available in the [`vmware-samples/packer-examples-for-vsphere`](https://github.com/vmware-samples/packer-examples-for-vsphere) -GitHub repository maintained by VMware by Broadcom. + GitHub repository maintained by VMware by Broadcom. ## Configuration Reference diff --git a/docs/builders/vsphere-supervisor.mdx b/docs/builders/vsphere-supervisor.mdx index 6e2a7701e..0a7b0610d 100644 --- a/docs/builders/vsphere-supervisor.mdx +++ b/docs/builders/vsphere-supervisor.mdx @@ -32,7 +32,7 @@ their respective End of General Support dates. For detailed information, refer t ## Examples -Examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/builder/vsphere/examples/) +Examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/examples/) directory of the GitHub repository. HCL Example: @@ -164,8 +164,8 @@ Content of `cleanup-playbook.yml`: group: root mode: "{{ item.mode }}" loop: - - { path: /etc/machine-id, state: absent, mode: "0644" } - - { path: /etc/machine-id, state: touch, mode: "0644" } + - { path: /etc/machine-id, state: absent, mode: "0644" } + - { path: /etc/machine-id, state: touch, mode: "0644" } - name: Truncate audit logs file: @@ -175,20 +175,20 @@ Content of `cleanup-playbook.yml`: group: utmp mode: "{{ item.mode }}" loop: - - { path: /var/log/wtmp, state: absent, mode: "0664" } - - { path: /var/log/lastlog, state: absent, mode: "0644" } - - { path: /var/log/wtmp, state: touch, mode: "0664" } - - { path: /var/log/lastlog, state: touch, mode: "0644" } + - { path: /var/log/wtmp, state: absent, mode: "0664" } + - { path: /var/log/lastlog, state: absent, mode: "0644" } + - { path: /var/log/wtmp, state: touch, mode: "0664" } + - { path: /var/log/lastlog, state: touch, mode: "0644" } - name: Remove cloud-init lib dir and logs file: state: absent path: "{{ item }}" loop: - - /var/lib/cloud - - /var/log/cloud-init.log - - /var/log/cloud-init-output.log - - /var/run/cloud-init + - /var/lib/cloud + - /var/log/cloud-init.log + - /var/log/cloud-init-output.log + - /var/run/cloud-init - name: Truncate all remaining log files in /var/log shell: @@ -205,9 +205,9 @@ Content of `cleanup-playbook.yml`: depth: 1 file_type: any paths: - - /tmp - - /var/tmp - pattern: '*' + - /tmp + - /var/tmp + pattern: "*" register: temp_files - name: Reset temp space @@ -221,6 +221,8 @@ Content of `cleanup-playbook.yml`: state: absent path: "{{ item.path }}" loop: - - { path: /root/.bash_history } - - { path: "/home/{{ ansible_env.SUDO_USER | default(ansible_user_id) }}/.bash_history" } + - { path: /root/.bash_history } + - { + path: "/home/{{ ansible_env.SUDO_USER | default(ansible_user_id) }}/.bash_history", + } ``` diff --git a/docs/post-processors/vsphere-template.mdx b/docs/post-processors/vsphere-template.mdx index 401ebd4c0..e8afa32db 100644 --- a/docs/post-processors/vsphere-template.mdx +++ b/docs/post-processors/vsphere-template.mdx @@ -21,6 +21,11 @@ the virtual machine as a template and moves it to your specified path. their respective End of General Support dates. For detailed information, refer to the [Broadcom Product Lifecycle](https://support.broadcom.com/group/ecx/productlifecycle). +## Examples + +Examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/examples/) +directory of the GitHub repository. + ## Configuration Reference The following configuration options are available for the post-processor. diff --git a/docs/post-processors/vsphere.mdx b/docs/post-processors/vsphere.mdx index 3a98c2c86..b81bd3ab9 100644 --- a/docs/post-processors/vsphere.mdx +++ b/docs/post-processors/vsphere.mdx @@ -19,6 +19,11 @@ The artifact must be a VMX, OVA, or OVF file. their respective End of General Support dates. For detailed information, refer to the [Broadcom Product Lifecycle](https://support.broadcom.com/group/ecx/productlifecycle). +## Examples + +Examples are available in the [examples](https://github.com/hashicorp/packer-plugin-vsphere/tree/main/examples/) +directory of the GitHub repository. + ## Configuration Reference The following configuration options are available for the post-processor. @@ -92,7 +97,7 @@ JSON Example: "cluster": "cluster-01", "datastore": "datastore-01", "vm_network": "VM Network", - "keep_input_artifact": true, + "keep_input_artifact": true } ] ] diff --git a/example/README.md b/example/README.md deleted file mode 100644 index e83da9ba8..000000000 --- a/example/README.md +++ /dev/null @@ -1,43 +0,0 @@ -## The Example Folder - -This folder contains a fully working example of the plugin usage. The -example defines the `required_plugins` block. A pre-defined GitHub Action -will run `packer init`, `packer validate`, and `packer build` to test the -plugin with the latest version available of Packer. - -The folder contains multiple HCL2 compatible files. The action will execute -Packer at this folder level running `packer init -upgrade .` and `packer build -.`. - -If the plugin requires authentication, the configuration should be provided via -GitHub Secrets and set as environment variables in the -[test-plugin-example.yml](/.github/workflows/test-plugin-example.yml) file. -Example: - -```yml - - name: Build - working-directory: ${{ github.event.inputs.folder }} - run: PACKER_LOG=${{ github.event.inputs.logs }} packer build . - env: - AUTH_KEY: ${{ secrets.AUTH_KEY }} - AUTH_PASSWORD: ${{ secrets.AUTH_PASSWORD }} -``` - -### Required variables - -To run this example the following variables are required - -```hcl -# file: vars.auto.pkrvars.hcl -bastion_host = "XXX.XXX.XXX.XXX" -bastion_user = "root" -datacenter_name = "datacenter" -esxi_host = "XXX.XXX.XXX.XXX" -esxi_password = "password" -esxi_user = "root" -vcenter_endpoint = "XXX.XXX.XXX.XXX" -vcenter_password = "password" -vcenter_user = "Administrator@vsphere.local" -vm_ip = "XXX.XXX.XXX.XXX" -gateway_ip = "XXX.XXX.XXX.XXX" -``` \ No newline at end of file diff --git a/example/build.pkr.hcl b/example/build.pkr.hcl deleted file mode 100644 index f482f79f9..000000000 --- a/example/build.pkr.hcl +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -packer { - required_version = ">= 1.7.0" - required_plugins { - vsphere = { - version = ">= v1.0.0" - source = "github.com/hashicorp/vsphere" - } - } -} - -build { - sources = [ - "source.vsphere-iso.example" - ] - - provisioner "shell-local" { - inline = ["echo the address is: $PACKER_HTTP_ADDR and build name is: $PACKER_BUILD_NAME"] - } -} diff --git a/example/preseed_hardcoded_ip.cfg b/example/preseed_hardcoded_ip.cfg deleted file mode 100644 index 2875d76ca..000000000 --- a/example/preseed_hardcoded_ip.cfg +++ /dev/null @@ -1,69 +0,0 @@ -# -# Based upon: https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt -# - -# localisation - -d-i debian-installer/locale string en_US.utf8 -d-i console-setup/ask_detect boolean false -d-i keyboard-configuration/layoutcode string us - -# networking -# Static network configuration. -# d-i netcfg/choose_interface ens192 -d-i netcfg/disable_autoconfig boolean true -d-i netcfg/get_nameservers string 8.8.8.8 -d-i netcfg/get_netmask string 255.255.255.248 -d-i netcfg/confirm_static boolean true - - -# d-i netcfg/choose_interface select auto -# d-i netcfg/get_hostname string unassigned-hostname -# d-i netcfg/get_domain string unassigned-domain -# d-i netcfg/wireless_wep string - -# apt mirrors -d-i mirror/country string manual -d-i mirror/http/directory string /ubuntu/ -d-i mirror/http/hostname string archive.ubuntu.com -d-i mirror/http/proxy string - -# clock and time zone -d-i clock-setup/utc boolean true -d-i time/zone string GMT -d-i clock-setup/ntp boolean true - -# partitioning -d-i partman-auto/method string lvm -d-i partman-lvm/device_remove_lvm boolean true -d-i partman-md/device_remove_md boolean true -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm_nooverwrite boolean true -d-i partman-auto-lvm/guided_size string max -d-i partman-auto/choose_recipe select atomic -d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -# users -d-i passwd/user-fullname string Vagrant -d-i passwd/username string vagrant -d-i passwd/user-password password vagrant -d-i passwd/user-password-again password vagrant -d-i user-setup/allow-password-weak boolean true -d-i user-setup/encrypt-home boolean false - -# packages -tasksel tasksel/first multiselect standard, ubuntu-server -d-i pkgsel/install-language-support boolean false -d-i pkgsel/include string openssh-server nfs-common open-vm-tools -d-i pkgsel/upgrade select full-upgrade -d-i pkgsel/update-policy select none -# postfix postfix/main_mailer_type select No configuration - -# boot loader -d-i grub-installer/only_debian boolean true - -# hide the shutdown notice -d-i finish-install/reboot_in_progress note \ No newline at end of file diff --git a/example/source.pkr.hcl b/example/source.pkr.hcl deleted file mode 100644 index 5caebf721..000000000 --- a/example/source.pkr.hcl +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -source "vsphere-iso" "example" { - datacenter = var.datacenter_name - vcenter_server = var.vcenter_endpoint - username = var.vcenter_user - password = var.vcenter_password - host = var.esxi_host - insecure_connection = true - - vm_name = "example-ubuntu" - guest_os_type = "ubuntu64Guest" - - ssh_username = "vagrant" - ssh_password = "vagrant" - - CPUs = 1 - RAM = 1024 - RAM_reserve_all = true - - disk_controller_type = ["pvscsi"] - datastore = "datastore1" - storage { - disk_size = 32768 - disk_thin_provisioned = true - } - - iso_urls = [ - "http://releases.ubuntu.com/16.04/ubuntu-16.04.7-server-amd64.iso" - ] - iso_checksum = "sha256:b23488689e16cad7a269eb2d3a3bf725d3457ee6b0868e00c8762d3816e25848" - - network_adapters { - network = "VM Network" - network_card = "vmxnet3" - } - - floppy_files = [ - "./preseed_hardcoded_ip.cfg" - ] - - boot_command = [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "/install/vmlinuz", - " initrd=/install/initrd.gz", - " priority=critical", - " locale=en_US", - " file=/media/preseed_hardcoded_ip.cfg", - " netcfg/get_ipaddress=${var.vm_ip}", - " netcfg/get_gateway=${var.gateway_ip}", - "" - ] -} \ No newline at end of file diff --git a/example/variables.pkr.hcl b/example/variables.pkr.hcl deleted file mode 100644 index 780743029..000000000 --- a/example/variables.pkr.hcl +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - -variable "bastion_host" { - type = string - default = "" -} -variable "bastion_user" { - type = string - default = "" -} -variable "datacenter_name" { - type = string - default = "" -} -variable "esxi_host" { - type = string - default = "" -} -variable "esxi_password" { - type = string - default = "" -} -variable "esxi_user" { - type = string - default = "" -} -variable "vcenter_endpoint" { - type = string - default = "" -} -variable "vcenter_password" { - type = string - default = "" -} -variable "vcenter_user" { - type = string - default = "" -} - -variable "gateway_ip" { - type = string - default = "" -} -variable "vm_ip" { - type = string - default = "" -} - - diff --git a/builder/vsphere/examples/clone/alpine.json b/examples/builder/vsphere-clone/alpine/alpine.json similarity index 100% rename from builder/vsphere/examples/clone/alpine.json rename to examples/builder/vsphere-clone/alpine/alpine.json diff --git a/builder/vsphere/examples/clone/alpine.pkr.hcl b/examples/builder/vsphere-clone/alpine/alpine.pkr.hcl similarity index 100% rename from builder/vsphere/examples/clone/alpine.pkr.hcl rename to examples/builder/vsphere-clone/alpine/alpine.pkr.hcl diff --git a/builder/vsphere/examples/alpine/alpine-3.8.json b/examples/builder/vsphere-iso/alpine/alpine-3.8.json similarity index 100% rename from builder/vsphere/examples/alpine/alpine-3.8.json rename to examples/builder/vsphere-iso/alpine/alpine-3.8.json diff --git a/builder/vsphere/examples/alpine/alpine-3.8.pkr.hcl b/examples/builder/vsphere-iso/alpine/alpine-3.8.pkr.hcl similarity index 100% rename from builder/vsphere/examples/alpine/alpine-3.8.pkr.hcl rename to examples/builder/vsphere-iso/alpine/alpine-3.8.pkr.hcl diff --git a/builder/vsphere/examples/alpine/answerfile b/examples/builder/vsphere-iso/alpine/answerfile similarity index 100% rename from builder/vsphere/examples/alpine/answerfile rename to examples/builder/vsphere-iso/alpine/answerfile diff --git a/builder/vsphere/examples/alpine/setup.sh b/examples/builder/vsphere-iso/alpine/setup.sh similarity index 100% rename from builder/vsphere/examples/alpine/setup.sh rename to examples/builder/vsphere-iso/alpine/setup.sh diff --git a/builder/vsphere/examples/ubuntu/preseed.cfg b/examples/builder/vsphere-iso/ubuntu/preseed.cfg similarity index 100% rename from builder/vsphere/examples/ubuntu/preseed.cfg rename to examples/builder/vsphere-iso/ubuntu/preseed.cfg diff --git a/builder/vsphere/examples/ubuntu/ubuntu-16.04.json b/examples/builder/vsphere-iso/ubuntu/ubuntu-16.04.json similarity index 100% rename from builder/vsphere/examples/ubuntu/ubuntu-16.04.json rename to examples/builder/vsphere-iso/ubuntu/ubuntu-16.04.json diff --git a/builder/vsphere/examples/ubuntu/ubuntu-16.04.pkr.hcl b/examples/builder/vsphere-iso/ubuntu/ubuntu-16.04.pkr.hcl similarity index 100% rename from builder/vsphere/examples/ubuntu/ubuntu-16.04.pkr.hcl rename to examples/builder/vsphere-iso/ubuntu/ubuntu-16.04.pkr.hcl diff --git a/builder/vsphere/examples/windows/.gitattributes b/examples/builder/vsphere-iso/windows/.gitattributes similarity index 100% rename from builder/vsphere/examples/windows/.gitattributes rename to examples/builder/vsphere-iso/windows/.gitattributes diff --git a/builder/vsphere/examples/windows/setup/Autounattend.xml b/examples/builder/vsphere-iso/windows/setup/Autounattend.xml similarity index 100% rename from builder/vsphere/examples/windows/setup/Autounattend.xml rename to examples/builder/vsphere-iso/windows/setup/Autounattend.xml diff --git a/builder/vsphere/examples/windows/setup/setup.ps1 b/examples/builder/vsphere-iso/windows/setup/setup.ps1 similarity index 100% rename from builder/vsphere/examples/windows/setup/setup.ps1 rename to examples/builder/vsphere-iso/windows/setup/setup.ps1 diff --git a/builder/vsphere/examples/windows/setup/vmtools.cmd b/examples/builder/vsphere-iso/windows/setup/vmtools.cmd similarity index 100% rename from builder/vsphere/examples/windows/setup/vmtools.cmd rename to examples/builder/vsphere-iso/windows/setup/vmtools.cmd diff --git a/builder/vsphere/examples/windows/windows-10.json b/examples/builder/vsphere-iso/windows/windows-10.json similarity index 100% rename from builder/vsphere/examples/windows/windows-10.json rename to examples/builder/vsphere-iso/windows/windows-10.json diff --git a/builder/vsphere/examples/windows/windows-10.pkr.hcl b/examples/builder/vsphere-iso/windows/windows-10.pkr.hcl similarity index 100% rename from builder/vsphere/examples/windows/windows-10.pkr.hcl rename to examples/builder/vsphere-iso/windows/windows-10.pkr.hcl diff --git a/builder/vsphere/examples/supervisor/cleanup-playbook.yml b/examples/builder/vsphere-supervisor/cleanup-playbook.yml similarity index 100% rename from builder/vsphere/examples/supervisor/cleanup-playbook.yml rename to examples/builder/vsphere-supervisor/cleanup-playbook.yml diff --git a/builder/vsphere/examples/supervisor/general-template.pkr.hcl b/examples/builder/vsphere-supervisor/general-template.pkr.hcl similarity index 100% rename from builder/vsphere/examples/supervisor/general-template.pkr.hcl rename to examples/builder/vsphere-supervisor/general-template.pkr.hcl diff --git a/builder/vsphere/examples/supervisor/jenkins-template.pkr.hcl b/examples/builder/vsphere-supervisor/jenkins-template.pkr.hcl similarity index 100% rename from builder/vsphere/examples/supervisor/jenkins-template.pkr.hcl rename to examples/builder/vsphere-supervisor/jenkins-template.pkr.hcl diff --git a/builder/vsphere/examples/supervisor/nginx-template.pkr.hcl b/examples/builder/vsphere-supervisor/nginx-template.pkr.hcl similarity index 100% rename from builder/vsphere/examples/supervisor/nginx-template.pkr.hcl rename to examples/builder/vsphere-supervisor/nginx-template.pkr.hcl diff --git a/builder/vsphere/examples/supervisor/sysprep-unattend-data.yml b/examples/builder/vsphere-supervisor/sysprep-unattend-data.yml similarity index 100% rename from builder/vsphere/examples/supervisor/sysprep-unattend-data.yml rename to examples/builder/vsphere-supervisor/sysprep-unattend-data.yml diff --git a/builder/vsphere/examples/supervisor/windows-template.pkr.hcl b/examples/builder/vsphere-supervisor/windows-template.pkr.hcl similarity index 100% rename from builder/vsphere/examples/supervisor/windows-template.pkr.hcl rename to examples/builder/vsphere-supervisor/windows-template.pkr.hcl diff --git a/builder/vsphere/examples/driver/main.go b/examples/driver/main.go similarity index 100% rename from builder/vsphere/examples/driver/main.go rename to examples/driver/main.go