{"id":18512810,"url":"https://github.com/vmware/python-script-for-esxi-imaging","last_synced_at":"2025-10-29T20:04:32.427Z","repository":{"id":246046789,"uuid":"813753016","full_name":"vmware/python-script-for-esxi-imaging","owner":"vmware","description":"Python script for creating an ESXi ISO image and installation script for unattended ESXi installation and configuration.","archived":false,"fork":false,"pushed_at":"2025-01-20T15:31:51.000Z","size":50,"stargazers_count":4,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-24T00:06:25.805Z","etag":null,"topics":["esxi","python-script","python3","vmware","vmware-cloud-foundation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vmware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-11T17:11:48.000Z","updated_at":"2025-01-20T15:31:54.000Z","dependencies_parsed_at":"2024-06-25T15:12:33.705Z","dependency_job_id":"2e40a541-5917-435c-8bf0-3248e47debbb","html_url":"https://github.com/vmware/python-script-for-esxi-imaging","commit_stats":null,"previous_names":["vmware/python-script-for-esxi-imaging"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fpython-script-for-esxi-imaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fpython-script-for-esxi-imaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fpython-script-for-esxi-imaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fpython-script-for-esxi-imaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vmware","download_url":"https://codeload.github.com/vmware/python-script-for-esxi-imaging/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987071,"owners_count":21028891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esxi","python-script","python3","vmware","vmware-cloud-foundation"],"created_at":"2024-11-06T15:35:31.566Z","updated_at":"2025-10-29T20:04:32.408Z","avatar_url":"https://github.com/vmware.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable first-line-h1 no-inline-html --\u003e\n\n# Python Script for ESXi Imaging\n\n## Table of Contents\n\n- [Python Script for ESXi Imaging](#python-script-for-esxi-imaging)\n  - [Table of Contents](#table-of-contents)\n  - [Introduction](#introduction)\n  - [Requirements](#requirements)\n    - [System Requirements](#system-requirements)\n    - [ESXi](#esxi)\n    - [Operating System](#operating-system)\n    - [Python](#python)\n  - [Generating the ESXi ISO Image](#generating-the-esxi-iso-image)\n  - [Troubleshooting](#troubleshooting)\n  - [Limitations](#limitations)\n  - [Known Issues](#known-issues)\n  - [Contributing](#contributing)\n  - [Support](#support)\n  - [License](#license)\n\n## Introduction\n\nThe Python Script for ESXi Imaging creates an ESXi ISO image with an installation script (kickstart\nfile) from the base ISO image to automate ESXi installation and configuration for VMware vSphere\nFoundation (VVF) and VMware Cloud Foundation (VCF).\n\nThe Python script uses the `re-image-hosts.json` and `firstboot-scripts.txt` files to generate the\nrequired installation script.\n\n## Requirements\n\n### System Requirements\n\nTo install ESXi, your system must meet specific requirements. Refer the [ESXi Requirements][docs-esxi-requirements]\nfor more details.\n\n### ESXi\n\n- ESXi 7.0, ESXi 8.0 and ESX 9.0.\n- The ESXi installer ISO image `VMware-VMvisor-Installer-x.x.x-XXXXXX.x86_64.iso`, where `x.x.x` is\n  the version of ESXi you are installing, and `XXXXXX` is the build number of the installer ISO\n  image.\n\n### Operating System\n\n- [VMware Photon OS][info-photon] 4.0 Rev2\n\n  - You can use the [Photon OS sample appliance][download-sample-appliance] or use the code from the [GitHub project][gh-sample-appliance]\n    to build the appliance.\n  - The sample appliance includes all required packages, otherwise, you must install the following\n    packages:\n\n    ```console\n    tdnf install -y \\\n      git \\\n      python3-pip \\\n      jq \\\n      cdrkit\n    ```\n\n  - Ensure you have enough space to generate the ISO files.\n\n### Python\n\n- [Python 3.10][info-python], included by default on Photon OS 4.0 Rev2.\n\n- The sample appliance includes all required Python packages, otherwise you must install the\n  following packages:\n\n  ```console\n  pip install maskpass==0.3.1\n  pip install psutil\n  ```\n\n## Generating the ESXi ISO Image\n\n1. Use a Secure Shell (SSH) client to log in as the `root` user to the photon appliance at\n   `\u003chost_virtual_machine_fqdn\u003e:22`.\n\n2. Clone the repository into current directory.\n\n   ```console\n   git clone https://github.com/vmware/python-script-for-esxi-imaging.git\n   cd python-script-for-esxi-imaging\n   ```\n\n3. Download the ESXi installer (ISO file) from your OEM or the [Broadcom Support Portal][kb-broadcom-downloads]\n   and place the ISO file in the `python-script-for-esxi-imaging` directory that has been created\n   during previous step.\n\n4. Modify the [`re-image-hosts.json`][sample-json] file to update details like the ISO file name,\n   MD5 checksum, network configuration, and installation disk.\n\n   | Information                  | Required or Optional   | Comments                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n   | ---------------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n   | `esxiIsoFileName`            | Required               | Specifies the filename of the ESXi installer image. Must available in the directory where the script is run.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n   | `isoMdSum`                   | Required               | Specifies the MD5 checksum of the ESXI installer image.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n   | `AcceptEsxiLicenseAgreement` | Required               | Specify option `Yes` to accept the ESXi license agreement. By using the automation, you are accepting EULA for the ESXi                                                                                                                                                                                                                                                                                                                                                                                                                                              |\n   | `dns`                        | Required for Static IP | Specifies the DNS servers for the ESXi host. Accepts up to two entries.\u003cbr/\u003e\u003cbr/\u003eExample:\u003cbr/\u003e\u003cbr/\u003e 1. `\"dns\": [\"172.16.11.4\",\"172.16.11.5\"]`\u003cbr/\u003e 2. `\"dns\": [\"172.16.11.4\"]`                                                                                                                                                                                                                                                                                                                                                                                        |\n   | `dnsSuffix0`                  | Required for Static IP | Specifies the DNS suffix for the ESXi host.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |\n   | `macAddress`                 | Required               | Specifies the MAC address of the network card used by the ESXi host. The management network will be mapped to the specified network adapter after the ESXi installation.                                                                                                                                                                                                                                                                                                                                                                                               |\n   | `hostName`                   | Required for Static IP | Specifies the hostname for the ESXi host.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n   | `clearPart`                  | Optional               | Specifies to clear any existing partitions on the disk of the ESXi host. \u003cbr/\u003e\u003cbr/\u003eExample:\u003cbr/\u003e\u003cbr/\u003e `\"clearPart\": \"--alldrives --overwritevmfs\"` --\u003e Allows clearing of partitions on every drive. Refer to the sample JSON and [product documentation][vsphere8-esxi-installation] for more details.                                                                                                                                                                                                                                                               |\n   | `installDisk`                | Required               | Specifies the disk to install ESXi. \u003cbr/\u003e\u003cbr/\u003eExamples:\u003cbr/\u003e\u003cbr/\u003e 1. `\"installDisk\": \"local\"` --\u003e Deletes the existing VMFS partitions and installs the image on the first eligible disk found.\u003cbr/\u003e 2.`\"installDisk\": \"usb\"` ---\u003e Deletes the existing VMFS partitions and install the image on the USB or SD device.\u003cbr/\u003e 3. `\"installDisk\": \"--firstdisk=ATA --overwritevmfs\"` ---\u003e Deletes the existing VMFS partitions and install the image on the ATA disk. Refer to the sample JSON and [product documentation][vsphere8-esxi-installation] for more details.   |\n   | `mgmtIpv4`                   | Required               | Specifies the IPv4 address for the ESXi host. \u003cbr/\u003e\u003cbr/\u003eExamples:\u003cbr/\u003e\u003cbr/\u003e 1. `\"mgmtIpv4\": \"dhcp\"`\u003cbr/\u003e 2.`\"mgmtIpv4\": \"172.16.11.101\"`                                                                                                                                                                                                                                                                                                                                                                                                                              |\n   | `mgmtGateway`                | Required for Static IP | Specifies the IPv4 default gateway for the ESXi host.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |\n   | `mgmtVlanId`                 | Required               | Specifies the VLAN for the ESXi host management network. Used with either DHCP or a static IP address.                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n\n5. Run the following command to validate the updated `re-image-hosts.json` file and remediate any\n   error messages found.\n\n   ```console\n   jq . re-image-hosts.json 1\u003e /dev/null\n   ```\n\n6. Update the post-install commands in the [`firstboot-scripts.txt`][firstboot-scripts] file to be\n   run after installation. The file includes examples of post-install commands. You can add or\n   remove post-install commands based on your specific requirements.\n\n7. Run the following command to generate the ISO file.\n\n   ```console\n   python create-custom-iso.py -j re-image-hosts.json\n   ```\n\n   If you are using the [Photon OS sample appliance][download-sample-appliance] and logged in as the\n   `admin` user, run the command with sudo.\n\n   ```console\n   sudo python create-custom-iso.py -j re-image-hosts.json\n   ```\n\n8. Enter and confirm the password for the ESXi root account.\n\n    The script generates an ISO file with a timestamp that includes the kickstart file after\n    successful validation. If the optional parameter `-s` or `--suffix` is specified in the command\n    line, the given value will be appended to the output ISO file instead of the timestamp.\n\n    You can use this ISO installer image for regular boot or UEFI boot.\n\n    You can use the [remote management applications][docs-esxi-install-remote-management-applications]\n    to install ESXi hosts remotely.\n\n## Troubleshooting\n\n- If the specified MAC address in JSON does not match with the host then the installation wizard\n  would throw an error:\n\n  ```console\n  An error has occurred while parsing the installation script. Could not open the file. no such file\n  or directory.\n  ```\n\n  Ensure that proper MAC address is specified.\n\n- If you encounter an error like:\n\n  ```console\n  mkisofs: command not found\n  ERROR Create an ISO with the updated KS file command did not run successfully. Exiting...\n  ```\n\n  Ensure that `mkisofs` is available. If not, install the `cdrkit` package and try again.\n\n- After the installation is complete, if the firstboot scripts are not run, please refer to\n  `/var/log/kickstart.log`.\n- To view the kickstart file's content in the generated ISO file, run the following command\n\n  ```console\n  python display-ks-content.py -i \u003cyour_generated_iso_file\u003e\n  ```\n\n   If you are using the [Photon OS sample appliance][download-sample-appliance], run the command\n   with sudo.\n\n  ```console\n    sudo python display-ks-content.py -i \u003cyour_generated_iso_file\u003e\n    ```\n\n## Limitations\n\n- Does not support upgrades; only the installation scenario is supported.\n\n## Known Issues\n\n- If secure boot is enabled, the commands in the `firstboot-scripts.txt` file will not be executed.\n\n## Contributing\n\nWe encourage community contributions! To get started, please refer to the [\n  contribution guidelines][contributing].\n\n## Support\n\nThis Python module is not supported by VMware Support Services.\n\nWe welcome you to use the [GitHub Issues][gh-issues] to report bugs or suggest enhancements.\n\nIn order to have a good experience with our community, we recommend that you read the [contributing guidelines][contributing].\n\nWhen filing an issue, please check existing open, or recently closed, issues to make sure someone else hasn't already\nreported the issue.\n\nPlease try to include as much information as you can. Details like these are incredibly useful:\n\n- A reproducible test case or series of steps.\n- Any modifications you've made relevant to the bug.\n- Anything unusual about your environment or deployment.\n\n## License\n\n© Broadcom. All Rights Reserved.\n\nThe term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.\n\nThis project is licensed under the [BSD 2-Clause License](LICENSE).\n\n[docs-esxi-install-remote-management-applications]: https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/esxi-installation-and-setup-8-0.html\n[docs-esxi-requirements]: https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/esxi-installation-and-setup-8-0.html\n[download-sample-appliance]: https://broadcom.box.com/v/get-vvs-sample-appliance\n[contributing]: CONTRIBUTING.md\n[sample-json]: re-image-hosts.json\n[firstboot-scripts]: firstboot-scripts.txt\n[gh-issues]: https://github.com/vmware/\n[gh-sample-appliance]: https://github.com/vmware-samples/validated-solutions-for-cloud-foundation/tree/main/appliance\n[info-photon]: https://vmware.github.io/photon/\n[info-python]: https://www.python.org\n[kb-broadcom-downloads]: https://knowledge.broadcom.com/external/article?articleId=142814\n[vsphere8-esxi-installation]: https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/esxi-installation-and-setup-8-0.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware%2Fpython-script-for-esxi-imaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmware%2Fpython-script-for-esxi-imaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware%2Fpython-script-for-esxi-imaging/lists"}