From 54e25bebda4d2d7ec560a9ab42a1e90cb5d9e717 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Fri, 9 Mar 2018 14:58:08 -0500 Subject: [PATCH] cobbler: Write exact /etc/default/grub This fixes console output during Xenial and later. Prior to this, the Plymouth boot screen would get loaded and "[37mUbuntu 16.04[-1;-1f[33m. [37m. [37m. [37m." would get repeated to the console until the login prompt shows up. Writing our own file instead of finding and replacing variables makes sure the settings are exactly what we want. This snippet is only used on Debian-based distros. The default Cobbler snippet is used on RPM-based distros. Signed-off-by: David Galloway --- .../cephlab_post_install_kernel_options | 24 +++--- roles/testnode/README.rst | 3 - .../testnode/files/scripts/kernel_logging.sh | 75 ------------------- .../tasks/setup-ubuntu-non-aarch64.yml | 12 --- 4 files changed, 15 insertions(+), 99 deletions(-) delete mode 100644 roles/testnode/files/scripts/kernel_logging.sh diff --git a/roles/cobbler/templates/snippets/cephlab_post_install_kernel_options b/roles/cobbler/templates/snippets/cephlab_post_install_kernel_options index 8479cc9..338b856 100644 --- a/roles/cobbler/templates/snippets/cephlab_post_install_kernel_options +++ b/roles/cobbler/templates/snippets/cephlab_post_install_kernel_options @@ -1,12 +1,18 @@ ## {{ ansible_managed }} -#if $getVar('kernel_options_post','') != '' # Start post install kernel options update -if [ -f /etc/default/grub ]; then - # set GRUB_CMDLINE_LINUX - TMP_GRUB=\$(gawk 'match(\$0,/^GRUB_CMDLINE_LINUX="([^"]+)"/,a) {printf("%s\n",a[1])}' /etc/default/grub) - sed -i '/^GRUB_CMDLINE_LINUX=/d' /etc/default/grub - echo "GRUB_CMDLINE_LINUX=\"\$TMP_GRUB $kernel_options_post\"" >> /etc/default/grub - grub-mkconfig -o /boot/grub/grub.cfg -fi -# End post install kernel options update +cat > /etc/default/grub <<-EOF + # {{ ansible_managed }} + GRUB_DEFAULT=0 + GRUB_TIMEOUT=5 + GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` + GRUB_CMDLINE_LINUX_DEFAULT="" + GRUB_TERMINAL="console" + GRUB_SERIAL_COMMAND="console --unit=1 --speed=115200 --stop=1" +#if $getVar('kernel_options_post','') != '' + GRUB_CMDLINE_LINUX="$kernel_options_post" +#else + GRUB_CMDLINE_LINUX="console=tty0" #end if + EOF +update-grub +# End post install kernel options update diff --git a/roles/testnode/README.rst b/roles/testnode/README.rst index 468307e..1c5928a 100644 --- a/roles/testnode/README.rst +++ b/roles/testnode/README.rst @@ -245,9 +245,6 @@ gpg-keys hostname Check and set proper fqdn. See, ``roles/testnode/tasks/set_hostname.yml``. -kernel_logging - Runs a script that enabled kernel logging to the console on ubuntu. - lvm Configures logical volumes if dicts are defined in the secrets repo. diff --git a/roles/testnode/files/scripts/kernel_logging.sh b/roles/testnode/files/scripts/kernel_logging.sh deleted file mode 100644 index 98a1b0d..0000000 --- a/roles/testnode/files/scripts/kernel_logging.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# {{ ansible_managed }} - -set -e -f=/etc/default/grub -#Mira are ttyS2 -miracheck=$(uname -n | grep -ic mira || true) -typicacheck=$(uname -n | grep -ic typica || true) -# if it has a setting, make sure it's to ttyS1 -if [ $miracheck -gt 0 ] -then -if grep -q '^GRUB_CMDLINE_LINUX=.*".*console=tty0 console=ttyS[012],115200' $f; then sed 's/console=ttyS[012]/console=ttyS2/' <$f >$f.chef; fi -else -if [ $typicacheck -gt 0 ] -then -if grep -q '^GRUB_CMDLINE_LINUX=.*".*console=ttyS[012],115200' $f; then sed 's/console=ttyS[012]/console=ttyS0/' <$f >$f.chef; fi -else -if grep -q '^GRUB_CMDLINE_LINUX=.*".*console=ttyS[01],115200' $f; then sed 's/console=ttyS[01]/console=ttyS1/' <$f >$f.chef; fi -fi -fi - -# if it has no setting, add it -if [ $miracheck -gt 0 ] -then -if ! grep -q '^GRUB_CMDLINE_LINUX=.*".* console=tty0 console=ttyS[012],115200.*' $f; then sed 's/^GRUB_CMDLINE_LINUX="\(.*\)"$/GRUB_CMDLINE_LINUX="\1 console=tty0 console=ttyS2,115200"/' <$f >$f.chef; fi -else -if [ $typicacheck -gt 0 ] -then -if ! grep -q '^GRUB_CMDLINE_LINUX=.*".*console=ttyS[012],115200.*' $f; then sed 's/^GRUB_CMDLINE_LINUX="\(.*\)"$/GRUB_CMDLINE_LINUX="\1 console=ttyS0,115200"/' <$f >$f.chef; fi -else -if ! grep -q '^GRUB_CMDLINE_LINUX=.*".* console=ttyS[01],115200.*' $f; then sed 's/^GRUB_CMDLINE_LINUX="\(.*\)"$/GRUB_CMDLINE_LINUX="\1 console=ttyS1,115200"/' <$f >$f.chef; fi -if grep -q '^GRUB_CMDLINE_LINUX=.*".*console=ttyS[01],115200' $f; then sed 's/console=ttyS[01]/console=ttyS1/' <$f >$f.chef; fi -fi -fi - - -# if we did something; move it into place. update-grub done below. -if [ -f $f.chef ] ; then mv $f.chef $f; fi - -#Remove quiet kernel output: -sed -i 's/quiet//g' $f -serialcheck=$(grep -ic serial $f || true) -if [ $serialcheck -eq 0 ] -then -if [ $miracheck -gt 0 ] -then -echo "" >> $f -echo "GRUB_TERMINAL=serial" >> $f -echo "GRUB_SERIAL_COMMAND=\"serial --unit=2 --speed=115200 --stop=1\"" >> $f -else -if [ $typicacheck -gt 0 ] -then -echo "" >> $f -echo "GRUB_TERMINAL=serial" >> $f -echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200 --stop=1\"" >> $f -else -echo "" >> $f -echo "GRUB_TERMINAL=serial" >> $f -echo "GRUB_SERIAL_COMMAND=\"serial --unit=1 --speed=115200 --stop=1\"" >> $f -fi -fi -fi - -#Don't hide grub menu - -sed -i 's/^GRUB_HIDDEN_TIMEOUT.*//g' $f - -#No PCI reallocation (breaks 10 gig on burnupi) -sed -i 's;" console=ttyS;"pci=realloc=off console=ttyS;g' $f - -#set verbose kernel output via dmesg: -if ! grep -q dmesg /etc/rc.local; then sed -i 's/^exit 0/dmesg -n 7\nexit 0/g' /etc/rc.local; fi - -# touch this file so we know not to run this script again -touch /kernel-logging-setup diff --git a/roles/testnode/tasks/setup-ubuntu-non-aarch64.yml b/roles/testnode/tasks/setup-ubuntu-non-aarch64.yml index 836669d..fdf51f9 100644 --- a/roles/testnode/tasks/setup-ubuntu-non-aarch64.yml +++ b/roles/testnode/tasks/setup-ubuntu-non-aarch64.yml @@ -17,18 +17,6 @@ group: root mode: 0755 -- name: Enable kernel logging to console. - script: scripts/kernel_logging.sh creates=/kernel-logging-setup - register: kernel_logging - tags: - - kernel_logging - -- name: Update grub - command: update-grub - when: kernel_logging|changed - tags: - - kernel_logging - - name: Enable kernel modules to load at boot time. template: src: modules -- 2.39.5