From: Andrew Schoen Date: Mon, 13 Apr 2015 15:36:24 +0000 (-0500) Subject: Enable kernel logging on ubuntu using a script. X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=17292fe9ddcf09615bd9b9469a3e0506201e681a;p=ceph-cm-ansible.git Enable kernel logging on ubuntu using a script. This was ported directly from chef as-is. We might want to come back later and convert this from a script into something else. Signed-off-by: Andrew Schoen --- diff --git a/roles/testnode/files/scripts/kernel_logging.sh b/roles/testnode/files/scripts/kernel_logging.sh new file mode 100644 index 00000000..871f9489 --- /dev/null +++ b/roles/testnode/files/scripts/kernel_logging.sh @@ -0,0 +1,74 @@ +#!/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=tty0 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=tty0 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=tty0 console=ttyS[012],115200.*' $f; then sed 's/^GRUB_CMDLINE_LINUX="\(.*\)"$/GRUB_CMDLINE_LINUX="\1 console=tty0 console=ttyS0,115200"/' <$f >$f.chef; fi +else +if ! grep -q '^GRUB_CMDLINE_LINUX=.*".* console=tty0 console=ttyS[01],115200.*' $f; then sed 's/^GRUB_CMDLINE_LINUX="\(.*\)"$/GRUB_CMDLINE_LINUX="\1 console=tty0 console=ttyS1,115200"/' <$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=tty0;"pci=realloc=off console=tty0;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.yml b/roles/testnode/tasks/setup-ubuntu.yml index 4bd2dcc1..36adf6e1 100644 --- a/roles/testnode/tasks/setup-ubuntu.yml +++ b/roles/testnode/tasks/setup-ubuntu.yml @@ -60,3 +60,11 @@ # the user to the specified group or groups. groups: fuse,kvm,disk append: yes + +- name: Enable kernel logging to console. + script: scripts/kernel_logging.sh creates=/kernel-logging-setup + register: kernel_logging + +- name: Update grub + command: update-grub + when: kernel_logging|changed