-
-
Save Isotop7/44d91bee7c81fb6d4c08dc0b4f6f196f to your computer and use it in GitHub Desktop.
ubuntu-20.04
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
variable "disk_size" { | |
type = string | |
default = "20480" | |
} | |
variable "esxi_datastore" { | |
type = string | |
default = "" | |
} | |
variable "esxi_host" { | |
type = string | |
default = "" | |
} | |
variable "esxi_password" { | |
type = string | |
default = "" | |
} | |
variable "esxi_user" { | |
type = string | |
default = "" | |
} | |
variable "image_name" { | |
type = string | |
default = "ubuntu-20.04" | |
} | |
variable "memory" { | |
type = string | |
default = "2048" | |
} | |
variable "ssh_name" { | |
type = string | |
default = "administrator" | |
} | |
variable "ssh_pass" { | |
type = string | |
default = "administrator" | |
} | |
variable "ssh_timeout" { | |
type = string | |
default = "30m" | |
} | |
variable "vsphere_dev_address" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_dev_datacenter" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_dev_cluster" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_dev_datastore" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_dev_host" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_dev_network" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_dev_pass" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_dev_username" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_prod_address" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_prod_datacenter" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_prod_cluster" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_prod_datastore" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_prod_host" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_prod_network" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_prod_pass" { | |
type = string | |
default = "" | |
} | |
variable "vsphere_prod_username" { | |
type = string | |
default = "" | |
} | |
source "vmware-iso" "ubuntu-20" { | |
boot_command = ["<shift><enter>", "<f6><esc>", " autoinstall net.ifnames=0 biosdevname=0 ip=dhcp ipv6.disable=1 ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/", "<enter>"] | |
boot_wait = "1s" | |
cores = "2" | |
cpus = "2" | |
disk_size = "${var.disk_size}" | |
disk_type_id = "thin" | |
format = "ovf" | |
guest_os_type = "ubuntu-64" | |
headless = true | |
http_directory = "cloud-init/ubuntu-20.04" | |
http_port_max = "8020" | |
http_port_min = "8000" | |
insecure_connection = true | |
iso_checksum = "f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98" | |
iso_url = "https://ftp.halifax.rwth-aachen.de/ubuntu-releases/focal/ubuntu-20.04.3-live-server-amd64.iso" | |
memory = "${var.memory}" | |
network_adapter_type = "vmxnet3" | |
output_directory = "output-${var.image_name}" | |
ovftool_options = ["--overwrite"] | |
remote_cache_datastore = "${var.esxi_datastore}" | |
remote_cache_directory = "cache" | |
remote_datastore = "${var.esxi_datastore}" | |
remote_host = "${var.esxi_host}" | |
remote_password = "${var.esxi_password}" | |
remote_type = "esx5" | |
remote_username = "${var.esxi_user}" | |
shutdown_command = "echo ${var.ssh_pass} | sudo -S systemctl poweroff" | |
ssh_password = "${var.ssh_pass}" | |
ssh_timeout = "${var.ssh_timeout}" | |
ssh_username = "${var.ssh_name}" | |
version = "19" | |
vm_name = "${var.image_name}" | |
vmdk_name = "${var.image_name}_flat" | |
vmx_data = { | |
"disk.enableUUID" = "true" | |
"ethernet0.networkName" = "int-mgmt-1021" | |
"tools.syncTime" = "false" | |
} | |
vnc_disable_password = true | |
vnc_over_websocket = true | |
} | |
build { | |
sources = ["source.vmware-iso.ubuntu-20"] | |
provisioner "ansible" { | |
ansible_env_vars = ["ANSIBLE_NOCOWS=1"] | |
extra_arguments = ["--extra-vars", "ansible_become_pass=${var.ssh_pass} ansible_become_user=root ansible_ssh_user=${var.ssh_name} ansible_become=true ansible_ssh_pass=${var.ssh_pass} ansible_become_method=sudo"] | |
playbook_file = "../ansible/bootstrap-${var.image_name}/bootstrap.yml" | |
user = "${var.ssh_name}" | |
} | |
post-processors { | |
post-processor "vsphere" { | |
cluster = "${var.vsphere_prod_cluster}" | |
datacenter = "${var.vsphere_prod_datacenter}" | |
datastore = "${var.vsphere_prod_datastore}" | |
host = "${var.vsphere_prod_host}" | |
insecure = true | |
overwrite = true | |
password = "${var.vsphere_prod_pass}" | |
username = "${var.vsphere_prod_username}" | |
vm_folder = "/packer-templates" | |
vm_name = "${var.image_name}" | |
vm_network = "${var.vsphere_prod_network}" | |
} | |
post-processor "vsphere-template" { | |
datacenter = "${var.vsphere_prod_datacenter}" | |
folder = "/packer-templates" | |
host = "${var.vsphere_prod_host}" | |
insecure = true | |
password = "${var.vsphere_prod_pass}" | |
reregister_vm = false | |
username = "${var.vsphere_prod_username}" | |
} | |
} | |
post-processors { | |
post-processor "vsphere" { | |
cluster = "${var.vsphere_dev_cluster}" | |
datacenter = "${var.vsphere_dev_datacenter}" | |
datastore = "${var.vsphere_dev_datastore}" | |
host = "${var.vsphere_dev_host}" | |
insecure = true | |
overwrite = true | |
password = "${var.vsphere_dev_pass}" | |
username = "${var.vsphere_dev_username}" | |
vm_folder = "/packer-templates" | |
vm_name = "${var.image_name}" | |
vm_network = "${var.vsphere_dev_network}" | |
} | |
post-processor "vsphere-template" { | |
datacenter = "${var.vsphere_dev_datacenter}" | |
folder = "/packer-templates" | |
host = "${var.vsphere_dev_host}" | |
insecure = true | |
password = "${var.vsphere_dev_pass}" | |
reregister_vm = false | |
username = "${var.vsphere_dev_username}" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment