Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add floppy_content for Ubuntu Server 18.04 LTS #82

Merged
merged 3 commits into from
Oct 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions builds/linux/ubuntu-server-18-04-lts/linux-ubuntu-server.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ packer {
required_version = ">= 1.7.6"
required_plugins {
vsphere = {
version = ">= v1.0.1"
version = ">= v1.0.2"
source = "github.com/hashicorp/vsphere"
}
}
Expand All @@ -23,6 +23,16 @@ locals {
buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp())
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
manifest_path = "${path.cwd}/manifests/"
data_source_content = {
"/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
build_username = var.build_username
build_password_encrypted = var.build_password_encrypted
vm_guest_os_language = var.vm_guest_os_language
vm_guest_os_keyboard = var.vm_guest_os_keyboard
vm_guest_os_timezone = var.vm_guest_os_timezone
})
}
data_source_command = var.common_data_source == "http" ? "url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" : "file=/media/ks.cfg"
}

// BLOCK: source
Expand Down Expand Up @@ -67,17 +77,10 @@ source "vsphere-iso" "linux-ubuntu-server" {
notes = "Built by HashiCorp Packer on ${local.buildtime}."

// Removable Media Settings
iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"]
iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}"
http_content = {
"/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
build_username = var.build_username
build_password_encrypted = var.build_password_encrypted
vm_guest_os_language = var.vm_guest_os_language
vm_guest_os_keyboard = var.vm_guest_os_keyboard
vm_guest_os_timezone = var.vm_guest_os_timezone
})
}
iso_paths = ["[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"]
iso_checksum = "${var.iso_checksum_type}:${var.iso_checksum_value}"
http_content = var.common_data_source == "http" ? local.data_source_content : null
floppy_content = var.common_data_source == "disk" ? local.data_source_content : null

// Boot and Provisioning Settings
http_ip = var.common_http_ip
Expand All @@ -98,7 +101,7 @@ source "vsphere-iso" "linux-ubuntu-server" {
"<bs><bs><bs>",
"/install/vmlinuz initrd=/install/initrd.gz",
" priority=critical locale=${var.vm_guest_os_language}",
" url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg",
" ${local.data_source_command}",
"<enter>"
]
ip_wait_timeout = var.common_ip_wait_timeout
Expand Down Expand Up @@ -134,13 +137,16 @@ source "vsphere-iso" "linux-ubuntu-server" {
build {
sources = ["source.vsphere-iso.linux-ubuntu-server"]

provisioner "file" {
destination = "/tmp/root-ca.crt"
source = "${path.cwd}/certificates/root-ca.crt"
}

provisioner "ansible-local" {
playbook_file = "${path.cwd}/scripts/ansible/playbook.yml"
provisioner "ansible" {
playbook_file = "${path.cwd}/ansible/main.yml"
roles_path = "${path.cwd}/ansible/roles"
ansible_env_vars = [
"ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg",
"ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python3"
]
extra_arguments = [
"-e", "display_skipped_hosts = false"
]
}

provisioner "shell" {
Expand Down Expand Up @@ -180,4 +186,4 @@ build {
vsphere_iso_path = "[${var.common_iso_datastore}] ${var.iso_path}/${var.iso_file}"
}
}
}
}