{"id":15676926,"url":"https://github.com/rgl/esxi-vagrant","last_synced_at":"2025-05-07T00:34:59.880Z","repository":{"id":40426538,"uuid":"259124817","full_name":"rgl/esxi-vagrant","owner":"rgl","description":"ESXi running in QEMU/KVM/libvirt/ESXi wrapped in a vagrant environment","archived":false,"fork":false,"pushed_at":"2022-12-10T15:02:30.000Z","size":45,"stargazers_count":18,"open_issues_count":3,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-31T04:36:20.086Z","etag":null,"topics":["esx","esxi","kvm","libvirt","packer","vagrant"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rgl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-26T20:18:40.000Z","updated_at":"2025-01-21T09:58:22.000Z","dependencies_parsed_at":"2023-01-26T03:30:23.359Z","dependency_job_id":null,"html_url":"https://github.com/rgl/esxi-vagrant","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2Fesxi-vagrant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2Fesxi-vagrant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2Fesxi-vagrant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2Fesxi-vagrant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rgl","download_url":"https://codeload.github.com/rgl/esxi-vagrant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252792765,"owners_count":21805028,"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":["esx","esxi","kvm","libvirt","packer","vagrant"],"created_at":"2024-10-03T16:07:25.204Z","updated_at":"2025-05-07T00:34:59.835Z","avatar_url":"https://github.com/rgl.png","language":"Shell","readme":"# About\n\nThis is a packer template for installing ESXi inside a VM in a way that\ncan be later used as a vagrant base box.\n\n**NB** This builds a base box **without any datastore**. This means you\nhave to create one yourself in your vagrant environment (see the\n[vagrant example](example)).\n\n**NB** If you want to create a base box with a datastore, you have to edit\nthe `esxi.json` file to add `autoPartitionOSDataSize=4096` to the\n`boot_command` array (after the `ks=` element) and increase `disk_size` to\na size that is big enough to hold your datastore.\n\n**NB** This is needed until [packer#9160](https://github.com/hashicorp/packer/issues/9160) and [vagrant-libvirt#602](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/602) are addressed.\n\n## Usage\n\n**NB** These instructions are for an Ubuntu 22.04 host.\n\nInstall Packer 1.6.0+ ([because we need to use the qemu bridge mode](https://github.com/hashicorp/packer/issues/9156)).\n\nDownload the [Free ESXi 8.0 (aka vSphere Hypervisor) iso file](https://www.vmware.com/go/get-free-esxi).\n\n### qemu-kvm usage\n\nInstall qemu-kvm:\n\n```bash\napt-get install -y qemu-kvm\napt-get install -y sysfsutils\nsystool -m kvm_intel -v\n```\n\nAllow non-root users to add tap interfaces to a bridge:\n\n```bash\n# allow non-root users to add tap interfaces to virbr0.\n# NB a tap (L2) interface is created by qemu when we use a bridge netdev.\nsudo chmod u+s /usr/lib/qemu/qemu-bridge-helper\nsudo bash -c 'mkdir -p /etc/qemu \u0026\u0026 echo \"allow virbr0\" \u003e\u003e/etc/qemu/bridge.conf'\n```\n\nCreate the base box and follow the returned instructions:\n\n```bash\ntime make build-libvirt\n```\n\nLaunch the vagrant example:\n\n```bash\napt-get install -y virt-manager libvirt-dev\nvagrant plugin install vagrant-libvirt # see https://github.com/vagrant-libvirt/vagrant-libvirt\ncd example\ntime vagrant up\n```\n\nTry using it:\n\n```bash\nvagrant ssh\nps -c\nesxcli software vib list\nesxcli system version get\nexit\n```\n\nCreate the [debian-vagrant base box and example](https://github.com/rgl/debian-vagrant) within this esxi instance.\n\n#### raw qemu-kvm usage\n\nTo fiddle with ESXi it can be more straightforward to directly use qemu, e.g.:\n\n```bash\n# allow non-root users to add tap interfaces to virbr0.\n# NB a tap (L2) interface is created by qemu when we use a bridge netdev.\nsudo chmod u+s /usr/lib/qemu/qemu-bridge-helper\nsudo bash -c 'mkdir -p /etc/qemu \u0026\u0026 echo \"allow virbr0\" \u003e\u003e/etc/qemu/bridge.conf'\n\n# create an empty disk.\nqemu-img create -f qcow2 test.qcow2 40G\nqemu-img info test.qcow2\n\n# launch the vm.\n# NB to known the available options use:\n#       qemu-system-x86_64 -machine help\n#       qemu-system-x86_64 -cpu help\n#       qemu-system-x86_64 -netdev help\n#       qemu-system-x86_64 -device help\n# see http://wiki.qemu.org/download/qemu-doc.html\nqemu-system-x86_64 \\\n  -name 'ESXi Test Baseline' \\\n  -machine pc,accel=kvm \\\n  -cpu host \\\n  -m 4G \\\n  -smp cores=4 \\\n  -k pt \\\n  -qmp unix:test.socket,server,nowait \\\n  -netdev bridge,id=net0,br=virbr0 \\\n  -device vmxnet3,id=nic0,netdev=net0,mac=52:54:00:12:34:56 \\\n  -drive if=ide,media=disk,discard=unmap,format=qcow2,cache=unsafe,file=test.qcow2 \\\n  -drive if=ide,media=cdrom,file=VMware-VMvisor-Installer-8.0-20513097.x86_64.iso\n\n# wait for the mac address to appear in the virbr0 interface, e.g. it\n# should output something alike:\n#   IP address       HW type     Flags       HW address            Mask     Device\n#   192.168.121.111  0x1         0x2         52:54:00:12:34:56     *        virbr0\ncat /proc/net/arp\n\n# play with the qmp socket.\n# see https://gist.github.com/rgl/dc38c6875a53469fdebb2e9c0a220c6c.\nnc -U test.socket      # directly access the socket.\nqmp-shell test.socket  # access it in a friendlier way.\n\n# open a ssh session (after you enable ssh access in ESXi).\nssh -v root@192.168.121.111\n\n# open a browser session.\nxdg-open https://192.168.121.111\n```\n\n### VMware ESXi usage\n\nSet your ESXi details, and test the connection to ESXi:\n\n```bash\nvagrant plugin install vagrant-vmware-esxi\ncat \u003esecrets.sh \u003c\u003cEOF\nexport ESXI_HOSTNAME='esxi.test'\nexport ESXI_USERNAME='root'\nexport ESXI_PASSWORD='HeyH0Password!'\nexport ESXI_DATASTORE='datastore1'\n# NB for the nested VMs to access the network, this VLAN port group security\n#    policy MUST be configured to Accept:\n#      Promiscuous mode\n#      Forged transmits\nexport ESXI_NETWORK='esxi'\nexport ESXI_TEMPLATE='template-esxi-8.0.0-amd64-esxi'\nEOF\nsource secrets.sh\n```\n\nUpload the ESXi ISO to the datastore.\n\nType `make build-esxi` and follow the instructions.\n\nTry the example vagrant example:\n\n```bash\ncd example\nsource ../secrets.sh\nvagrant up --provider=vmware_esxi --no-destroy-on-error\nvagrant ssh\nps -c\nesxcli software vib list\nesxcli system version get\nexit\nvagrant destroy -f\n```\n\n### VMware vSphere usage\n\nDownload [govc](https://github.com/vmware/govmomi/releases/latest) and place it inside your `/usr/local/bin` directory.\n\nSet your vSphere details, and test the connection to vSphere:\n\n```bash\nsudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev\nvagrant plugin install vagrant-vsphere\ncat \u003esecrets.sh \u003c\u003cEOF\nexport GOVC_INSECURE='1'\nexport GOVC_HOST='vsphere.local'\nexport GOVC_URL=\"https://$GOVC_HOST/sdk\"\nexport GOVC_USERNAME='administrator@vsphere.local'\nexport GOVC_PASSWORD='password'\nexport GOVC_DATACENTER='Datacenter'\nexport GOVC_CLUSTER='Cluster'\nexport GOVC_DATASTORE='Datastore'\nexport VSPHERE_OS_ISO=\"[$GOVC_DATASTORE] iso/VMware-VMvisor-Installer-8.0-20513097.x86_64.iso\"\nexport VSPHERE_ESXI_HOST='esxi.local'\nexport VSPHERE_TEMPLATE_FOLDER='test/templates'\nexport VSPHERE_TEMPLATE_NAME=\"$VSPHERE_TEMPLATE_FOLDER/esxi-8.0.0-amd64-vsphere\"\nexport VSPHERE_VM_FOLDER='test'\nexport VSPHERE_VM_NAME='esxi-vagrant-example'\n# NB for the nested VMs to access the network, this VLAN port group security\n#    policy MUST be configured to Accept:\n#      Promiscuous mode\n#      Forged transmits\nexport VSPHERE_VLAN='packer'\nEOF\nsource secrets.sh\n# see https://github.com/vmware/govmomi/blob/master/govc/USAGE.md\ngovc version\ngovc about\ngovc datacenter.info # list datacenters\ngovc find # find all managed objects\n```\n\nUpload the ESXi ISO to the datastore.\n\nType `make build-vsphere` and follow the instructions.\n\nTry the example vagrant example:\n\n```bash\ncd example\nsource ../secrets.sh\nvagrant up --provider=vsphere --no-destroy-on-error\nvagrant ssh\nps -c\nesxcli software vib list\nesxcli system version get\nexit\nvagrant destroy -f\n```\n\n## Notes\n\n* At the ESXi console you can press the following key\n  combinations to switch between the virtual consoles:\n  * `Alt+F1`: ESX Shell / Boot console.\n  * `Alt+F2`: Direct Console User Interface (DCUI) console.\n  * `Alt+F11`: Status console.\n  * `Alt+F12`: Log console.\n* In case you want to start virtual machines within the ESXi environment it is highly recommended\nto enable nested virtualization on your host system, see:\n  * [Fedora Docs: How to enable nested virtualization with KVM](https://docs.fedoraproject.org/en-US/quick-docs/using-nested-virtualization-in-kvm/)\n\n## Reference\n\n* [VMware Docs: Installing or Upgrading Hosts by Using a Script](https://docs.vmware.com/en/VMware-vSphere/8.0/vsphere-esxi-upgrade/GUID-870A07BC-F8B4-47AF-9476-D542BA53F1F5.html).\n* [VMware Docs: Installation and Upgrade Script Commands](https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.esxi.install.doc/GUID-61A14EBB-5CF3-43EE-87EF-DB8EC6D83698.html).\n* [VMware Docs: Using vmkfstools](https://docs.vmware.com/en/VMware-vSphere/8.0/vsphere-storage/GUID-A5D85C33-A510-4A3E-8FC7-93E6BA0A048F.html).\n* [How to properly clone a Nested ESXi VM?](https://williamlam.com/2013/12/how-to-properly-clone-nested-esxi-vm.html).\n* [vmk0 management network MAC address is not updated when NIC card is replaced or vmkernel has duplicate MAC address (1031111)](https://kb.vmware.com/s/article/1031111).\n* [Applying vSphere host configuration changes after an unclean shutdown (2001780)](https://kb.vmware.com/s/article/2001780).\n* [Changing the default size of the ESX-OSData volume in ESXi 7.0](https://williamlam.com/2020/05/changing-the-default-size-of-the-esx-osdata-volume-in-esxi-7-0.html).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgl%2Fesxi-vagrant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frgl%2Fesxi-vagrant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgl%2Fesxi-vagrant/lists"}