]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Enable kernel logging on ubuntu using a script.
authorAndrew Schoen <aschoen@redhat.com>
Mon, 13 Apr 2015 15:36:24 +0000 (10:36 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Thu, 16 Apr 2015 21:31:32 +0000 (16:31 -0500)
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 <aschoen@redhat.com>
roles/testnode/files/scripts/kernel_logging.sh [new file with mode: 0644]
roles/testnode/tasks/setup-ubuntu.yml

diff --git a/roles/testnode/files/scripts/kernel_logging.sh b/roles/testnode/files/scripts/kernel_logging.sh
new file mode 100644 (file)
index 0000000..871f948
--- /dev/null
@@ -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
index 4bd2dcc19593c20f51e982762ebdcc288af60746..36adf6e15d979e712dbd168eee987652f625d98f 100644 (file)
     # 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