Continue restructuring
This commit is contained in:
+2
-1
@@ -6,7 +6,8 @@
|
||||
# backwards compatibility). Please don't change it unless you know what
|
||||
# you're doing.
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "@@BOX@@"
|
||||
config.vm.box = "@@BOX_NAME@@"
|
||||
config.vm.box_url = "@@BOX@@"
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
# using a specific IP.
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
mode: "0600"
|
||||
dest: "{{ ansible_user_dir }}/.ssh/authorized_keys"
|
||||
url: https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub
|
||||
register: _fetch_authorized_keys
|
||||
retries: 3
|
||||
until: _fetch_authorized_keys is success
|
||||
|
||||
- name: Sudo commands
|
||||
block:
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
distro = "debian"
|
||||
version = "9"
|
||||
iso = {
|
||||
url = "https://cdimage.debian.org/cdimage/archive/9.13.0/amd64/iso-cd/debian-9.13.0-amd64-netinst.iso"
|
||||
checksum = "71c7e9eb292acc880f84605b1ca2b997f25737fe0a43fc9586f61d35cd2eb43b"
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto ",
|
||||
"DEBIAN_FRONTEND=text ",
|
||||
"net.ifnames=0 ",
|
||||
"biosdevnames=0 ",
|
||||
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/debian/9-preseed.cfg ",
|
||||
"console=ttyS0 ",
|
||||
"<enter>"
|
||||
]
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env xonsh
|
||||
import argparse
|
||||
source ./test.xsh
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser("Build all")
|
||||
parser.add_argument("--provider", choices=get_providers(), default="qemu.x86_64")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
for f in g`distros/**/build.xsh`:
|
||||
./@(f) --provider @(args.provider)
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Name of the file to write out
|
||||
name="${0%.sh}"
|
||||
|
||||
checksums="$(mktemp)"
|
||||
until curl -f -L -o "${checksums}" "http://mirror.centos.org/centos/8-stream/isos/x86_64/CHECKSUM"; do
|
||||
sleep 1
|
||||
done
|
||||
sha="$(cat "${checksums}" | grep latest-boot | grep SHA256 | cut -d' ' -f 4)"
|
||||
|
||||
cat << EOF > "${name}"
|
||||
distro = "centos"
|
||||
version = "8stream"
|
||||
iso = {
|
||||
url = "http://mirror.centos.org/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-latest-boot.iso"
|
||||
checksum = "${sha}"
|
||||
}
|
||||
boot_command = [
|
||||
"<up><tab><wait><bs><bs><bs><bs><bs>",
|
||||
"inst.text inst.ks=cdrom:/http/centos/8stream/x86_64.ks console=ttyS0",
|
||||
"<enter><wait>"
|
||||
]
|
||||
EOF
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
# Name of the file to write out
|
||||
name="${0%.sh}"
|
||||
|
||||
baseurl="https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso"
|
||||
checksums="$(mktemp)"
|
||||
until curl -f -L -o "${checksums}" "${baseurl}.SHA256SUM"; do
|
||||
sleep 1
|
||||
done
|
||||
sha="$(cat "${checksums}" | awk '/SHA256/ {print $4}')"
|
||||
rm "${checksums}"
|
||||
|
||||
cat << EOF > "${name}"
|
||||
distro = "centos"
|
||||
version = "9stream"
|
||||
iso = {
|
||||
url = "${baseurl}"
|
||||
checksum = "${sha}"
|
||||
}
|
||||
boot_command = [
|
||||
"<up><tab><wait><bs><bs><bs><bs><bs>",
|
||||
"inst.text inst.ks=cdrom:/http/centos/9stream-x86_64.ks console=tty0",
|
||||
"<enter><wait>"
|
||||
]
|
||||
EOF
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env xonsh
|
||||
$RAISE_SUBPROC_ERROR = True
|
||||
from pathlib import Path
|
||||
import sys
|
||||
self = Path(__file__).absolute()
|
||||
base = self.parent.parent.parent.parent
|
||||
source @(base / "test.xsh")
|
||||
|
||||
|
||||
opts = get_parser(sys.argv[1:])
|
||||
|
||||
cd @(str(base))
|
||||
for provider in opts["providers"]:
|
||||
packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources")
|
||||
@@ -0,0 +1,169 @@
|
||||
distro = "centos"
|
||||
version = "8stream"
|
||||
iso = {
|
||||
url = "http://mirror.centos.org/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-latest-boot.iso"
|
||||
checksum = "029ead89f720becd5ee2a8cf9935aad12fda7494d61674710174b4674b357530"
|
||||
}
|
||||
boot_command = [
|
||||
"<up><tab><wait><bs><bs><bs><bs><bs>",
|
||||
"inst.text inst.ks=cdrom:/ks.cfg console=tty0",
|
||||
"<enter><wait>"
|
||||
]
|
||||
cd_files = {
|
||||
"ks.cfg" = <<KICKSTART
|
||||
url --mirrorlist=http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=BaseOS&infra=stock
|
||||
repo --name=AppStream --mirrorlist=http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock
|
||||
network --bootproto=dhcp --activate
|
||||
reboot
|
||||
|
||||
text
|
||||
keyboard --vckeymap us
|
||||
lang en_US
|
||||
skipx
|
||||
rootpw --plaintext vagrant
|
||||
firewall --disabled
|
||||
timezone --utc UTC
|
||||
services --enabled=vmtoolsd
|
||||
# The biosdevname and ifnames options ensure we get "eth0" as our interface
|
||||
# even in environments like virtualbox that emulate a real NW card
|
||||
bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop"
|
||||
zerombr
|
||||
clearpart --all
|
||||
part / --fstype=xfs --asprimary --size=1024 --grow
|
||||
|
||||
user --name=vagrant --plaintext --password=vagrant
|
||||
|
||||
%packages --instLangs=en
|
||||
bash-completion
|
||||
man-pages
|
||||
bzip2
|
||||
rsync
|
||||
nfs-utils
|
||||
cifs-utils
|
||||
chrony
|
||||
yum-utils
|
||||
hyperv-daemons
|
||||
open-vm-tools
|
||||
# Vagrant boxes aren't normally visible, no need for Plymouth
|
||||
-plymouth
|
||||
# Microcode updates cannot work in a VM
|
||||
-microcode_ctl
|
||||
# Firmware packages are not needed in a VM
|
||||
-iwl100-firmware
|
||||
-iwl1000-firmware
|
||||
-iwl105-firmware
|
||||
-iwl135-firmware
|
||||
-iwl2000-firmware
|
||||
-iwl2030-firmware
|
||||
-iwl3160-firmware
|
||||
-iwl3945-firmware
|
||||
-iwl4965-firmware
|
||||
-iwl5000-firmware
|
||||
-iwl5150-firmware
|
||||
-iwl6000-firmware
|
||||
-iwl6000g2a-firmware
|
||||
-iwl6050-firmware
|
||||
-iwl7260-firmware
|
||||
# Don't build rescue initramfs
|
||||
-dracut-config-rescue
|
||||
%end
|
||||
|
||||
# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only
|
||||
# works on systems with at least 2GB RAM (which excludes most Vagrant boxes)
|
||||
# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169
|
||||
%addon com_redhat_kdump --disable
|
||||
%end
|
||||
|
||||
%post
|
||||
# configure swap to a file
|
||||
fallocate -l 2G /swapfile
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
|
||||
|
||||
# sudo
|
||||
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant
|
||||
chmod 0440 /etc/sudoers.d/vagrant
|
||||
|
||||
# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38
|
||||
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
|
||||
DEVICE="eth0"
|
||||
BOOTPROTO="dhcp"
|
||||
ONBOOT="yes"
|
||||
TYPE="Ethernet"
|
||||
PERSISTENT_DHCLIENT="yes"
|
||||
EOF
|
||||
|
||||
# sshd: disable password authentication and DNS checks
|
||||
ex -s /etc/ssh/sshd_config <<EOF
|
||||
:%substitute/^\(PasswordAuthentication\) yes$/\1 no/
|
||||
:%substitute/^#\(UseDNS\) yes$/&\r\1 no/
|
||||
:update
|
||||
:quit
|
||||
EOF
|
||||
cat >>/etc/sysconfig/sshd <<EOF
|
||||
|
||||
# Decrease connection time by preventing reverse DNS lookups
|
||||
# (see https://lists.centos.org/pipermail/centos-devel/2016-July/014981.html
|
||||
# and man sshd for more information)
|
||||
OPTIONS="-u0"
|
||||
EOF
|
||||
|
||||
# Default insecure vagrant key
|
||||
mkdir -m 0700 -p /home/vagrant/.ssh
|
||||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" >> /home/vagrant/.ssh/authorized_keys
|
||||
chmod 600 /home/vagrant/.ssh/authorized_keys
|
||||
chown -R vagrant:vagrant /home/vagrant/.ssh
|
||||
|
||||
# Fix for issue #76, regular users can gain admin privileges via su
|
||||
ex -s /etc/pam.d/su <<'EOF'
|
||||
# allow vagrant to use su, but prevent others from becoming root or vagrant
|
||||
/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet$/
|
||||
:append
|
||||
account [success=1 default=ignore] \\
|
||||
pam_succeed_if.so user = vagrant use_uid quiet
|
||||
account required pam_succeed_if.so user notin root:vagrant
|
||||
.
|
||||
:update
|
||||
:quit
|
||||
EOF
|
||||
|
||||
# systemd should generate a new machine id during the first boot, to
|
||||
# avoid having multiple Vagrant instances with the same id in the local
|
||||
# network. /etc/machine-id should be empty, but it must exist to prevent
|
||||
# boot errors (e.g. systemd-journald failing to start).
|
||||
:>/etc/machine-id
|
||||
|
||||
echo 'vag' > /etc/yum/vars/infra
|
||||
|
||||
# Blacklist the floppy module to avoid probing timeouts
|
||||
echo blacklist floppy > /etc/modprobe.d/nofloppy.conf
|
||||
chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf
|
||||
|
||||
# Customize the initramfs
|
||||
pushd /etc/dracut.conf.d
|
||||
# Enable VMware PVSCSI support for VMware Fusion guests.
|
||||
echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf
|
||||
echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf
|
||||
# There's no floppy controller, but probing for it generates timeouts
|
||||
echo 'omit_drivers+=" floppy "' > nofloppy.conf
|
||||
popd
|
||||
# Fix the SELinux context of the new files
|
||||
restorecon -f - <<EOF
|
||||
/etc/sudoers.d/vagrant
|
||||
/etc/dracut.conf.d/vmware-fusion-drivers.conf
|
||||
/etc/dracut.conf.d/hyperv-drivers.conf
|
||||
/etc/dracut.conf.d/nofloppy.conf
|
||||
EOF
|
||||
|
||||
# Rerun dracut for the installed kernel (not the running kernel):
|
||||
KERNEL_VERSION=$(rpm -q kernel --qf '%\{version}-%\{release}.%\{arch}\n')
|
||||
dracut -f /boot/initramfs-$\{KERNEL_VERSION}.img $\{KERNEL_VERSION}
|
||||
|
||||
# Seal for deployment
|
||||
rm -rf /etc/ssh/ssh_host_*
|
||||
hostnamectl set-hostname localhost.localdomain
|
||||
rm -rf /etc/udev/rules.d/70-*
|
||||
%end
|
||||
KICKSTART
|
||||
}
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Name of the file to write out
|
||||
name="${0%.sh}"
|
||||
|
||||
checksums="$(mktemp)"
|
||||
until curl -f -L -o "${checksums}" "http://mirror.centos.org/centos/8-stream/isos/x86_64/CHECKSUM"; do
|
||||
sleep 1
|
||||
done
|
||||
sha="$(cat "${checksums}" | grep latest-boot | grep SHA256 | cut -d' ' -f 4)"
|
||||
|
||||
cat << HERPDERP > "${name}"
|
||||
distro = "centos"
|
||||
version = "8stream"
|
||||
iso = {
|
||||
url = "http://mirror.centos.org/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-latest-boot.iso"
|
||||
checksum = "${sha}"
|
||||
}
|
||||
boot_command = [
|
||||
"<up><tab><wait><bs><bs><bs><bs><bs>",
|
||||
"inst.text inst.ks=cdrom:/ks.cfg console=tty0",
|
||||
"<enter><wait>"
|
||||
]
|
||||
cd_files = {
|
||||
"ks.cfg" = <<KICKSTART
|
||||
url --mirrorlist=http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=BaseOS&infra=stock
|
||||
repo --name=AppStream --mirrorlist=http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock
|
||||
network --bootproto=dhcp --activate
|
||||
reboot
|
||||
|
||||
text
|
||||
keyboard --vckeymap us
|
||||
lang en_US
|
||||
skipx
|
||||
rootpw --plaintext vagrant
|
||||
firewall --disabled
|
||||
timezone --utc UTC
|
||||
services --enabled=vmtoolsd
|
||||
# The biosdevname and ifnames options ensure we get "eth0" as our interface
|
||||
# even in environments like virtualbox that emulate a real NW card
|
||||
bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop"
|
||||
zerombr
|
||||
clearpart --all
|
||||
part / --fstype=xfs --asprimary --size=1024 --grow
|
||||
|
||||
user --name=vagrant --plaintext --password=vagrant
|
||||
|
||||
%packages --instLangs=en
|
||||
bash-completion
|
||||
man-pages
|
||||
bzip2
|
||||
rsync
|
||||
nfs-utils
|
||||
cifs-utils
|
||||
chrony
|
||||
yum-utils
|
||||
hyperv-daemons
|
||||
open-vm-tools
|
||||
# Vagrant boxes aren't normally visible, no need for Plymouth
|
||||
-plymouth
|
||||
# Microcode updates cannot work in a VM
|
||||
-microcode_ctl
|
||||
# Firmware packages are not needed in a VM
|
||||
-iwl100-firmware
|
||||
-iwl1000-firmware
|
||||
-iwl105-firmware
|
||||
-iwl135-firmware
|
||||
-iwl2000-firmware
|
||||
-iwl2030-firmware
|
||||
-iwl3160-firmware
|
||||
-iwl3945-firmware
|
||||
-iwl4965-firmware
|
||||
-iwl5000-firmware
|
||||
-iwl5150-firmware
|
||||
-iwl6000-firmware
|
||||
-iwl6000g2a-firmware
|
||||
-iwl6050-firmware
|
||||
-iwl7260-firmware
|
||||
# Don't build rescue initramfs
|
||||
-dracut-config-rescue
|
||||
%end
|
||||
|
||||
# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only
|
||||
# works on systems with at least 2GB RAM (which excludes most Vagrant boxes)
|
||||
# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169
|
||||
%addon com_redhat_kdump --disable
|
||||
%end
|
||||
|
||||
%post
|
||||
# configure swap to a file
|
||||
fallocate -l 2G /swapfile
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
|
||||
|
||||
# sudo
|
||||
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant
|
||||
chmod 0440 /etc/sudoers.d/vagrant
|
||||
|
||||
# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38
|
||||
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
|
||||
DEVICE="eth0"
|
||||
BOOTPROTO="dhcp"
|
||||
ONBOOT="yes"
|
||||
TYPE="Ethernet"
|
||||
PERSISTENT_DHCLIENT="yes"
|
||||
EOF
|
||||
|
||||
# sshd: disable password authentication and DNS checks
|
||||
ex -s /etc/ssh/sshd_config <<EOF
|
||||
:%substitute/^\(PasswordAuthentication\) yes\$/\1 no/
|
||||
:%substitute/^#\(UseDNS\) yes\$/&\r\1 no/
|
||||
:update
|
||||
:quit
|
||||
EOF
|
||||
cat >>/etc/sysconfig/sshd <<EOF
|
||||
|
||||
# Decrease connection time by preventing reverse DNS lookups
|
||||
# (see https://lists.centos.org/pipermail/centos-devel/2016-July/014981.html
|
||||
# and man sshd for more information)
|
||||
OPTIONS="-u0"
|
||||
EOF
|
||||
|
||||
# Default insecure vagrant key
|
||||
mkdir -m 0700 -p /home/vagrant/.ssh
|
||||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" >> /home/vagrant/.ssh/authorized_keys
|
||||
chmod 600 /home/vagrant/.ssh/authorized_keys
|
||||
chown -R vagrant:vagrant /home/vagrant/.ssh
|
||||
|
||||
# Fix for issue #76, regular users can gain admin privileges via su
|
||||
ex -s /etc/pam.d/su <<'EOF'
|
||||
# allow vagrant to use su, but prevent others from becoming root or vagrant
|
||||
/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet\$/
|
||||
:append
|
||||
account [success=1 default=ignore] \\
|
||||
pam_succeed_if.so user = vagrant use_uid quiet
|
||||
account required pam_succeed_if.so user notin root:vagrant
|
||||
.
|
||||
:update
|
||||
:quit
|
||||
EOF
|
||||
|
||||
# systemd should generate a new machine id during the first boot, to
|
||||
# avoid having multiple Vagrant instances with the same id in the local
|
||||
# network. /etc/machine-id should be empty, but it must exist to prevent
|
||||
# boot errors (e.g. systemd-journald failing to start).
|
||||
:>/etc/machine-id
|
||||
|
||||
echo 'vag' > /etc/yum/vars/infra
|
||||
|
||||
# Blacklist the floppy module to avoid probing timeouts
|
||||
echo blacklist floppy > /etc/modprobe.d/nofloppy.conf
|
||||
chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf
|
||||
|
||||
# Customize the initramfs
|
||||
pushd /etc/dracut.conf.d
|
||||
# Enable VMware PVSCSI support for VMware Fusion guests.
|
||||
echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf
|
||||
echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf
|
||||
# There's no floppy controller, but probing for it generates timeouts
|
||||
echo 'omit_drivers+=" floppy "' > nofloppy.conf
|
||||
popd
|
||||
# Fix the SELinux context of the new files
|
||||
restorecon -f - <<EOF
|
||||
/etc/sudoers.d/vagrant
|
||||
/etc/dracut.conf.d/vmware-fusion-drivers.conf
|
||||
/etc/dracut.conf.d/hyperv-drivers.conf
|
||||
/etc/dracut.conf.d/nofloppy.conf
|
||||
EOF
|
||||
|
||||
# Rerun dracut for the installed kernel (not the running kernel):
|
||||
KERNEL_VERSION=\$(rpm -q kernel --qf '%\{version}-%\{release}.%\{arch}\n')
|
||||
dracut -f /boot/initramfs-\$\{KERNEL_VERSION}.img \$\{KERNEL_VERSION}
|
||||
|
||||
# Seal for deployment
|
||||
rm -rf /etc/ssh/ssh_host_*
|
||||
hostnamectl set-hostname localhost.localdomain
|
||||
rm -rf /etc/udev/rules.d/70-*
|
||||
%end
|
||||
KICKSTART
|
||||
}
|
||||
HERPDERP
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env xonsh
|
||||
$RAISE_SUBPROC_ERROR = True
|
||||
from pathlib import Path
|
||||
import sys
|
||||
self = Path(__file__).absolute()
|
||||
base = self.parent.parent.parent.parent
|
||||
source @(base / "test.xsh")
|
||||
|
||||
|
||||
unsupported = set({
|
||||
#"virtualbox-iso.x86_64"
|
||||
})
|
||||
|
||||
opts = get_parser(sys.argv[1:], unsupported)
|
||||
|
||||
cd @(str(base))
|
||||
for provider in opts["providers"]:
|
||||
packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources")
|
||||
@@ -0,0 +1,178 @@
|
||||
distro = "centos"
|
||||
version = "9stream"
|
||||
iso = {
|
||||
url = "https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso"
|
||||
checksum = "3ccccffb97c30906bc9ca1cb5fc2f07c76db632c0b4e061775155fb397dee1f1"
|
||||
}
|
||||
boot_command = [
|
||||
"<up><tab><wait><bs><bs><bs><bs><bs>",
|
||||
"inst.text inst.ks=cdrom:/ks.cfg console=tty0",
|
||||
"<enter><wait>"
|
||||
]
|
||||
cd_files = {
|
||||
"ks.cfg" = <<KICKSTART
|
||||
url --metalink=https://mirrors.centos.org/metalink?arch=x86_64&repo=centos-baseos-9-stream
|
||||
repo --name=AppStream --metalink=https://mirrors.centos.org/metalink?arch=x86_64&repo=centos-appstream-9-stream
|
||||
network --bootproto=dhcp --activate
|
||||
reboot
|
||||
|
||||
text
|
||||
keyboard --vckeymap us
|
||||
lang en_US
|
||||
skipx
|
||||
rootpw --plaintext vagrant
|
||||
firewall --disabled
|
||||
timezone --utc UTC
|
||||
services --enabled=vmtoolsd
|
||||
# The biosdevname and ifnames options ensure we get "eth0" as our interface
|
||||
# even in environments like virtualbox that emulate a real NW card
|
||||
bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop"
|
||||
zerombr
|
||||
%include /tmp/disks.ks
|
||||
|
||||
%pre --interpreter /bin/bash --log /tmp/greg
|
||||
if [ -e /dev/vda ]; then
|
||||
disk="vda"
|
||||
else
|
||||
disk="sda"
|
||||
fi
|
||||
echo "clearpart --all --drives=$disk" > /tmp/disks.ks
|
||||
echo "part / --fstype=ext4 --asprimary --size=1024 --grow --ondisk=$disk" >> /tmp/disks.ks
|
||||
%end
|
||||
|
||||
user --name=vagrant --plaintext --password=vagrant
|
||||
|
||||
%packages --inst-langs=en
|
||||
bash-completion
|
||||
man-pages
|
||||
bzip2
|
||||
rsync
|
||||
nfs-utils
|
||||
cifs-utils
|
||||
chrony
|
||||
yum-utils
|
||||
hyperv-daemons
|
||||
open-vm-tools
|
||||
# Vagrant boxes aren't normally visible, no need for Plymouth
|
||||
-plymouth
|
||||
# Microcode updates cannot work in a VM
|
||||
-microcode_ctl
|
||||
# Firmware packages are not needed in a VM
|
||||
-iwl100-firmware
|
||||
-iwl1000-firmware
|
||||
-iwl105-firmware
|
||||
-iwl135-firmware
|
||||
-iwl2000-firmware
|
||||
-iwl2030-firmware
|
||||
-iwl3160-firmware
|
||||
-iwl3945-firmware
|
||||
-iwl4965-firmware
|
||||
-iwl5000-firmware
|
||||
-iwl5150-firmware
|
||||
-iwl6000-firmware
|
||||
-iwl6000g2a-firmware
|
||||
-iwl6050-firmware
|
||||
-iwl7260-firmware
|
||||
# Don't build rescue initramfs
|
||||
-dracut-config-rescue
|
||||
%end
|
||||
|
||||
# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only
|
||||
# works on systems with at least 2GB RAM (which excludes most Vagrant boxes)
|
||||
# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169
|
||||
%addon com_redhat_kdump --disable
|
||||
%end
|
||||
|
||||
%post
|
||||
# configure swap to a file
|
||||
fallocate -l 2G /swapfile
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
|
||||
|
||||
# sudo
|
||||
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant
|
||||
chmod 0440 /etc/sudoers.d/vagrant
|
||||
|
||||
# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38
|
||||
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
|
||||
DEVICE="eth0"
|
||||
BOOTPROTO="dhcp"
|
||||
ONBOOT="yes"
|
||||
TYPE="Ethernet"
|
||||
PERSISTENT_DHCLIENT="yes"
|
||||
EOF
|
||||
|
||||
# sshd: disable password authentication and DNS checks
|
||||
ex -s /etc/ssh/sshd_config <<EOF
|
||||
:%substitute/^\(PasswordAuthentication\) yes$/\1 no/
|
||||
:%substitute/^#\(UseDNS\) yes$/&\r\1 no/
|
||||
:update
|
||||
:quit
|
||||
EOF
|
||||
cat >>/etc/sysconfig/sshd <<EOF
|
||||
|
||||
# Decrease connection time by preventing reverse DNS lookups
|
||||
# (see https://lists.centos.org/pipermail/centos-devel/2016-July/014981.html
|
||||
# and man sshd for more information)
|
||||
OPTIONS="-u0"
|
||||
EOF
|
||||
|
||||
# Default insecure vagrant key
|
||||
mkdir -m 0700 -p /home/vagrant/.ssh
|
||||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" >> /home/vagrant/.ssh/authorized_keys
|
||||
chmod 600 /home/vagrant/.ssh/authorized_keys
|
||||
chown -R vagrant:vagrant /home/vagrant/.ssh
|
||||
|
||||
# Fix for issue #76, regular users can gain admin privileges via su
|
||||
ex -s /etc/pam.d/su <<'EOF'
|
||||
# allow vagrant to use su, but prevent others from becoming root or vagrant
|
||||
/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet$/
|
||||
:append
|
||||
account [success=1 default=ignore] \
|
||||
pam_succeed_if.so user = vagrant use_uid quiet
|
||||
account required pam_succeed_if.so user notin root:vagrant
|
||||
.
|
||||
:update
|
||||
:quit
|
||||
EOF
|
||||
|
||||
# systemd should generate a new machine id during the first boot, to
|
||||
# avoid having multiple Vagrant instances with the same id in the local
|
||||
# network. /etc/machine-id should be empty, but it must exist to prevent
|
||||
# boot errors (e.g. systemd-journald failing to start).
|
||||
:>/etc/machine-id
|
||||
|
||||
echo 'vag' > /etc/yum/vars/infra
|
||||
|
||||
# Blacklist the floppy module to avoid probing timeouts
|
||||
echo blacklist floppy > /etc/modprobe.d/nofloppy.conf
|
||||
chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf
|
||||
|
||||
# Customize the initramfs
|
||||
pushd /etc/dracut.conf.d
|
||||
# Enable VMware PVSCSI support for VMware Fusion guests.
|
||||
echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf
|
||||
echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf
|
||||
# There's no floppy controller, but probing for it generates timeouts
|
||||
echo 'omit_drivers+=" floppy "' > nofloppy.conf
|
||||
popd
|
||||
# Fix the SELinux context of the new files
|
||||
restorecon -f - <<EOF
|
||||
/etc/sudoers.d/vagrant
|
||||
/etc/dracut.conf.d/vmware-fusion-drivers.conf
|
||||
/etc/dracut.conf.d/hyperv-drivers.conf
|
||||
/etc/dracut.conf.d/nofloppy.conf
|
||||
EOF
|
||||
|
||||
# Rerun dracut for the installed kernel (not the running kernel):
|
||||
KERNEL_VERSION=$(rpm -q kernel --qf '%\{version}-%\{release}.%\{arch}\n')
|
||||
dracut -f /boot/initramfs-$\{KERNEL_VERSION}.img $\{KERNEL_VERSION}
|
||||
|
||||
# Seal for deployment
|
||||
rm -rf /etc/ssh/ssh_host_*
|
||||
hostnamectl set-hostname localhost.localdomain
|
||||
rm -rf /etc/udev/rules.d/70-*
|
||||
%end
|
||||
KICKSTART
|
||||
}
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
# Name of the file to write out
|
||||
name="${0%.sh}"
|
||||
|
||||
baseurl="https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso"
|
||||
checksums="$(mktemp)"
|
||||
until curl -f -L -o "${checksums}" "${baseurl}.SHA256SUM"; do
|
||||
sleep 1
|
||||
done
|
||||
sha="$(cat "${checksums}" | awk '/SHA256/ {print $4}')"
|
||||
rm "${checksums}"
|
||||
|
||||
cat << HERPDERP > "${name}"
|
||||
distro = "centos"
|
||||
version = "9stream"
|
||||
iso = {
|
||||
url = "${baseurl}"
|
||||
checksum = "${sha}"
|
||||
}
|
||||
boot_command = [
|
||||
"<up><tab><wait><bs><bs><bs><bs><bs>",
|
||||
"inst.text inst.ks=cdrom:/ks.cfg console=tty0",
|
||||
"<enter><wait>"
|
||||
]
|
||||
cd_files = {
|
||||
"ks.cfg" = <<KICKSTART
|
||||
url --metalink=https://mirrors.centos.org/metalink?arch=x86_64&repo=centos-baseos-9-stream
|
||||
repo --name=AppStream --metalink=https://mirrors.centos.org/metalink?arch=x86_64&repo=centos-appstream-9-stream
|
||||
network --bootproto=dhcp --activate
|
||||
reboot
|
||||
|
||||
text
|
||||
keyboard --vckeymap us
|
||||
lang en_US
|
||||
skipx
|
||||
rootpw --plaintext vagrant
|
||||
firewall --disabled
|
||||
timezone --utc UTC
|
||||
services --enabled=vmtoolsd
|
||||
# The biosdevname and ifnames options ensure we get "eth0" as our interface
|
||||
# even in environments like virtualbox that emulate a real NW card
|
||||
bootloader --timeout=1 --append="no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop"
|
||||
zerombr
|
||||
%include /tmp/disks.ks
|
||||
|
||||
%pre --interpreter /bin/bash --log /tmp/greg
|
||||
if [ -e /dev/vda ]; then
|
||||
disk="vda"
|
||||
else
|
||||
disk="sda"
|
||||
fi
|
||||
echo "clearpart --all --drives=\$disk" > /tmp/disks.ks
|
||||
echo "part / --fstype=ext4 --asprimary --size=1024 --grow --ondisk=\$disk" >> /tmp/disks.ks
|
||||
%end
|
||||
|
||||
user --name=vagrant --plaintext --password=vagrant
|
||||
|
||||
%packages --inst-langs=en
|
||||
bash-completion
|
||||
man-pages
|
||||
bzip2
|
||||
rsync
|
||||
nfs-utils
|
||||
cifs-utils
|
||||
chrony
|
||||
yum-utils
|
||||
hyperv-daemons
|
||||
open-vm-tools
|
||||
# Vagrant boxes aren't normally visible, no need for Plymouth
|
||||
-plymouth
|
||||
# Microcode updates cannot work in a VM
|
||||
-microcode_ctl
|
||||
# Firmware packages are not needed in a VM
|
||||
-iwl100-firmware
|
||||
-iwl1000-firmware
|
||||
-iwl105-firmware
|
||||
-iwl135-firmware
|
||||
-iwl2000-firmware
|
||||
-iwl2030-firmware
|
||||
-iwl3160-firmware
|
||||
-iwl3945-firmware
|
||||
-iwl4965-firmware
|
||||
-iwl5000-firmware
|
||||
-iwl5150-firmware
|
||||
-iwl6000-firmware
|
||||
-iwl6000g2a-firmware
|
||||
-iwl6050-firmware
|
||||
-iwl7260-firmware
|
||||
# Don't build rescue initramfs
|
||||
-dracut-config-rescue
|
||||
%end
|
||||
|
||||
# kdump needs to reserve 160MB + 2bits/4kB RAM, and automatic allocation only
|
||||
# works on systems with at least 2GB RAM (which excludes most Vagrant boxes)
|
||||
# CBS doesn't support %addon yet https://bugs.centos.org/view.php?id=12169
|
||||
%addon com_redhat_kdump --disable
|
||||
%end
|
||||
|
||||
%post
|
||||
# configure swap to a file
|
||||
fallocate -l 2G /swapfile
|
||||
chmod 600 /swapfile
|
||||
mkswap /swapfile
|
||||
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
|
||||
|
||||
# sudo
|
||||
echo "%vagrant ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/vagrant
|
||||
chmod 0440 /etc/sudoers.d/vagrant
|
||||
|
||||
# Fix for https://github.com/CentOS/sig-cloud-instance-build/issues/38
|
||||
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
|
||||
DEVICE="eth0"
|
||||
BOOTPROTO="dhcp"
|
||||
ONBOOT="yes"
|
||||
TYPE="Ethernet"
|
||||
PERSISTENT_DHCLIENT="yes"
|
||||
EOF
|
||||
|
||||
# sshd: disable password authentication and DNS checks
|
||||
ex -s /etc/ssh/sshd_config <<EOF
|
||||
:%substitute/^\(PasswordAuthentication\) yes\$/\1 no/
|
||||
:%substitute/^#\(UseDNS\) yes\$/&\r\1 no/
|
||||
:update
|
||||
:quit
|
||||
EOF
|
||||
cat >>/etc/sysconfig/sshd <<EOF
|
||||
|
||||
# Decrease connection time by preventing reverse DNS lookups
|
||||
# (see https://lists.centos.org/pipermail/centos-devel/2016-July/014981.html
|
||||
# and man sshd for more information)
|
||||
OPTIONS="-u0"
|
||||
EOF
|
||||
|
||||
# Default insecure vagrant key
|
||||
mkdir -m 0700 -p /home/vagrant/.ssh
|
||||
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" >> /home/vagrant/.ssh/authorized_keys
|
||||
chmod 600 /home/vagrant/.ssh/authorized_keys
|
||||
chown -R vagrant:vagrant /home/vagrant/.ssh
|
||||
|
||||
# Fix for issue #76, regular users can gain admin privileges via su
|
||||
ex -s /etc/pam.d/su <<'EOF'
|
||||
# allow vagrant to use su, but prevent others from becoming root or vagrant
|
||||
/^account\s\+sufficient\s\+pam_succeed_if.so uid = 0 use_uid quiet\$/
|
||||
:append
|
||||
account [success=1 default=ignore] \\
|
||||
pam_succeed_if.so user = vagrant use_uid quiet
|
||||
account required pam_succeed_if.so user notin root:vagrant
|
||||
.
|
||||
:update
|
||||
:quit
|
||||
EOF
|
||||
|
||||
# systemd should generate a new machine id during the first boot, to
|
||||
# avoid having multiple Vagrant instances with the same id in the local
|
||||
# network. /etc/machine-id should be empty, but it must exist to prevent
|
||||
# boot errors (e.g. systemd-journald failing to start).
|
||||
:>/etc/machine-id
|
||||
|
||||
echo 'vag' > /etc/yum/vars/infra
|
||||
|
||||
# Blacklist the floppy module to avoid probing timeouts
|
||||
echo blacklist floppy > /etc/modprobe.d/nofloppy.conf
|
||||
chcon -u system_u -r object_r -t modules_conf_t /etc/modprobe.d/nofloppy.conf
|
||||
|
||||
# Customize the initramfs
|
||||
pushd /etc/dracut.conf.d
|
||||
# Enable VMware PVSCSI support for VMware Fusion guests.
|
||||
echo 'add_drivers+=" vmw_pvscsi "' > vmware-fusion-drivers.conf
|
||||
echo 'add_drivers+=" hv_netvsc hv_storvsc hv_utils hv_vmbus hid-hyperv "' > hyperv-drivers.conf
|
||||
# There's no floppy controller, but probing for it generates timeouts
|
||||
echo 'omit_drivers+=" floppy "' > nofloppy.conf
|
||||
popd
|
||||
# Fix the SELinux context of the new files
|
||||
restorecon -f - <<EOF
|
||||
/etc/sudoers.d/vagrant
|
||||
/etc/dracut.conf.d/vmware-fusion-drivers.conf
|
||||
/etc/dracut.conf.d/hyperv-drivers.conf
|
||||
/etc/dracut.conf.d/nofloppy.conf
|
||||
EOF
|
||||
|
||||
# Rerun dracut for the installed kernel (not the running kernel):
|
||||
KERNEL_VERSION=\$(rpm -q kernel --qf '%\{version}-%\{release}.%\{arch}\n')
|
||||
dracut -f /boot/initramfs-\$\{KERNEL_VERSION}.img \$\{KERNEL_VERSION}
|
||||
|
||||
# Seal for deployment
|
||||
rm -rf /etc/ssh/ssh_host_*
|
||||
hostnamectl set-hostname localhost.localdomain
|
||||
rm -rf /etc/udev/rules.d/70-*
|
||||
%end
|
||||
KICKSTART
|
||||
}
|
||||
HERPDERP
|
||||
@@ -10,5 +10,5 @@ source @(base / "test.xsh")
|
||||
opts = get_parser(sys.argv[1:])
|
||||
|
||||
cd @(str(base))
|
||||
for provider in get_providers():
|
||||
packer build -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources")
|
||||
for provider in opts["providers"]:
|
||||
packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources")
|
||||
|
||||
@@ -5,8 +5,8 @@ iso = {
|
||||
checksum = "b79079ad71cc3c5ceb3561fff348a1b67ee37f71f4cddfec09480d4589c191d6"
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"linux inst.ks=cdrom:/ks.cfg console=tty0",
|
||||
"<up><tab><wait>",
|
||||
"<bs><bs><bs><bs><bs> inst.ks=cdrom:/ks.cfg console=tty0",
|
||||
"<enter>"
|
||||
]
|
||||
cd_files = {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
distro = "debian"
|
||||
version = "10"
|
||||
iso = {
|
||||
url = "https://cdimage.debian.org/cdimage/archive/10.13.0/amd64/iso-cd/debian-10.13.0-amd64-netinst.iso"
|
||||
checksum = "75aa64071060402a594dcf1e14afd669ca0f8bf757b56d4c9c1a31b8f7c8f931"
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto ",
|
||||
"DEBIAN_FRONTEND=text ",
|
||||
"net.ifnames=0 ",
|
||||
"biosdevnames=0 ",
|
||||
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/debian/10-preseed.cfg ",
|
||||
"console=ttyS0 ",
|
||||
"console=tty0 ",
|
||||
"<enter>"
|
||||
]
|
||||
@@ -1,16 +0,0 @@
|
||||
distro = "debian"
|
||||
version = "11"
|
||||
iso = {
|
||||
url = "https://cdimage.debian.org/cdimage/archive/11.7.0/amd64/iso-cd/debian-11.7.0-amd64-netinst.iso"
|
||||
checksum = "eb3f96fd607e4b67e80f4fc15670feb7d9db5be50f4ca8d0bf07008cb025766b"
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto ",
|
||||
"DEBIAN_FRONTEND=text ",
|
||||
"net.ifnames=0 ",
|
||||
"biosdevnames=0 ",
|
||||
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/debian/11-preseed.cfg ",
|
||||
"console=ttyS0 ",
|
||||
"<enter>"
|
||||
]
|
||||
@@ -1,16 +0,0 @@
|
||||
distro = "debian"
|
||||
version = "12"
|
||||
iso = {
|
||||
url = "https://cdimage.debian.org/cdimage/archive/12.0.0/amd64/iso-cd/debian-12.0.0-amd64-netinst.iso"
|
||||
checksum = "3b0e9718e3653435f20d8c2124de6d363a51a1fd7f911b9ca0c6db6b3d30d53e"
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto ",
|
||||
"DEBIAN_FRONTEND=text ",
|
||||
"net.ifnames=0 ",
|
||||
"biosdevnames=0 ",
|
||||
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/debian/12-preseed.cfg ",
|
||||
"console=ttyS0 ",
|
||||
"<enter>"
|
||||
]
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env xonsh
|
||||
$RAISE_SUBPROC_ERROR = True
|
||||
from pathlib import Path
|
||||
import sys
|
||||
self = Path(__file__).absolute()
|
||||
base = self.parent.parent.parent.parent
|
||||
source @(base / "test.xsh")
|
||||
|
||||
|
||||
unsupported = set({
|
||||
})
|
||||
|
||||
opts = get_parser(sys.argv[1:], unsupported)
|
||||
|
||||
cd @(str(base))
|
||||
for provider in opts["providers"]:
|
||||
packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources")
|
||||
@@ -1,3 +1,19 @@
|
||||
distro = "debian"
|
||||
version = "10"
|
||||
iso = {
|
||||
url = "https://cdimage.debian.org/cdimage/archive/10.13.0/amd64/iso-cd/debian-10.13.0-amd64-netinst.iso"
|
||||
checksum = "75aa64071060402a594dcf1e14afd669ca0f8bf757b56d4c9c1a31b8f7c8f931"
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto ",
|
||||
"DEBIAN_FRONTEND=text ",
|
||||
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ",
|
||||
"console=tty0 ",
|
||||
"<enter>"
|
||||
]
|
||||
http_files = {
|
||||
"/preseed.cfg" = <<KICKSTART
|
||||
d-i debian-installer/locale string en_US
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
@@ -56,3 +72,5 @@ d-i preseed/late_command string
|
||||
echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant; \
|
||||
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \
|
||||
chmod 440 /target/etc/sudoers.d/vagrant
|
||||
KICKSTART
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env xonsh
|
||||
$RAISE_SUBPROC_ERROR = True
|
||||
from pathlib import Path
|
||||
import sys
|
||||
self = Path(__file__).absolute()
|
||||
base = self.parent.parent.parent.parent
|
||||
source @(base / "test.xsh")
|
||||
|
||||
|
||||
unsupported = set({
|
||||
})
|
||||
|
||||
opts = get_parser(sys.argv[1:], unsupported)
|
||||
|
||||
cd @(str(base))
|
||||
for provider in opts["providers"]:
|
||||
packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources")
|
||||
@@ -1,3 +1,19 @@
|
||||
distro = "debian"
|
||||
version = "11"
|
||||
iso = {
|
||||
url = "https://cdimage.debian.org/cdimage/archive/11.7.0/amd64/iso-cd/debian-11.7.0-amd64-netinst.iso"
|
||||
checksum = "eb3f96fd607e4b67e80f4fc15670feb7d9db5be50f4ca8d0bf07008cb025766b"
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto ",
|
||||
"DEBIAN_FRONTEND=text ",
|
||||
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ",
|
||||
"console=tty0 ",
|
||||
"<enter>"
|
||||
]
|
||||
http_files = {
|
||||
"/preseed.cfg" = <<KICKSTART
|
||||
d-i debian-installer/locale string en_US
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
@@ -56,3 +72,5 @@ d-i preseed/late_command string
|
||||
echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant; \
|
||||
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \
|
||||
chmod 440 /target/etc/sudoers.d/vagrant
|
||||
KICKSTART
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env xonsh
|
||||
$RAISE_SUBPROC_ERROR = True
|
||||
from pathlib import Path
|
||||
import sys
|
||||
self = Path(__file__).absolute()
|
||||
base = self.parent.parent.parent.parent
|
||||
source @(base / "test.xsh")
|
||||
|
||||
|
||||
unsupported = set({
|
||||
})
|
||||
|
||||
opts = get_parser(sys.argv[1:], unsupported)
|
||||
|
||||
cd @(str(base))
|
||||
for provider in opts["providers"]:
|
||||
packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources")
|
||||
@@ -1,3 +1,20 @@
|
||||
distro = "debian"
|
||||
version = "12"
|
||||
iso = {
|
||||
url = "https://cdimage.debian.org/cdimage/archive/12.0.0/amd64/iso-cd/debian-12.0.0-amd64-netinst.iso"
|
||||
checksum = "3b0e9718e3653435f20d8c2124de6d363a51a1fd7f911b9ca0c6db6b3d30d53e"
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto ",
|
||||
"DEBIAN_FRONTEND=text ",
|
||||
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ",
|
||||
"console=tty0 ",
|
||||
"<enter>"
|
||||
]
|
||||
http_files = {
|
||||
"/preseed.cfg" = <<KICKSTART
|
||||
d-i auto-install/enable boolean true
|
||||
d-i debian-installer/locale string en_US
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
@@ -56,3 +73,5 @@ d-i preseed/late_command string
|
||||
echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant; \
|
||||
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \
|
||||
chmod 440 /target/etc/sudoers.d/vagrant
|
||||
KICKSTART
|
||||
}
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env xonsh
|
||||
$RAISE_SUBPROC_ERROR = True
|
||||
from pathlib import Path
|
||||
import sys
|
||||
self = Path(__file__).absolute()
|
||||
base = self.parent.parent.parent.parent
|
||||
source @(base / "test.xsh")
|
||||
|
||||
|
||||
unsupported = set({
|
||||
})
|
||||
|
||||
opts = get_parser(sys.argv[1:], unsupported)
|
||||
|
||||
cd @(str(base))
|
||||
for provider in opts["providers"]:
|
||||
packer build -var=@(opts["headless"]) -var-file=@(self.parent / "x86_64.pkrvars.hcl") @(opts["upload"]) -only=@(provider) @(base / "sources")
|
||||
@@ -1,3 +1,30 @@
|
||||
distro = "debian"
|
||||
version = "9"
|
||||
iso = {
|
||||
url = "https://cdimage.debian.org/cdimage/archive/9.13.0/amd64/iso-cd/debian-9.13.0-amd64-netinst.iso"
|
||||
checksum = "71c7e9eb292acc880f84605b1ca2b997f25737fe0a43fc9586f61d35cd2eb43b"
|
||||
}
|
||||
boot_command = [
|
||||
"<esc><wait>",
|
||||
"auto ",
|
||||
"DEBIAN_FRONTEND=text ",
|
||||
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ",
|
||||
"console=tty0 ",
|
||||
"--- ", # Lines after this are copied to the resulting system?!
|
||||
"biosdevnames=0 ",
|
||||
"net.ifnames=0 ",
|
||||
"<enter>"
|
||||
]
|
||||
http_files = {
|
||||
"/preseed.cfg" = <<KICKSTART
|
||||
d-i mirror/country string manual
|
||||
d-i mirror/http/hostname string archive.kernel.org
|
||||
d-i mirror/http/directory string /debian-archive/debian
|
||||
|
||||
d-i apt-setup/security_host string archive.kernel.org/debian-archive
|
||||
|
||||
d-i netcfg/hostname string vagrant
|
||||
|
||||
d-i debian-installer/locale string en_US
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
@@ -56,3 +83,6 @@ d-i preseed/late_command string
|
||||
echo 'Defaults:vagrant !requiretty' > /target/etc/sudoers.d/vagrant; \
|
||||
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /target/etc/sudoers.d/vagrant; \
|
||||
chmod 440 /target/etc/sudoers.d/vagrant
|
||||
|
||||
KICKSTART
|
||||
}
|
||||
@@ -18,8 +18,7 @@ source "virtualbox-iso" "x86_64" {
|
||||
cpus = local.cpus
|
||||
memory = local.memory
|
||||
headless = var.headless
|
||||
nic_type = "virtio"
|
||||
guest_os_type = "RedHat_64"
|
||||
guest_os_type = "Linux_64"
|
||||
guest_additions_url = "http://download.virtualbox.org/virtualbox/7.0.10/VBoxGuestAdditions_7.0.10.iso"
|
||||
guest_additions_sha256 = "bbabd89b8fff38a257bab039a278f0c4dc4426eff6e4238c1db01edb7284186a"
|
||||
vboxmanage = [
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import argparse
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
@@ -16,10 +17,10 @@ def get_vagrant_provider(provider):
|
||||
|
||||
def get_providers():
|
||||
"List of providers as defined in sources/"
|
||||
providers: list[str] = [
|
||||
providers: set[str] = {
|
||||
"virtualbox-iso.x86_64",
|
||||
"qemu.x86_64"
|
||||
]
|
||||
}
|
||||
return providers
|
||||
|
||||
|
||||
@@ -31,46 +32,40 @@ def get_builds():
|
||||
return builds
|
||||
|
||||
|
||||
def get_parser(args):
|
||||
def get_parser(args, unsupported=set()):
|
||||
parser = argparse.ArgumentParser("Builder")
|
||||
parser.add_argument("--headless", action="store_true")
|
||||
parser.add_argument("--upload", action="store_true")
|
||||
parser.add_argument("--provider", action="append")
|
||||
parsed = parser.parse_args(args)
|
||||
opts = {}
|
||||
if parsed.headless:
|
||||
opts["headless"] = "hadless=true"
|
||||
opts["headless"] = "headless=true"
|
||||
else:
|
||||
opts["headless"] = "headless=false"
|
||||
if parsed.upload:
|
||||
opts["upload"] = ""
|
||||
else:
|
||||
opts["upload"] = "-except=upload"
|
||||
if parsed.provider:
|
||||
opts["providers"] = set(parsed.provider)
|
||||
else:
|
||||
opts["providers"] = get_providers()
|
||||
# Filter providers
|
||||
opts["providers"] -= unsupported
|
||||
return opts
|
||||
|
||||
|
||||
def main():
|
||||
# Equivalent of `set -e` in Bash
|
||||
$RAISE_SUBPROC_ERROR = True
|
||||
|
||||
# Parse user arguments
|
||||
parser = argparse.ArgumentParser("Test script")
|
||||
parser.add_argument("--build", "-b", required=True, choices=get_builds())
|
||||
parser.add_argument("--provider", "-p", default="virtualbox-iso.x86_64", choices=get_providers())
|
||||
parser.add_argument("--headless", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.headless:
|
||||
headless = "headless=true"
|
||||
else:
|
||||
headless = "headless=false"
|
||||
|
||||
packer build -var @(headless) -var-file distros/@(args.build).pkrvars.hcl -except=upload -only=@(args.provider) sources/
|
||||
vagrant box add --force --name @(args.build) @(args.build).box
|
||||
sed -e f's/@@BOX@@/{args.build}/' Vagrantfile.in > Vagrantfile
|
||||
vagrant up --provider @(get_vagrant_provider(args.provider)) --provision
|
||||
vagrant ssh -c "ls -la ~/"
|
||||
vagrant destroy -f
|
||||
rm -r .vagrant
|
||||
#$RAISE_SUBPROC_ERROR = True
|
||||
for box in g`*.box`:
|
||||
sed -e f's#@@BOX@@#file:///home/greg/src/vms/vms/{box}#' -e f's/@@BOX_NAME@@/{box}/' Vagrantfile.in > Vagrantfile
|
||||
#vagrant box add --force --name @(args.build) @(args.build).box
|
||||
#vagrant up --provider @(get_vagrant_provider(args.provider)) --provision
|
||||
vagrant up --provider libvirt
|
||||
vagrant destroy -f
|
||||
rm -rf .vagrant
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user