Browse Source

examples

master
dave 3 years ago
parent
commit
24bad32cc4
  1. 126
      isos/samples/lvm/ks.default
  2. 1
      isos/samples/vmtemplate/info.txt
  3. 193
      isos/samples/vmtemplate/ks.default
  4. 24
      isos/samples/vmtemplate/menu.default
  5. 45
      isos/samples/vmtemplate/seed.default

126
isos/samples/lvm/ks.default

@ -65,129 +65,3 @@ htop
%post
# Add arbitrary shell code to execute in the installer environment below here
# Ubuntu user
useradd --create-home --groups sudo --shell /bin/bash ubuntu
echo "ubuntu:ubuntu" | chpasswd
touch /home/ubuntu/.sudo_as_admin_successful
# First time startup script
cat <<"EOF" > /usr/local/sbin/vm-firstboot.sh
#!/bin/bash
set +x
sed -i -E "s/^#?PermitRootLogin .+/PermitRootLogin yes/" /etc/ssh/sshd_config
apt-get update
apt-get dist-upgrade -y
apt-get install -y open-vm-tools dirmngr
rm /etc/firstboot
reboot
EOF
chmod +x /usr/local/sbin/vm-firstboot.sh
# and systemd unit to call it
cat <<"EOF" > /etc/systemd/system/vm-firstboot.service
[Unit]
Description=Initialize this template-created VM
ConditionPathExists=/etc/firstboot
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/vm-firstboot.sh
[Install]
WantedBy=multi-user.target
EOF
ln -s /etc/systemd/system/vm-firstboot.service /etc/systemd/system/multi-user.target.wants/vm-firstboot.service
touch /etc/firstboot
# Template cleanup helper script
cat <<"EOF" > /usr/local/sbin/vm-clean.sh
#!/bin/bash
touch /etc/firstboot
rm -f /etc/ssh/*key*
rm -f /etc/machine-id
EOF
chmod +x /usr/local/sbin/vm-clean.sh
# First boot ssh key regen
cat <<"EOF" > /lib/systemd/system/ssh.service
[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/bin/bash -c "test -f /etc/ssh/ssh_host_rsa_key || ssh-keygen -A"
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=sshd.service
EOF
# First boot machine uuidgen
cat <<"EOF" > /etc/systemd/system/machineidgen.service
[Unit]
Description=Regen machine-id on first boot
Before=systemd-networkd.service systemd-journald.service
After=local-fs.target
ConditionPathExists=!/etc/machine-id
[Service]
Type=oneshot
ExecStart=/bin/systemd-machine-id-setup
[Install]
WantedBy=multi-user.target
EOF
ln -s /etc/systemd/system/machineidgen.service /etc/systemd/system/multi-user.target.wants/machineidgen.service
rm /etc/machine-id
# Show IP address on console
cp /etc/issue /etc/issue.tpl
cat <<"EOF" > /usr/local/sbin/console-set-ip.sh
#!/bin/bash
cat /etc/issue.tpl > /etc/issue
(ip addr | grep inet | awk '{print $2}' | grep -vE '^(::|fe80|127\.0\.0)') 2>&1 >> /etc/issue
echo "" >> /etc/issue
EOF
chmod +x /usr/local/sbin/console-set-ip.sh
cat <<"EOF" > /etc/systemd/system/consoleip.service
[Unit]
Description=Display machine ip on console
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/console-set-ip.sh
[Install]
WantedBy=multi-user.target
EOF
ln -s /etc/systemd/system/consoleip.service /etc/systemd/system/multi-user.target.wants/consoleip.service
rm -f /etc/update-motd.d/50-motd-news /etc/update-motd.d/80-livepatch

1
isos/samples/vmtemplate/info.txt

@ -0,0 +1 @@
Install suitable for a cloneable vm image template. Resets instance-specific items such as host keys on first boot. Includes cleanup tools.

193
isos/samples/vmtemplate/ks.default

@ -0,0 +1,193 @@
#System language
lang en_US
#Language modules to install
langsupport en_US
#System keyboard
keyboard us
#System mouse
mouse
#System timezone
timezone America/Los_Angeles
#Root password
rootpw ubuntu
#Initial user
user --disabled
#Reboot after installation
reboot
#Use text mode install
text
#Install OS instead of upgrade
install
#Use CDROM installation media
cdrom
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype ext2 --size=500
part pv.01 --size=1 --grow
volgroup vg_root pv.01
logvol / --vgname=vg_root --name=lv_root --size 1 --grow
#System authorization infomation
auth --useshadow --enablemd5
#Network information
network --bootproto=dhcp --device=eth0
#Firewall configuration
firewall --disabled
#Do not configure the X Window System
skipx
%packages
openssh-server
vim
htop
%post
# Add arbitrary shell code to execute in the installer environment below here
# Ubuntu user
useradd --create-home --groups sudo --shell /bin/bash ubuntu
echo "ubuntu:ubuntu" | chpasswd
touch /home/ubuntu/.sudo_as_admin_successful
# First time startup script
cat <<"EOF" > /usr/local/sbin/vm-firstboot.sh
#!/bin/bash
set +x
sed -i -E "s/^#?PermitRootLogin .+/PermitRootLogin yes/" /etc/ssh/sshd_config
apt-get update
apt-get dist-upgrade -y
apt-get install -y open-vm-tools dirmngr
rm -f /etc/firstboot /root/.bash_history /home/ubuntu/.bash_history
reboot
EOF
chmod +x /usr/local/sbin/vm-firstboot.sh
# and systemd unit to call it
cat <<"EOF" > /etc/systemd/system/vm-firstboot.service
[Unit]
Description=Initialize this template-created VM
ConditionPathExists=/etc/firstboot
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/vm-firstboot.sh
[Install]
WantedBy=multi-user.target
EOF
ln -s /etc/systemd/system/vm-firstboot.service /etc/systemd/system/multi-user.target.wants/vm-firstboot.service
touch /etc/firstboot
# Template cleanup helper script
cat <<"EOF" > /usr/local/sbin/vm-clean.sh
#!/bin/bash
touch /etc/firstboot
rm -f /etc/ssh/*key*
rm -f /etc/machine-id
EOF
chmod +x /usr/local/sbin/vm-clean.sh
# First boot ssh key regen
cat <<"EOF" > /lib/systemd/system/ssh.service
[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/ssh
ExecStartPre=/bin/bash -c "test -f /etc/ssh/ssh_host_rsa_key || ssh-keygen -A"
ExecStartPre=/usr/sbin/sshd -t
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/usr/sbin/sshd -t
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
RuntimeDirectory=sshd
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
Alias=sshd.service
EOF
# First boot machine uuidgen
cat <<"EOF" > /etc/systemd/system/machineidgen.service
[Unit]
Description=Regen machine-id on first boot
Before=systemd-networkd.service systemd-journald.service
After=local-fs.target
ConditionPathExists=!/etc/machine-id
[Service]
Type=oneshot
ExecStart=/bin/systemd-machine-id-setup
[Install]
WantedBy=multi-user.target
EOF
ln -s /etc/systemd/system/machineidgen.service /etc/systemd/system/multi-user.target.wants/machineidgen.service
rm /etc/machine-id
# Show IP address on console
cp /etc/issue /etc/issue.tpl
cat <<"EOF" > /usr/local/sbin/console-set-ip.sh
#!/bin/bash
cat /etc/issue.tpl > /etc/issue
(ip addr | grep inet | awk '{print $2}' | grep -vE '^(::|fe80|127\.0\.0)') 2>&1 >> /etc/issue
echo "" >> /etc/issue
EOF
chmod +x /usr/local/sbin/console-set-ip.sh
cat <<"EOF" > /etc/systemd/system/consoleip.service
[Unit]
Description=Display machine ip on console
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/console-set-ip.sh
[Install]
WantedBy=multi-user.target
EOF
ln -s /etc/systemd/system/consoleip.service /etc/systemd/system/multi-user.target.wants/consoleip.service
rm -f /etc/update-motd.d/50-motd-news /etc/update-motd.d/80-livepatch

24
isos/samples/vmtemplate/menu.default

@ -0,0 +1,24 @@
default install
label install
menu label ^Manual install
kernel /install/vmlinuz
append file=/cdrom/preseed/ubuntu-server.seed vga=788 initrd=/install/initrd.gz quiet --
label on_disk_kickstart
menu label ^Install from kickstart + seed
kernel /install/vmlinuz
append initrd=/install/initrd.gz ks=cdrom:/ks.cfg file=/cdrom/preseed/custom.seed --
label custom_seed
menu label ^Custom seed
kernel /install/vmlinuz
append initrd=/install/initrd.gz file=/cdrom/preseed/custom.seed --
label minimal_vm
menu label ^Minimal VM
kernel /install/vmlinuz
append initrd=/install/initrd.gz file=/cdrom/preseed/ubuntu-server-minimalvm.seed --
label memtest
menu label Test ^memory
kernel /install/mt86plus

45
isos/samples/vmtemplate/seed.default

@ -0,0 +1,45 @@
# Always install the virtual kernel.
d-i base-installer/kernel/override-image string linux-virtual
# Don't even install the standard task.
tasksel tasksel/skip-tasks string standard
# Only install basic language packs. Let tasksel ask about tasks.
d-i pkgsel/language-pack-patterns string
# No language support packages.
d-i pkgsel/install-language-support boolean false
# Only ask the UTC question if there are other operating systems installed.
d-i clock-setup/utc-auto boolean true
# Use UTC time
d-i time/zone string UTC
# Verbose output and no boot splash screen.
d-i debian-installer/quiet boolean false
d-i debian-installer/splash boolean false
# Install the debconf oem-config frontend (if in OEM mode).
d-i oem-config-udeb/frontend string debconf
# Wait for two seconds in grub
d-i grub-installer/timeout string 2
# Add the network and tasks oem-config steps by default.
oem-config oem-config/steps multiselect language, timezone, keyboard, user, network, tasks
# Overwrite/remove existing LVMs
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/confirm boolean true
# Bypass no swap warning
d-i partman-basicfilesystems/no_swap boolean false
# dont wait a long time for dhcp
d-i netcfg/dhcp_timeout string 8
d-i netcfg/dhcpv6_timeout string 8
# Allow weak passwords in installer
d-i user-setup/allow-password-weak boolean true
Loading…
Cancel
Save