collection of ansible roles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 lines
1.4 KiB

#!/bin/bash
DEBIAN_INTERFACES_CONFIG=/etc/network/interfaces
add_rfc3442_hook() {
cat << EOF > /etc/initramfs-tools/hooks/add-rfc3442-dhclient-hook
#!/bin/sh
PREREQ=""
prereqs()
{
echo "\$PREREQ"
}
case \$1 in
prereqs)
prereqs
exit 0
;;
esac
if [ ! -x /sbin/dhclient ]; then
exit 0
fi
. /usr/share/initramfs-tools/scripts/functions
. /usr/share/initramfs-tools/hook-functions
mkdir -p \$DESTDIR/etc/dhcp/dhclient-exit-hooks.d/
cp -a /etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes \$DESTDIR/etc/dhcp/dhclient-exit-hooks.d/
EOF
chmod +x /etc/initramfs-tools/hooks/add-rfc3442-dhclient-hook
}
# Install hook
add_rfc3442_hook
# Copy SSH keys for dropbear
mkdir -p /etc/dropbear-initramfs
cp -a /root/.ssh/authorized_keys /etc/dropbear-initramfs/authorized_keys
# override initramfs interface which is used for dhcp
{% if autoinstall_initramfs_override_interface %}
echo "DEVICE={{ autoinstall_initramfs_interface }}" >> /etc/initramfs-tools/initramfs.conf
{% endif %}
# Update system
apt-get update >/dev/null
apt-get -y install cryptsetup-initramfs dropbear-initramfs
{% for interface in ansible_interfaces %}
{% if "ens" in interface and interface != "ens3" and ansible_distribution|lower == "debian" %}
echo "" >> $DEBIAN_INTERFACES_CONFIG
echo "auto {{ interface }}" >> $DEBIAN_INTERFACES_CONFIG
echo "iface {{ interface }} inet dhcp" >> $DEBIAN_INTERFACES_CONFIG
{% endif %}
{% endfor %}