|
|
@@ -0,0 +1,941 @@ |
|
|
############################# ON ERL3 ############################# |
|
|
# First SSH to the ELR3 then edit the configuration |
|
|
configure # drops you into the configuration terminal |
|
|
|
|
|
# Set the boot file. |
|
|
set service dhcp-server shared-network-name LAN1 subnet 172.16.24.0/22 bootfile-name pxelinux.0 |
|
|
|
|
|
# Set the boot server. |
|
|
set service dhcp-server shared-network-name LAN1 subnet 172.16.24.0/22 bootfile-server 172.16.24.90 |
|
|
|
|
|
# Set the TFTP server to the same as the bootfile-server (assuming they're the same in your case) |
|
|
set service dhcp-server shared-network-name LAN1 subnet 172.16.24.0/22 tftp-server-name 172.16.24.90 |
|
|
|
|
|
# Now commit the changes and save |
|
|
commit |
|
|
save |
|
|
|
|
|
# Exit the configuration terminal |
|
|
exit |
|
|
|
|
|
# Log out of the ERL3 |
|
|
exit |
|
|
############################# ON ERL3 ############################# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############################# ON PXE SERVER ############################# |
|
|
set -eouv |
|
|
|
|
|
export tftpboot_dir="/var/lib/tftpboot" |
|
|
export tftp_server="172.16.24.90" |
|
|
export tftp_ssh_key="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvCFVPmVN37Ti2ypHal3k23rSi3/FMhSGoHruyOSRCEobnWl/y86QA8D8I2GgwWi4z1qNv62KQyYGLDW6gHoBdx+X/jktu6DbyejY3h55T3fxo0gUPkQnBVGvg6KmtHNGMLzv+GExMuYnp2hSJ5ATgvh2edlYEqMIdAnMazecQ3Ia86qPiYcuB75V7t65NsDa5Io1iIiqLOaHXH//MXXXlfKr+RGnvv9VuhTy+dErYPa1Bl/mPvlist7zw860Wb3aQyFTObomIPbJIojpw/AKXKT4lyDRmdsqj8qKcCEIXW9zgFMUqbdF+lBtmOI05FU9csVrMTDrsz+jIQSIYbcGX [email protected]" |
|
|
export image_url="http://releases.ubuntu.com/16.04.2/ubuntu-16.04.2-server-amd64.iso" |
|
|
export image_name="$(basename ${image_url})" |
|
|
export image_short_name="$(basename -s .iso ${image_name})" |
|
|
|
|
|
# Web server setup |
|
|
apt install -y tftpd-hpa inetutils-inetd nginx p7zip-full p7zip-rar |
|
|
cat > /etc/nginx/sites-enabled/default <<EOF |
|
|
server { |
|
|
listen 80 default_server; |
|
|
listen [::]:80 default_server; |
|
|
root /var/www/pxe; |
|
|
location / { |
|
|
autoindex on; |
|
|
} |
|
|
} |
|
|
EOF |
|
|
|
|
|
systemctl restart nginx |
|
|
|
|
|
cat > /etc/default/tftpd-hpa <<EOF |
|
|
TFTP_USERNAME="tftp" |
|
|
TFTP_DIRECTORY="/var/lib/tftpboot" |
|
|
TFTP_ADDRESS=":69" |
|
|
TFTP_OPTIONS="--secure" |
|
|
RUN_DAEMON="yes" |
|
|
OPTIONS="-l -s /var/lib/tftpboot" |
|
|
EOF |
|
|
|
|
|
cat > /etc/inetd.conf <<EOF |
|
|
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot |
|
|
EOF |
|
|
|
|
|
systemctl restart tftpd-hpa |
|
|
systemctl restart inetutils-inetd |
|
|
|
|
|
# PXE server setup |
|
|
mkdir -p /var/www/pxe |
|
|
mkdir -p /var/www/pxe/scripts |
|
|
mkdir -p /var/www/pxe/networking |
|
|
mkdir -p /var/www/pxe/iso |
|
|
mkdir -p /var/www/pxe/images |
|
|
|
|
|
chown -R www-data:www-data /var/www |
|
|
chmod -R 2774 /var/www |
|
|
|
|
|
pushd /var/www/pxe |
|
|
pushd iso |
|
|
if [[ ! -f "${image_name}" ]]; then |
|
|
wget "${image_url}" -O "${image_name}" |
|
|
fi |
|
|
popd |
|
|
pushd images |
|
|
if [[ -d "${image_short_name}" ]]; then |
|
|
rm -rf "${image_short_name}" |
|
|
fi |
|
|
mkdir "${image_short_name}" |
|
|
pushd "${image_short_name}" |
|
|
7z x "/var/www/pxe/iso/${image_name}" |
|
|
popd |
|
|
popd |
|
|
popd |
|
|
|
|
|
mkdir -p "${tftpboot_dir}" |
|
|
mkdir -p "${tftpboot_dir}/boot-screens" |
|
|
mkdir -p "${tftpboot_dir}/preseed" |
|
|
mkdir -p "${tftpboot_dir}/pxelinux.cfg" |
|
|
|
|
|
cp -av "/var/www/pxe/images/${image_short_name}/install/netboot/ubuntu-installer" "${tftpboot_dir}/${image_short_name}" |
|
|
|
|
|
pushd "/var/www/pxe/images/${image_short_name}/isolinux" |
|
|
cp ldlinux.c32 "${tftpboot_dir}/" |
|
|
popd |
|
|
|
|
|
pushd "${tftpboot_dir}/${image_short_name}/amd64/" |
|
|
cp pxelinux.0 "${tftpboot_dir}/" |
|
|
pushd boot-screens |
|
|
cp libcom32.c32 "${tftpboot_dir}/boot-screens/" |
|
|
cp libutil.c32 "${tftpboot_dir}/boot-screens/" |
|
|
cp vesamenu.c32 "${tftpboot_dir}/boot-screens/" |
|
|
popd |
|
|
popd |
|
|
|
|
|
cat > ${tftpboot_dir}/pxelinux.cfg/default <<EOF |
|
|
path boot-screens |
|
|
include boot-screens/menu.cfg |
|
|
default boot-screens/vesamenu.c32 |
|
|
prompt 0 |
|
|
timeout 100 |
|
|
EOF |
|
|
|
|
|
pushd ${tftpboot_dir}/boot-screens |
|
|
ln -f ../pxelinux.cfg/default syslinux.cfg |
|
|
popd |
|
|
|
|
|
cat > ${tftpboot_dir}/boot-screens/menu.cfg <<EOF |
|
|
menu hshift 13 |
|
|
menu width 49 |
|
|
menu margin 8 |
|
|
menu tabmsg |
|
|
|
|
|
menu title Boot Menu |
|
|
label local |
|
|
menu label ^Boot local hard drive |
|
|
LOCALBOOT 0 |
|
|
|
|
|
label auto-ubuntu-16.04-vm |
|
|
menu label ^Ubuntu 16.04 vm automated install |
|
|
kernel ${image_short_name}/amd64/linux |
|
|
append biosdevname=0 net.ifnames=0 auto=true priority=critical vga=789 initrd=${image_short_name}/amd64/initrd.gz preseed/url=tftp://${tftp_server}/preseed/ubuntu-16.04-vm-preseed.cfg preseed/interactive=false netcfg/choose_interface=eth0 |
|
|
|
|
|
label auto-ubuntu-16.04-mnaio |
|
|
menu label ^Ubuntu 16.04 mnaio automated install |
|
|
kernel ${image_short_name}/amd64/linux |
|
|
append biosdevname=0 net.ifnames=0 auto=true priority=critical vga=789 initrd=${image_short_name}/amd64/initrd.gz preseed/url=tftp://${tftp_server}/preseed/ubuntu-16.04-mnaio-preseed.cfg preseed/interactive=false netcfg/choose_interface=eth0 |
|
|
|
|
|
menu begin ubuntu-16.04 |
|
|
menu title Ubuntu 16.04 |
|
|
label mainmenu |
|
|
menu label ^Back.. |
|
|
menu exit |
|
|
include ${image_short_name}/amd64/boot-screens/menu.cfg |
|
|
|
|
|
menu end |
|
|
EOF |
|
|
|
|
|
# create the default profile for a given mac address |
|
|
count=1 |
|
|
for i in infra1 infra2 infra3 compute1 swift1 cinder1; do |
|
|
VM_NAME="${i}" |
|
|
cat > "${tftpboot_dir}/pxelinux.cfg/01-52-54-00-bd-80-$(printf "%02d" ${count})" <<EOF |
|
|
default linux |
|
|
prompt 0 |
|
|
timeout 1 |
|
|
label linux |
|
|
kernel ${image_short_name}/amd64/linux |
|
|
append hostname=${VM_NAME} biosdevname=0 net.ifnames=0 auto=true priority=critical vga=789 initrd=${image_short_name}/amd64/initrd.gz preseed/url=tftp://${tftp_server}/preseed/ubuntu-16.04-vm-preseed.cfg preseed/interactive=false netcfg/choose_interface=eth0 |
|
|
EOF |
|
|
count=$((count + 1)) |
|
|
done |
|
|
|
|
|
cat > ${tftpboot_dir}/preseed/ubuntu-16.04-vm-preseed.cfg <<EOF |
|
|
# Ubuntu Server 16.04 Preseed |
|
|
# Kernel Options |
|
|
|
|
|
# Use the following option to add additional boot parameters for the |
|
|
# installed system (if supported by the bootloader installer). |
|
|
# Note: options passed to the installer will be added automatically. |
|
|
d-i debian-installer/add-kernel-opts string biosdevname=0 net.ifnames=0 |
|
|
|
|
|
# Networking |
|
|
d-i netcfg/choose_interface select eth0 |
|
|
d-i netcfg/dhcp_timeout string 60 |
|
|
d-i netcfg/get_hostname string common1 |
|
|
d-i netcfg/get_domain string common1.openstackci.local |
|
|
|
|
|
## USE THIS FOR STATIC NETWORKING |
|
|
# d-i netcfg/disable_autoconfig boolean true |
|
|
# d-i netcfg/dhcp_failed note |
|
|
# d-i netcfg/dhcp_options select Configure network manually |
|
|
|
|
|
# # Static network configuration. |
|
|
# d-i netcfg/get_ipaddress string 10.0.0.100 |
|
|
# d-i netcfg/get_netmask string 255.255.255.0 |
|
|
# d-i netcfg/get_gateway string 10.0.0.200 |
|
|
# d-i netcfg/get_nameservers string 8.8.8.8 |
|
|
# d-i netcfg/confirm_static boolean true |
|
|
## USE THIS FOR STATIC NETWORKING |
|
|
|
|
|
# Disable that annoying WEP key dialog. |
|
|
d-i netcfg/wireless_wep string |
|
|
|
|
|
# Pre Install |
|
|
|
|
|
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726. |
|
|
d-i preseed/early_command string \ |
|
|
umount /media || true |
|
|
|
|
|
# Net Image |
|
|
|
|
|
# Required at least for 12.10+ |
|
|
d-i live-installer/net-image string http://${tftp_server}/images/${image_short_name}/install/filesystem.squashfs |
|
|
|
|
|
# Localization |
|
|
|
|
|
d-i debian-installer/locale string en |
|
|
d-i debian-installer/country string US |
|
|
d-i debian-installer/locale string en_US.UTF-8 |
|
|
d-i debian-installer/language string en |
|
|
|
|
|
# Keyboard |
|
|
|
|
|
# Disable automatic (interactive) keymap detection. |
|
|
d-i console-setup/ask_detect boolean false |
|
|
d-i console-setup/layoutcode string us |
|
|
d-i console-setup/variantcode string |
|
|
d-i keyboard-configuration/layoutcode string us |
|
|
|
|
|
# Mirror |
|
|
|
|
|
d-i mirror/country string manual |
|
|
d-i mirror/http/proxy string |
|
|
d-i mirror/http/hostname string archive.ubuntu.com |
|
|
d-i mirror/http/directory string /ubuntu |
|
|
|
|
|
# Clock and Time Zone |
|
|
|
|
|
# Controls whether to use NTP to set the clock during the install |
|
|
d-i clock-setup/ntp boolean true |
|
|
d-i clock-setup/ntp-server string ntp.ubuntu.com |
|
|
|
|
|
# You may set this to any valid setting for TZ; see the contents of |
|
|
# /usr/share/zoneinfo/ for valid values. |
|
|
d-i time/zone string US/Central |
|
|
|
|
|
# Controls whether or not the hardware clock is set to UTC. |
|
|
d-i clock-setup/utc boolean true |
|
|
|
|
|
# Partitioning |
|
|
|
|
|
# If one of the disks that are going to be automatically partitioned |
|
|
# contains an old LVM configuration, the user will normally receive a |
|
|
# warning. This can be preseeded away... |
|
|
d-i partman-lvm/device_remove_lvm boolean true |
|
|
d-i partman-lvm/device_remove_lvm_span boolean true |
|
|
d-i partman-auto/purge_lvm_from_device boolean true |
|
|
|
|
|
# The same applies to pre-existing software RAID array: |
|
|
d-i partman-md/device_remove_md boolean true |
|
|
|
|
|
# And the same goes for the confirmation to write the lvm partitions. |
|
|
d-i partman-lvm/confirm boolean true |
|
|
d-i partman-lvm/confirm_nooverwrite boolean true |
|
|
|
|
|
d-i partman-auto/method string lvm |
|
|
d-i partman-auto/disk string /dev/[sv]da |
|
|
|
|
|
# For LVM partitioning, you can select how much of the volume group to use |
|
|
# for logical volumes. |
|
|
d-i partman-auto-lvm/guided_size string max |
|
|
|
|
|
d-i partman-auto/choose_recipe select custompartitioning |
|
|
d-i partman-auto/expert_recipe string \ |
|
|
custompartitioning :: \ |
|
|
512 1 512 ext2 \ |
|
|
\$primary{ } \ |
|
|
\$bootable{ } \ |
|
|
method{ format } \ |
|
|
format{ } \ |
|
|
use_filesystem{ } \ |
|
|
filesystem{ ext2 } \ |
|
|
label{ boot } \ |
|
|
mountpoint{ /boot } \ |
|
|
. \ |
|
|
1024 1 100% ext4 \ |
|
|
\$primary{ } \ |
|
|
method{ lvm } \ |
|
|
vg_name{ vg00 } \ |
|
|
. \ |
|
|
1024 512 800% linux-swap \ |
|
|
\$lvmok{ } \ |
|
|
in_vg{ vg00 } \ |
|
|
lv_name{ swap00 } \ |
|
|
method{ swap } \ |
|
|
label{ swap } \ |
|
|
format{ } \ |
|
|
. \ |
|
|
16384 5000 100% ext4 \ |
|
|
\$lvmok{ } \ |
|
|
in_vg{ vg00 } \ |
|
|
lv_name{ root00 } \ |
|
|
method{ format } \ |
|
|
format{ } \ |
|
|
use_filesystem{ } \ |
|
|
filesystem{ ext4 } \ |
|
|
label{ root } \ |
|
|
mountpoint{ / } \ |
|
|
. \ |
|
|
81920 1000 100% ext4 \ |
|
|
\$lvmok{ } \ |
|
|
in_vg{ vg00 } \ |
|
|
lv_name{ openstack00 } \ |
|
|
method{ format } \ |
|
|
format{ } \ |
|
|
use_filesystem{ } \ |
|
|
filesystem{ ext4 } \ |
|
|
label{ openstack } \ |
|
|
mountpoint{ /openstack } \ |
|
|
. \ |
|
|
81920 1000 100% btrfs \ |
|
|
\$lvmok{ } \ |
|
|
in_vg{ vg00 } \ |
|
|
lv_name{ machines00 } \ |
|
|
method{ format } \ |
|
|
format{ } \ |
|
|
use_filesystem{ } \ |
|
|
filesystem{ btrfs } \ |
|
|
label{ machines } \ |
|
|
mountpoint{ /var/lib/machines } \ |
|
|
. \ |
|
|
|
|
|
# This makes partman automatically partition without confirmation, provided |
|
|
# that you told it what to do using one of the methods above. |
|
|
d-i partman-partitioning/confirm_write_new_label boolean true |
|
|
d-i partman/choose_partition select finish |
|
|
d-i partman/confirm boolean true |
|
|
d-i partman/confirm_nooverwrite boolean true |
|
|
|
|
|
# Packages |
|
|
|
|
|
# Package selection |
|
|
tasksel tasksel/first multiselect openssh-server |
|
|
|
|
|
# Whether to upgrade packages after debootstrap. |
|
|
# Allowed values: none, safe-upgrade, full-upgrade |
|
|
d-i pkgsel/upgrade select none |
|
|
d-i pkgsel/include string bridge-utils \ |
|
|
dstat \ |
|
|
ethtool \ |
|
|
git \ |
|
|
htop \ |
|
|
ifenslave \ |
|
|
lvm2 \ |
|
|
openssh-server \ |
|
|
parted \ |
|
|
python-all \ |
|
|
tmux \ |
|
|
vim \ |
|
|
vlan |
|
|
|
|
|
d-i pkgsel/update-policy select none |
|
|
|
|
|
# Some versions of the installer can report back on what software you have |
|
|
# installed, and what software you use. The default is not to report back, |
|
|
# but sending reports helps the project determine what software is most |
|
|
# popular and include it on CDs. |
|
|
popularity-contest popularity-contest/participate boolean false |
|
|
|
|
|
# Users and Password |
|
|
|
|
|
# Skip creation of a root account (normal user account will be able to |
|
|
# use sudo). The default is false; preseed this to true if you want to set |
|
|
# a root password. |
|
|
d-i passwd/root-login boolean true |
|
|
|
|
|
# Alternatively, to skip creation of a normal user account. |
|
|
d-i passwd/make-user boolean false |
|
|
|
|
|
# The installer will warn about weak passwords. If you are sure you know |
|
|
# what you're doing and want to override it, uncomment this. |
|
|
d-i user-setup/allow-password-weak boolean true |
|
|
|
|
|
# Root password, either in clear text |
|
|
d-i passwd/root-password password secrete |
|
|
d-i passwd/root-password-again password secrete |
|
|
|
|
|
# Bootloader |
|
|
|
|
|
# This is fairly safe to set, it makes grub install automatically to the MBR |
|
|
# if no other operating system is detected on the machine. |
|
|
d-i grub-installer/only_debian boolean true |
|
|
|
|
|
# Post Install |
|
|
|
|
|
d-i preseed/late_command string \ |
|
|
in-target bash -c 'apt-get remove --purge snap* lxc* lxd* || true'; \ |
|
|
sed -i 's/\(GRUB_CMDLINE_LINUX_DEFAULT=\).*/\1\"\"/g' /target/etc/default/grub; \ |
|
|
in-target bash -c 'update-grub'; \ |
|
|
sed -i '/PermitRootLogin / s/ .*/ yes/' /target/etc/ssh/sshd_config; \ |
|
|
mkdir /target/root/.ssh; \ |
|
|
chmod 0700 /target/root/.ssh; \ |
|
|
echo "${tftp_ssh_key}" >> /target/root/.ssh/authorized_keys; \ |
|
|
in-target bash -c "wget http://${tftp_server}/networking/\$(hostname)-bridges.cfg -O /etc/network/interfaces.d/vm-bridges.cfg"; \ |
|
|
in-target bash -c "wget http://${tftp_server}/networking/basic-interface.cfg -O /etc/network/interfaces" |
|
|
# Finish |
|
|
|
|
|
# Reboot after the install is finished. |
|
|
finish-install finish-install/reboot_in_progress note |
|
|
EOF |
|
|
|
|
|
cat > ${tftpboot_dir}/preseed/ubuntu-16.04-mnaio-preseed.cfg <<EOF |
|
|
# Ubuntu Server 16.04 Preseed |
|
|
# Kernel Options |
|
|
|
|
|
# Use the following option to add additional boot parameters for the |
|
|
# installed system (if supported by the bootloader installer). |
|
|
# Note: options passed to the installer will be added automatically. |
|
|
d-i debian-installer/add-kernel-opts string biosdevname=0 net.ifnames=0 |
|
|
|
|
|
# Networking |
|
|
d-i netcfg/choose_interface select eth0 |
|
|
d-i netcfg/dhcp_timeout string 60 |
|
|
d-i netcfg/get_hostname string host1 |
|
|
d-i netcfg/get_domain string host1.openstack.local |
|
|
|
|
|
## USE THIS FOR STATIC NETWORKING |
|
|
# d-i netcfg/disable_autoconfig boolean true |
|
|
# d-i netcfg/dhcp_failed note |
|
|
# d-i netcfg/dhcp_options select Configure network manually |
|
|
|
|
|
# # Static network configuration. |
|
|
# d-i netcfg/get_ipaddress string 10.0.0.100 |
|
|
# d-i netcfg/get_netmask string 255.255.255.0 |
|
|
# d-i netcfg/get_gateway string 10.0.0.200 |
|
|
# d-i netcfg/get_nameservers string 8.8.8.8 |
|
|
# d-i netcfg/confirm_static boolean true |
|
|
## USE THIS FOR STATIC NETWORKING |
|
|
|
|
|
# Disable that annoying WEP key dialog. |
|
|
d-i netcfg/wireless_wep string |
|
|
|
|
|
# Pre Install |
|
|
|
|
|
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726. |
|
|
d-i preseed/early_command string \ |
|
|
umount /media || true |
|
|
|
|
|
# Net Image |
|
|
|
|
|
# Required at least for 12.10+ |
|
|
d-i live-installer/net-image string http://${tftp_server}/images/${image_short_name}/install/filesystem.squashfs |
|
|
|
|
|
# Localization |
|
|
|
|
|
d-i debian-installer/locale string en |
|
|
d-i debian-installer/country string US |
|
|
d-i debian-installer/locale string en_US.UTF-8 |
|
|
d-i debian-installer/language string en |
|
|
|
|
|
# Keyboard |
|
|
|
|
|
# Disable automatic (interactive) keymap detection. |
|
|
d-i console-setup/ask_detect boolean false |
|
|
d-i console-setup/layoutcode string us |
|
|
d-i console-setup/variantcode string |
|
|
d-i keyboard-configuration/layoutcode string us |
|
|
|
|
|
# Mirror |
|
|
|
|
|
d-i mirror/country string manual |
|
|
d-i mirror/http/proxy string |
|
|
d-i mirror/http/hostname string archive.ubuntu.com |
|
|
d-i mirror/http/directory string /ubuntu |
|
|
|
|
|
# Clock and Time Zone |
|
|
|
|
|
# Controls whether to use NTP to set the clock during the install |
|
|
d-i clock-setup/ntp boolean true |
|
|
d-i clock-setup/ntp-server string ntp.ubuntu.com |
|
|
|
|
|
# You may set this to any valid setting for TZ; see the contents of |
|
|
# /usr/share/zoneinfo/ for valid values. |
|
|
d-i time/zone string US/Central |
|
|
|
|
|
# Controls whether or not the hardware clock is set to UTC. |
|
|
d-i clock-setup/utc boolean true |
|
|
|
|
|
# Partitioning |
|
|
|
|
|
# If one of the disks that are going to be automatically partitioned |
|
|
# contains an old LVM configuration, the user will normally receive a |
|
|
# warning. This can be preseeded away... |
|
|
d-i partman-lvm/device_remove_lvm boolean true |
|
|
d-i partman-lvm/device_remove_lvm_span boolean true |
|
|
d-i partman-auto/purge_lvm_from_device boolean true |
|
|
|
|
|
# The same applies to pre-existing software RAID array: |
|
|
d-i partman-md/device_remove_md boolean true |
|
|
|
|
|
# And the same goes for the confirmation to write the lvm partitions. |
|
|
d-i partman-lvm/confirm boolean true |
|
|
d-i partman-lvm/confirm_nooverwrite boolean true |
|
|
d-i partman-md/confirm boolean true |
|
|
d-i partman-md/confirm_nooverwrite boolean true |
|
|
|
|
|
d-i partman-basicfilesystems/choose_label string gpt |
|
|
d-i partman-basicfilesystems/default_label string gpt |
|
|
d-i partman-partitioning/choose_label string gpt |
|
|
d-i partman-partitioning/default_label string gpt |
|
|
d-i partman/choose_label string gpt |
|
|
d-i partman/default_label string gpt |
|
|
|
|
|
d-i partman-auto/method string raid |
|
|
d-i partman-auto/disk string /dev/[sv]da /dev/[sv]db |
|
|
|
|
|
# For LVM partitioning, you can select how much of the volume group to use |
|
|
# for logical volumes. |
|
|
d-i partman-auto-lvm/guided_size string max |
|
|
d-i partman-auto-lvm/new_vg_name string vg00 |
|
|
|
|
|
d-i partman-auto/choose_recipe select custompartitioning |
|
|
|
|
|
d-i partman-auto/expert_recipe string \ |
|
|
custompartitioning :: \ |
|
|
1 1 1 free \ |
|
|
\$gptonly{ } \ |
|
|
\$primary{ } \ |
|
|
\$bios_boot{ } \ |
|
|
method{ biosgrub } \ |
|
|
. \ |
|
|
256 1 512 raid \ |
|
|
\$gptonly{ } \ |
|
|
\$lvmignore{ } \ |
|
|
\$primary{ } \ |
|
|
\$bootable{ } \ |
|
|
method{ raid } \ |
|
|
raidid{ 1 } \ |
|
|
. \ |
|
|
204800 1 -1 raid \ |
|
|
\$gptonly{ } \ |
|
|
\$lvmignore{ } \ |
|
|
method{ raid } \ |
|
|
raidid{ 2 } \ |
|
|
. \ |
|
|
1024 512 400% linux-swap \ |
|
|
\$defaultignore{ } \ |
|
|
\$lvmok{ } \ |
|
|
method{ swap } \ |
|
|
format{ } \ |
|
|
. \ |
|
|
16384 5000 100% ext4 \ |
|
|
\$defaultignore{ } \ |
|
|
\$lvmok{ } \ |
|
|
method{ format } \ |
|
|
format{ } \ |
|
|
use_filesystem{ } \ |
|
|
filesystem{ ext4 } \ |
|
|
mountpoint{ / } \ |
|
|
. \ |
|
|
81920 1000 100% ext4 \ |
|
|
\$defaultignore{ } \ |
|
|
\$lvmok{ } \ |
|
|
lv_name{ openstack00 } \ |
|
|
method{ format } \ |
|
|
format{ } \ |
|
|
use_filesystem{ } \ |
|
|
filesystem{ ext4 } \ |
|
|
label{ openstack } \ |
|
|
mountpoint{ /openstack } \ |
|
|
. \ |
|
|
81920 1000 100% btrfs \ |
|
|
\$defaultignore{ } \ |
|
|
\$lvmok{ } \ |
|
|
lv_name{ machines00 } \ |
|
|
method{ format } \ |
|
|
format{ } \ |
|
|
use_filesystem{ } \ |
|
|
filesystem{ btrfs } \ |
|
|
label{ machines } \ |
|
|
mountpoint{ /var/lib/machines } \ |
|
|
. \ |
|
|
|
|
|
d-i partman-auto-raid/recipe string \ |
|
|
0 2 0 ext2 /boot raidid=1 \ |
|
|
/dev/[sv]da1#/dev/[sv]db1 \ |
|
|
. \ |
|
|
0 2 0 lvm - raidid=2 \ |
|
|
/dev/[sv]da5#/dev/[sv]db5 \ |
|
|
. \ |
|
|
|
|
|
# This makes partman automatically partition without confirmation, provided |
|
|
# that you told it what to do using one of the methods above. |
|
|
d-i partman-partitioning/confirm_write_new_label boolean true |
|
|
d-i partman/choose_partition select finish |
|
|
d-i partman/confirm boolean true |
|
|
d-i partman/confirm_nooverwrite boolean true |
|
|
|
|
|
# Packages |
|
|
|
|
|
# Package selection |
|
|
tasksel tasksel/first multiselect openssh-server |
|
|
|
|
|
# Whether to upgrade packages after debootstrap. |
|
|
# Allowed values: none, safe-upgrade, full-upgrade |
|
|
d-i pkgsel/upgrade select full-upgrade |
|
|
d-i pkgsel/include string bridge-utils \ |
|
|
dstat \ |
|
|
ethtool \ |
|
|
git \ |
|
|
htop \ |
|
|
ifenslave \ |
|
|
libvirt-bin \ |
|
|
lvm2 \ |
|
|
openssh-server \ |
|
|
parted \ |
|
|
python3-all \ |
|
|
python-all \ |
|
|
qemu-kvm \ |
|
|
systemd-container \ |
|
|
tmux \ |
|
|
vim \ |
|
|
virt-manager \ |
|
|
virtinst \ |
|
|
vlan |
|
|
|
|
|
d-i pkgsel/update-policy select none |
|
|
|
|
|
# Some versions of the installer can report back on what software you have |
|
|
# installed, and what software you use. The default is not to report back, |
|
|
# but sending reports helps the project determine what software is most |
|
|
# popular and include it on CDs. |
|
|
popularity-contest popularity-contest/participate boolean false |
|
|
|
|
|
# Users and Password |
|
|
|
|
|
# Skip creation of a root account (normal user account will be able to |
|
|
# use sudo). The default is false; preseed this to true if you want to set |
|
|
# a root password. |
|
|
d-i passwd/root-login boolean true |
|
|
|
|
|
# Alternatively, to skip creation of a normal user account. |
|
|
d-i passwd/make-user boolean false |
|
|
|
|
|
# The installer will warn about weak passwords. If you are sure you know |
|
|
# what you're doing and want to override it, uncomment this. |
|
|
d-i user-setup/allow-password-weak boolean true |
|
|
|
|
|
# Root password, either in clear text |
|
|
d-i passwd/root-password password secrete |
|
|
d-i passwd/root-password-again password secrete |
|
|
|
|
|
# Bootloader |
|
|
|
|
|
# This is fairly safe to set, it makes grub install automatically to the MBR |
|
|
# if no other operating system is detected on the machine. |
|
|
d-i grub-installer/only_debian boolean true |
|
|
|
|
|
# Post Install |
|
|
|
|
|
d-i preseed/late_command string \ |
|
|
in-target bash -c 'apt-get remove --purge snap* lxc* lxd* || true'; \ |
|
|
sed -i 's/\(GRUB_CMDLINE_LINUX_DEFAULT=\).*/\1\"\"/g' /target/etc/default/grub; \ |
|
|
in-target bash -c 'update-grub'; \ |
|
|
sed -i '/PermitRootLogin / s/ .*/ yes/' /target/etc/ssh/sshd_config; \ |
|
|
mkdir /target/root/.ssh; \ |
|
|
chmod 0700 /target/root/.ssh; \ |
|
|
echo "${tftp_ssh_key}" >> /target/root/.ssh/authorized_keys; \ |
|
|
in-target bash -c "wget http://${tftp_server}/networking/mnaio-bridges.cfg -O /etc/network/interfaces.d/mnaio-bridges.cfg"; \ |
|
|
in-target bash -c "wget http://${tftp_server}/networking/basic-interface.cfg -O /etc/network/interfaces" |
|
|
# Finish |
|
|
|
|
|
# Reboot after the install is finished. |
|
|
finish-install finish-install/reboot_in_progress note |
|
|
EOF |
|
|
|
|
|
cat > /var/www/pxe/networking/vm-bridges.cfg <<EOF |
|
|
# Physical interface, could be bond. This only needs to be set once |
|
|
# for the physical device MANAGEMENT Network |
|
|
auto eth1 |
|
|
iface eth1 inet manual |
|
|
|
|
|
# FLAT Network |
|
|
auto eth2 |
|
|
iface eth2 inet manual |
|
|
|
|
|
# VLAN Network |
|
|
auto eth3 |
|
|
iface eth3 inet manual |
|
|
|
|
|
# TUNNEL Network |
|
|
auto eth4 |
|
|
iface eth4 inet manual |
|
|
|
|
|
# STORAGE Network |
|
|
auto eth5 |
|
|
iface eth5 inet manual |
|
|
|
|
|
auto br-dhcp |
|
|
iface br-dhcp inet dhcp |
|
|
bridge_stp off |
|
|
bridge_waitport 0 |
|
|
bridge_fd 0 |
|
|
bridge_ports eth0 |
|
|
offload-sg off |
|
|
|
|
|
auto br-mgmt |
|
|
iface br-mgmt inet static |
|
|
bridge_stp off |
|
|
bridge_waitport 10 |
|
|
bridge_fd 0 |
|
|
bridge_ports eth1 |
|
|
address 10.0.236.__COUNT__ |
|
|
netmask 255.255.252.0 |
|
|
offload-sg off |
|
|
|
|
|
auto br-flat |
|
|
iface br-flat inet static |
|
|
bridge_stp off |
|
|
bridge_waitport 10 |
|
|
bridge_fd 0 |
|
|
bridge_ports eth2 |
|
|
address 10.0.248.__COUNT__ |
|
|
netmask 255.255.252.0 |
|
|
offload-sg off |
|
|
|
|
|
auto br-vlan |
|
|
iface br-vlan inet manual |
|
|
bridge_stp off |
|
|
bridge_waitport 10 |
|
|
bridge_fd 0 |
|
|
bridge_ports eth3 |
|
|
offload-sg off |
|
|
|
|
|
auto br-vxlan |
|
|
iface br-vxlan inet static |
|
|
bridge_stp off |
|
|
bridge_waitport 10 |
|
|
bridge_fd 0 |
|
|
bridge_ports eth4 |
|
|
address 10.0.240.__COUNT__ |
|
|
netmask 255.255.252.0 |
|
|
offload-sg off |
|
|
# To ensure ssh checksum is correct |
|
|
up /sbin/iptables -A POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill |
|
|
down /sbin/iptables -D POSTROUTING -t mangle -p tcp --dport 22 -j CHECKSUM --checksum-fill |
|
|
# To provide internet connectivity to instances |
|
|
up /sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
|
|
down /sbin/iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE |
|
|
# Make sure instances can talk to the metadata server |
|
|
up /sbin/iptables -t mangle -A POSTROUTING -p tcp --sport 80 -j CHECKSUM --checksum-fill |
|
|
|
|
|
auto br-storage |
|
|
iface br-storage inet static |
|
|
bridge_stp off |
|
|
bridge_waitport 10 |
|
|
bridge_fd 0 |
|
|
bridge_ports eth5 |
|
|
address 10.0.244.__COUNT__ |
|
|
netmask 255.255.252.0 |
|
|
offload-sg off |
|
|
EOF |
|
|
|
|
|
cat > /var/www/pxe/networking/mnaio-bridges.cfg <<EOF |
|
|
#### SYSTEM INTEGRATION DEVICES #### |
|
|
auto br-dhcp |
|
|
iface br-dhcp inet dhcp |
|
|
bridge_stp off |
|
|
bridge_waitport 0 |
|
|
bridge_fd 0 |
|
|
bridge_ports eth0 |
|
|
offload-sg off |
|
|
|
|
|
iface br-dhcp inet static |
|
|
address 10.29.234.200 |
|
|
netmask 255.255.255.0 |
|
|
|
|
|
# This is an autoconfigured IPv6 interface |
|
|
iface br-dhcp inet6 auto |
|
|
#### SYSTEM INTEGRATION DEVICES #### |
|
|
|
|
|
#### BRIDGES USED FOR VM INTERFACES #### |
|
|
# MANAGEMENT Network |
|
|
auto vm-br-eth1 |
|
|
iface vm-br-eth1 inet static |
|
|
bridge_stp off |
|
|
bridge_waitport 0 |
|
|
bridge_fd 0 |
|
|
bridge_ports none |
|
|
address 10.29.236.200 |
|
|
netmask 255.255.252.0 |
|
|
offload-sg off |
|
|
|
|
|
# FLAT Network |
|
|
auto vm-br-eth2 |
|
|
iface vm-br-eth2 inet static |
|
|
bridge_stp off |
|
|
bridge_waitport 0 |
|
|
bridge_fd 0 |
|
|
bridge_ports none |
|
|
address 10.29.248.200 |
|
|
netmask 255.255.252.0 |
|
|
offload-sg off |
|
|
|
|
|
# VLAN Network |
|
|
auto vm-br-eth3 |
|
|
iface vm-br-eth3 inet manual |
|
|
bridge_stp off |
|
|
bridge_waitport 0 |
|
|
bridge_fd 0 |
|
|
bridge_ports none |
|
|
offload-sg off |
|
|
|
|
|
# TUNNEL Network |
|
|
auto vm-br-eth4 |
|
|
iface vm-br-eth4 inet manual |
|
|
bridge_stp off |
|
|
bridge_waitport 0 |
|
|
bridge_fd 0 |
|
|
bridge_ports none |
|
|
offload-sg off |
|
|
|
|
|
# STORAGE Network |
|
|
auto vm-br-eth5 |
|
|
iface vm-br-eth5 inet manual |
|
|
bridge_stp off |
|
|
bridge_waitport 0 |
|
|
bridge_fd 0 |
|
|
bridge_ports none |
|
|
offload-sg off |
|
|
#### INTERFACES USED FOR VM BRIDGES #### |
|
|
EOF |
|
|
|
|
|
cat > /var/www/pxe/networking/basic-interface.cfg <<EOF |
|
|
# This file describes the network interfaces available on your system |
|
|
# and how to activate them. For more information, see interfaces(5). |
|
|
# The loopback network interface |
|
|
auto lo |
|
|
iface lo inet loopback |
|
|
|
|
|
# The primary network interface |
|
|
auto eth0 |
|
|
iface eth0 inet manual |
|
|
|
|
|
source /etc/network/interfaces.d/*.cfg |
|
|
EOF |
|
|
|
|
|
count=1 |
|
|
for i in infra1 infra2 infra3 compute1 swift1 cinder1; do |
|
|
VM_NAME="${i}" |
|
|
sed "s|__COUNT__|$(printf "%02d" ${count})|g" /var/www/pxe/networking/vm-bridges.cfg > /var/www/pxe/networking/${VM_NAME}-bridges.cfg |
|
|
count=$((count + 1)) |
|
|
done |
|
|
|
|
|
# Fix perms if needed |
|
|
find "${tftpboot_dir}" -type d -exec chmod 0755 {} \; |
|
|
find "${tftpboot_dir}" -type f -exec chmod 0644 {} \; |
|
|
############################# ON PXE SERVER ############################# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############################# ON BOOTED VM HOST ############################# |
|
|
# on the mnaio host this is used to setup the libvirt network default configs |
|
|
mkdir -p /opt/mnaio/templates |
|
|
cat > /opt/mnaio/templates/libvirt-network-template.xml <<EOF |
|
|
<network> |
|
|
<name>__NETWORK__</name> |
|
|
<forward mode="bridge"/> |
|
|
<bridge name="__NETWORK__"/> |
|
|
</network> |
|
|
EOF |
|
|
|
|
|
# Remove the original virsh network, we will not need this, then create the integration bridges |
|
|
mkdir -p /opt/mnaio/scripts |
|
|
cat > /opt/mnaio/scripts/libvirt-networking.sh <<EOF |
|
|
if virsh net-list | grep -qw "default"; then |
|
|
virsh net-autostart default --disable |
|
|
virsh net-destroy default |
|
|
fi |
|
|
|
|
|
# Create the libvirt networks used for the Host VMs |
|
|
for network in br-dhcp vm-br-eth1 vm-br-eth2 vm-br-eth3 vm-br-eth4 vm-br-eth5; do |
|
|
if ! virsh net-list | grep -qw "\${network}"; then |
|
|
sed "s/__NETWORK__/\${network}/g" /opt/mnaio/templates/libvirt-network-template.xml > /etc/libvirt/qemu/networks/\${network}.xml |
|
|
virsh net-define --file /etc/libvirt/qemu/networks/\${network}.xml |
|
|
virsh net-create --file /etc/libvirt/qemu/networks/\${network}.xml |
|
|
virsh net-autostart \${network} |
|
|
fi |
|
|
done |
|
|
EOF |
|
|
|
|
|
# Create the volume group vg01 on our space disk |
|
|
vgcreate vg01 /dev/sdc1 |
|
|
|
|
|
# Create a storage pool on our volume group so that VMs can use it |
|
|
virsh pool-create-as vg01 logical |
|
|
virsh pool-dumpxml vg01 > /etc/libvirt/storage/vg01.xml |
|
|
virsh pool-define /etc/libvirt/storage/vg01.xml |
|
|
virsh pool-autostart vg01 |
|
|
############################# ON BOOTED VM HOST ############################# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############################# CREATE VM ############################# |
|
|
count=1 |
|
|
for i in infra1 infra2 infra3 compute1 swift1 cinder1; do |
|
|
VM_NAME="${i}" |
|
|
VM_SIZE=$((${#VM_NAME} * 16)) |
|
|
echo y | lvcreate -n ${VM_NAME} -L ${VM_SIZE}G vg01 |
|
|
sed "s|__name__|${VM_NAME}|g" /opt/mnaio/templates/vm.xml > /etc/libvirt/qemu/${VM_NAME}.xml |
|
|
sed -i "s|__mac__|$(printf "%02d" ${count})|g" /etc/libvirt/qemu/${VM_NAME}.xml |
|
|
virsh define /etc/libvirt/qemu/${VM_NAME}.xml |
|
|
virsh create /etc/libvirt/qemu/${VM_NAME}.xml |
|
|
virsh start ${VM_NAME} || true |
|
|
count=$((count + 1)) |
|
|
done |
|
|
############################# CREATE VM ############################# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############################# DELETE VM ############################# |
|
|
for i in infra1 infra2 infra3 compute1 swift1 cinder1; do |
|
|
VM_NAME="${i}" |
|
|
virsh destroy ${VM_NAME} || true |
|
|
virsh undefine ${VM_NAME} |
|
|
echo y | lvremove /dev/mapper/vg01-${VM_NAME} |
|
|
rm /etc/libvirt/qemu/${VM_NAME}.xml |
|
|
done |
|
|
############################# DELETE VM ############################# |