我正在尝试使用 packer 1.8.1 和 Ubuntu 20.4 构建打包器映像
我的 HCL 清单是正确的,但我总是收到提示“继续自动安装吗?在内核命令行中添加自动安装以避免这种情况”
我尝试了很多配置,但都没有任何效果。有人能给点建议吗?
这是我的 hcl 清单和我的用户数据
source "vsphere-iso" "example" {
CPUs = 4
RAM = 4096
RAM_reserve_all = true
boot_command = [
"<enter><wait><wait><enter><wait><f6><esc><wait> ",
"autoinstall net.ifnames=0 biosdevname=0 ip=dhcp ipv6.disable=1 ds=nocloud;",
"<wait><enter>"
]
disk_controller_type = ["pvscsi"]
guest_os_type = "ubuntu64Guest"
host = "esx6.maquette.lan"
insecure_connection = true
iso_paths = ["[DT1_ESX6] ISO/ubuntu-20.04.4-live-server-amd64.iso"]
cd_files = ["./meta-data", "./user-data"]
cd_label = "cidata"
network_adapters {
network_card = "vmxnet3"
network = "PG_WINDOWS-SRV_VL8"
}
ssh_password = "ubuntu"
ssh_username = "ubuntu"
ssh_timeout = "180m"
disable_shutdown = true
shutdown_timeout = "180m"
storage {
disk_size = 55000
disk_thin_provisioned = true
}
username = "<username>"
vcenter_server = "vcenter.lan"
password = "<password>"
以及用于 ubuntu 自动安装的用户日期:
#cloud-config
autoinstall:
version: 1
early-commands:
- sudo systemctl stop ssh
- echo "yes"
locale: en_US.UTF-8
keyboard:
layout: fr
variant: us
packages: [open-vm-tools, openssh-server, chrony, curl, vim, ifupdown, unzip, gnupg2, software-properties-common, apt-transport-https, ca-certificates, lsb-release]
identity:
hostname: epachard
password: '$6$wdAcoXrU039hKYPd$508Qvbe7ObUnxoj15DRCkzC3qO7edjH0VV7BPNRDYK4QR8ofJaEEF2heacn0QgD.f8pO8SNp83XNdWG6tocBM1'
username: ubuntu
ssh:
install-server: yes
network:
network:
version: 2
ethernets:
ens192: {dhcp4: true, dhcp-identifier: mac}
apt:
preserve_sources_list: false
primary:
- arches: [amd64]
uri: "http://archive.ubuntu.com/ubuntu"
- arches: [default]
uri: "http://ports.ubuntu.com/ubuntu-ports"
geoip: true
storage:
config:
- grub_device: true
id: disk-sda
name: ''
path: /dev/sda
preserve: false
ptable: gpt
type: disk
wipe: superblock
- device: disk-sda
flag: bios_grub
grub_device: false
id: partition-0
number: 1
preserve: false
size: 1048576
type: partition
- device: disk-sda
flag: ''
grub_device: false
id: partition-1
number: 2
preserve: false
size: 1073741824
type: partition
wipe: superblock
- fstype: xfs
id: format-2
preserve: false
type: format
volume: partition-1
- device: disk-sda
flag: ''
grub_device: false
id: partition-3
number: 3
preserve: false
size: 56908316672
type: partition
wipe: superblock
- devices:
- partition-3
id: lvm_volgroup-1
name: vg0
preserve: false
type: lvm_volgroup
- id: lvm_partition-1
name: lv_root
preserve: false
size: 10737418240B
type: lvm_partition
volgroup: lvm_volgroup-1
wipe: superblock
- fstype: xfs
id: format-3
preserve: false
type: format
volume: lvm_partition-1
- device: format-3
id: mount-3
path: /
type: mount
- id: lvm_partition-2
name: lv_home
preserve: false
size: 1073741824B
type: lvm_partition
volgroup: lvm_volgroup-1
wipe: superblock
- fstype: xfs
id: format-4
preserve: false
type: format
volume: lvm_partition-2
- device: format-4
id: mount-4
path: /home
type: mount
- id: lvm_partition-3
name: lv_tmp
preserve: false
size: 4294967296B
type: lvm_partition
volgroup: lvm_volgroup-1
wipe: superblock
- fstype: xfs
id: format-5
preserve: false
type: format
volume: lvm_partition-3
- device: format-5
id: mount-5
path: /tmp
type: mount
- id: lvm_partition-4
name: lv_var
preserve: false
size: 3221225472B
type: lvm_partition
volgroup: lvm_volgroup-1
wipe: superblock
- fstype: xfs
id: format-6
preserve: false
type: format
volume: lvm_partition-4
- device: format-6
id: mount-6
path: /var
type: mount
- id: lvm_partition-5
name: lv_var_log
preserve: false
size: 4294967296B
type: lvm_partition
volgroup: lvm_volgroup-1
wipe: superblock
- fstype: xfs
id: format-7
preserve: false
type: format
volume: lvm_partition-5
- device: format-7
id: mount-7
path: /var/log
type: mount
- id: lvm_partition-6
name: lv_var_log_audit
preserve: false
size: 2147483648B
type: lvm_partition
volgroup: lvm_volgroup-1
wipe: superblock
- fstype: xfs
id: format-8
preserve: false
type: format
volume: lvm_partition-6
- device: format-8
id: mount-8
path: /var/log/audit
type: mount
- id: lvm_partition-7
name: lv_var_tmp
preserve: false
size: 1073741824B
type: lvm_partition
volgroup: lvm_volgroup-1
wipe: superblock
- fstype: xfs
id: format-9
preserve: false
type: format
volume: lvm_partition-7
- device: format-9
id: mount-9
path: /var/tmp
type: mount
- id: lvm_partition-8
name: lv_opt
preserve: false
size: 2147483648B
type: lvm_partition
volgroup: lvm_volgroup-1
wipe: superblock
- fstype: xfs
id: format-10
preserve: false
type: format
volume: lvm_partition-8
- device: format-10
id: mount-10
path: /opt
type: mount
- id: lvm_partition-9
name: lv_swap
preserve: false
size: 2147483648B
type: lvm_partition
volgroup: lvm_volgroup-1
wipe: superblock
- fstype: swap
id: format-11
preserve: false
type: format
volume: lvm_partition-9
- device: format-11
id: mount-11
path: ''
type: mount
- device: format-2
id: mount-2
path: /boot
type: mount
late-commands:
- sed -i 's/^#*\(send dhcp-client-identifier\).*$/\1 = hardware;/' /target/etc/dhcp/dhclient.conf
提前感谢你的帮助