diff --git a/ubuntu/build-ubuntu-20.04.sh b/ubuntu/build-ubuntu-20.04.sh new file mode 100755 index 0000000..7238861 --- /dev/null +++ b/ubuntu/build-ubuntu-20.04.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Building Ubuntu 20.04.2 LTS (Focal Fossa) template" + +packer build -force -var-file=../clouds/var-infra-z67.json ubuntu-20.04.json diff --git a/ubuntu/http/20.04/meta-data b/ubuntu/http/20.04/meta-data new file mode 100644 index 0000000..e69de29 diff --git a/ubuntu/http/20.04/user-data b/ubuntu/http/20.04/user-data new file mode 100644 index 0000000..54e94e6 --- /dev/null +++ b/ubuntu/http/20.04/user-data @@ -0,0 +1,27 @@ +#cloud-config +autoinstall: + version: 1 + locale: en_US + keyboard: + layout: en + variant: us + network: + network: + version: 2 + ethernets: + ens192: + dhcp4: true + storage: + layout: + name: lvm + identity: + hostname: ubuntu-packer + username: packer + password: $6$yRp1sC9EfcWC6bg$JLJ8y/UPg6EQsyjIck78qvO6/TdA8wnzeiBPyICI2jwWtU0.sYEpyY4fSxmbVAeB74zgPdVECE/aeW4alye2X0 + ssh: + install-server: yes + allow-pw: true + user-data: + disable_root: false + late-commands: + - echo 'packer ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/packer diff --git a/ubuntu/ubuntu-20.04.json b/ubuntu/ubuntu-20.04.json new file mode 100644 index 0000000..61d584b --- /dev/null +++ b/ubuntu/ubuntu-20.04.json @@ -0,0 +1,91 @@ +{ + "variables": + { + "author": "Romain Decker", + "website": "https://cloudmaniac.net", + "description": "Creation of a Ubuntu 20.04.2.0 LTS (Focal Fossa) vSphere template", + "var_vm_name": "packer-ubuntu-20.04", + "var_vm_hostname": "packer-ubuntu-20.04", + "var_vsphere_template_folder": "templates/packer/ubuntu", + "var_vm_guestos": "ubuntu64Guest", + "var_vm_cpu_size": "1", + "var_vm_ram_size": "1024", + "var_vm_disk_controller": "pvscsi", + "var_vm_disk_size": "16384", + "var_vm_notes": "Ubuntu 20.04.2.0 LTS (Focal Fossa) - {{isotime \"2006-01-02\"}}", + "var_iso_url": "https://releases.ubuntu.com/20.04/ubuntu-20.04.2-live-server-amd64.iso", + "var_iso_checksum_type": "sha256", + "var_iso_checksum": "d1f2bf834bbe9bb43faf16f9be992a6f3935e65be0edece1dee2aa6eb1767423", + "var_http_path": "20.04", + "var_guest_username": "packer", + "var_guest_password": "VMware1!" + } + , + "builders": [ + { + "type": "vsphere-iso", + + "vcenter_server": "{{user `var_vsphere_vcenter`}}", + "username": "{{user `var_vsphere_username`}}", + "password": "{{user `var_vsphere_password`}}", + "insecure_connection": "true", + + "datacenter": "{{user `var_vsphere_datacenter`}}", + "cluster": "{{user `var_vsphere_cluster`}}", + "folder": "{{user `var_vsphere_template_folder`}}", + "datastore": "{{user `var_vsphere_datastore`}}", + "network_adapters": [ + { + "network": "{{user `var_vsphere_network`}}", + "network_card": "vmxnet3" + } + ], + "convert_to_template": "true", + + "vm_name": "{{user `var_vm_name`}}", + "guest_os_type": "{{user `var_vm_guestos`}}", + + "CPUs": "{{user `var_vm_cpu_size`}}", + "RAM": "{{user `var_vm_ram_size`}}", + "disk_controller_type": "{{user `var_vm_disk_controller`}}", + "storage": [ + { + "disk_size": "{{user `var_vm_disk_size`}}", + "disk_thin_provisioned": true + } + ], + "notes": "{{user `var_vm_notes`}}", + + "communicator":"ssh", + "ssh_username": "{{user `var_guest_username`}}", + "ssh_password": "{{user `var_guest_password`}}", + "ssh_timeout": "30m", + "ssh_handshake_attempts": "200", + + "iso_urls": "{{user `var_iso_url`}}", + "iso_checksum": "{{user `var_iso_checksum_type`}}:{{user `var_iso_checksum`}}", + + "http_directory": "http/{{user `var_http_path`}}", + + "boot_wait": "5s", + "boot_command": [ + "", + "autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ", + "--- " + ], + "shutdown_command": "echo '{{user `var_guest_password`}}' | sudo -S -E shutdown -P now" + }], + "provisioners": [{ + "execute_command": "echo '{{user `var_guest_password`}}' | sudo -S -E bash '{{.Path}}'", + "scripts": [ + "./scripts/update.sh", + "./scripts/cleanup.sh" + ], + "type": "shell" + }, + { + "inline": "echo 'Template build complete ({{isotime \"2006-01-02 03:04:05\"}})!'", + "type": "shell" + } + ] +} \ No newline at end of file