Skip to content

Instantly share code, notes, and snippets.

@rockpapergoat
Created March 21, 2022 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rockpapergoat/59fe09ecb464e2308eee5eac4ca47036 to your computer and use it in GitHub Desktop.
Save rockpapergoat/59fe09ecb464e2308eee5eac4ca47036 to your computer and use it in GitHub Desktop.
test packer template
install
lang en_US.UTF-8
keyboard us
timezone America/New_York
auth --useshadow --enablemd5
selinux --disabled
firewall --disabled
services --enabled=NetworkManager,sshd
eula --agreed
ignoredisk --only-use=sda
reboot
network --bootproto=dhcp --onboot=on --device=eth0 --ipv6=auto
bootloader --location=mbr
zerombr
clearpart --all --initlabel
part swap --asprimary --fstype="swap" --size=1024
part /boot --fstype xfs --size=200
part pv.01 --size=1 --grow
volgroup rootvg01 pv.01
logvol / --fstype xfs --name=lv01 --vgname=rootvg01 --size=1 --grow
user --name=build --groups=wheel --iscrypted --password=$6$4QXYjerHFZ0tJ8zN$UAS1LU4JtLdr679khEzmgbktB4cA4cnykCFs22RN/XdKTx.272KQqQk898hWUruBwpWieeH8YbthEaP/odVnW/
url --url=http://mirror.seas.harvard.edu/centos/7.9.2009/os/x86_64/
repo --name=centos-7-base --baseurl=http://mirror.seas.harvard.edu/centos/7/os/x86_64/
repo --name=centos-7-updates --baseurl=http://mirror.seas.harvard.edu/centos/7/updates/x86_64/
repo --name=centos-7-extras --baseurl=http://mirror.seas.harvard.edu/centos/7/extras/x86_64/
repo --name=epel --baseurl=http://mirror.seas.harvard.edu/epel/7/x86_64/
%packages --nobase --ignoremissing
@core
vim
%post --log=/root/ks-post.log
mv /etc/ssh/sshd_config.anaconda /etc/ssh/sshd_config
systemctl start sshd
sed -i "s/#PermitRootLogin yes/PermitRootLogin yes/g" /etc/ssh/sshd_config
yum update -y
%end
%end
variable "iso_url" {
type = string
default = "https://mirrors.edge.kernel.org/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-NetInstall-2009.iso"
}
variable "iso_checksum" {
type = string
default = "https://mirrors.edge.kernel.org/centos/7.9.2009/isos/x86_64/sha256sum.txt"
}
source "qemu" "test_base" {
iso_url = var.iso_url
iso_checksum = "file:${var.iso_checksum}"
headless = true
qemu_binary = "/usr/libexec/qemu-kvm"
output_directory = "output_centos_test_base"
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
disk_size = "30G"
format = "qcow2"
#accelerator = "kvm"
http_directory = "http"
ssh_username = "build"
ssh_password = "build"
ssh_timeout = "20m"
vm_name = "fasse_base"
net_device = "virtio-net"
disk_interface = "virtio"
boot_wait = "20s"
shutdown_timeout = "1h"
boot_command = ["<tab> inst.sshd inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks-minimal.cfg<enter><wait>"]
}
build {
sources = ["source.qemu.test_base"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment