-
-
Save jillr/97e2419f93ab244d9fb2c09a48fd9998 to your computer and use it in GitHub Desktop.
Ansible VMware image build process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1: Ensure to have the images | |
The first things you need are the images: | |
VMWare-VCSA-all-* | |
VMWare-VMvisor-installer-* | |
Images should be reuploaded before the license expire: | |
VCSA 60 days | |
ESXi 90 days | |
#2: Build the ESXi images | |
First of all just create a virtual environment: | |
python3 -m venv ~/tmp/test-env | |
source ~/tmp/test-env/bin/activate | |
Install Virt-Lightning and configure KVM as explained here: https://github.com/virt-lightning/esxi-cloud-images#kvm-configuration | |
git clone [email protected]:virt-lightning/esxi-cloud-images.git | |
cd esxi-cloud-images | |
vim build.sh | |
Ensure you set: | |
mkpasswd --method=SHA-512 --stdin | |
rootpw –iscrypted <generated password> | |
If the SHA512 output has any special characters, escape them in the build.sh file. For example: | |
The string S$bKaf/H230Bh | |
Should be: S\$bKaf\/H230Bh | |
You add your key here: | |
https://github.com/virt-lightning/esxi-cloud-images/blob/master/build.sh#L66 | |
If libvirt on your computer does not have a default network, or uses some other network for basic DHCP based VMs, change the network name in the virt-install command here (or any other custom options needed for your local libvirt hypervisor) https://github.com/virt-lightning/esxi-cloud-images/blob/master/build.sh#L99 | |
./build.sh ~/Downloads/VMware-VMvisor-Installer-<your version>.iso | |
Once the image has been built, you can finally upload it to OpenStack images. <Ansible authentication instructions redacted> | |
Images are stored in two regions (https://github.com/ansible/zuul-config/blob/master/playbooks/set-up-mirrors/main.yaml#L3-L33) so you will need to update both ams1 and ca-ymq-1. | |
#3: Build the VCSA image | |
The VCSA image requires a working virt-lightning (vl) environment. If you do not already have the hard-coded libvirt storage pool that vl requires you must created it. | |
You need root privilege to create the storage pool, please do: | |
sudo mkdir -p /var/lib/virt-lightning/pool/upstream | |
sudo chown -R libvirt-qemu:kvm /var/lib/virt-lightning/pool | |
sudo chown -R jill /var/lib/virt-lightning/pool/upstream | |
sudo chmod 775 /var/lib/virt-lightning | |
sudo chmod 775 /var/lib/virt-lightning/pool /var/lib/virt-lightning/pool/upstream | |
git clone [email protected]:virt-lightning/vcsa_to_qcow2.git | |
cd vcsa_to_qcow2 | |
You will need the goneri.vcenter-instance role available in your ANSIBLE_ROLES_PATH | |
vcsa_to_qcow2$ ansible-galaxy role install -r requirements.yaml | |
If you are on a Debian or Ubuntu based OS you will need to edit the package name here: | |
goneri.vcenter-instance/tasks/main.yaml | |
--- | |
- package: | |
- name: libnsl | |
+ name: libnsl2 | |
state: present | |
become: true | |
Ensure you have also installed the Python deps for this repo: | |
(.virt-lightning) jill@lab:~/src/vmware/vcsa_to_qcow2$ pip install -r requirements.txt | |
And ensure that the ESXi image is available in the vl storage pool if that is not your default libvirt storage pool: | |
sudo cp -v esxi-7.0U3F-20036589-STANDARD.qcow2 esxi-7.0U3F-20036589-STANDARD.yaml /var/lib/virt-lightning/pool/upstream/ | |
Modify the distro version of this file https://github.com/virt-lightning/vcsa_to_qcow2/blob/master/virt-lightning.yaml with your esxi one. | |
Add become: true here https://github.com/virt-lightning/vcsa_to_qcow2/blob/master/install_vcsa.yml#L8 | |
Comment these lines https://github.com/virt-lightning/vcsa_to_qcow2/blob/master/install_vcsa.yml#L30 and https://github.com/virt-lightning/vcsa_to_qcow2/blob/master/install_vcsa.yml#L38 | |
Add here https://github.com/virt-lightning/vcsa_to_qcow2/blob/master/install_vcsa.yml#L57 | |
vars: | |
ansible_python_interpreter: <your venv path> | |
Modify this line https://github.com/virt-lightning/vcsa_to_qcow2/blob/master/run.sh#L15 with: | |
ansible-playbook install_vcsa.yml -i inventory -e "${extra_args}" -vvv –ask-become-pass | |
./run.sh ~/Downloads/VMware-VCSA-all-<your version>.iso | |
Note: you will need to remove the vcenter.test entry from your /etc/hosts after the VCSA image creation. Ideally, this should be done automatically. | |
Note: There is a chance you will have permissions problems with the virt-* commands towards the end of the run.sh script. (after the curl command for the raw image). If that happens you may need to run the script with sudo (comment out everything else that has succeeded in the script already so you don't need to repeat the hour+ long process to that point if this happens, as long as you successfully get the ~48.5GB vCenterServerAppliance.raw file first). | |
Once the image has been built, you can upload to OpenStack: | |
openstack image create --disk-format qcow2 --container-format bare --file VMware-VCSA-all-<your version>.qcow2 --property hw_qemu_guest_agent=no --min-disk 20 --min-ram 9000 --property hw_vif_model=e1000e VMware-VCSA-all-<your version> --os-cloud vexxhost --os-region ams1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment