Alexandros Kosiaris has submitted this change and it was merged.

Change subject: grub: use augeas to modify the config
......................................................................


grub: use augeas to modify the config

The base::grub class has accumulated a bunch of test/sed/grep execs
which are hard to read and make them do the right thing, especially with
regards to other local settings that the installer may have set.

Add an augeas definition that does everything that we currently do and
has been benchmarked to be actually faster(!). Unfortunately, it looks
like that the lens is broken on systems even as new as Ubuntu trusty and
backporting a newer augeas isn't worth the trouble for now, so keep the
shell stuff and put them behind an $augeasversion conditional.

Change-Id: I889d095a92bdb511f315e2b76af01da7152bfae8
---
M modules/base/manifests/init.pp
1 file changed, 46 insertions(+), 24 deletions(-)

Approvals:
  Alexandros Kosiaris: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/base/manifests/init.pp b/modules/base/manifests/init.pp
index 415d085..6437531 100644
--- a/modules/base/manifests/init.pp
+++ b/modules/base/manifests/init.pp
@@ -1,30 +1,52 @@
 class base::grub {
-    # Disable the 'quiet' kernel command line option so console messages
-    # will be printed.
-    exec { 'grub2 remove quiet':
-        path    => '/bin:/usr/bin',
-        command => "sed -r -i '/^GRUB_CMDLINE_LINUX_DEFAULT/s/quiet( 
splash)?//' /etc/default/grub",
-        onlyif  => "grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=.*quiet( splash)?' 
/etc/default/grub",
-        notify  => Exec['update-grub'],
-    }
+    # The shellvars_list lens is broken with backticks on older versions of
+    # Augeas (< jessie), so keep a compatibility version with test/grep/sed
+    if versioncmp($::augeasversion, '1.3.0') >= 0 {
+        augeas { 'grub2':
+            incl    => '/etc/default/grub',
+            lens    => 'Shellvars_list.lns',
+            changes => [
+                # set terminal; default usually is just serial
+                'set GRUB_TERMINAL/quote \'"\'',
+                'set GRUB_TERMINAL/value[1] console',
+                'set GRUB_TERMINAL/value[2] serial',
+                # removes quiet, splash from default kopts
+                'rm GRUB_CMDLINE_LINUX_DEFAULT/value[. = "quiet"]',
+                'rm GRUB_CMDLINE_LINUX_DEFAULT/value[. = "splash"]',
+                # The CFQ I/O scheduler is rather suboptimal for some of our 
I/O
+                # workloads. Override with deadline. (the installer does this 
too)
+                'set GRUB_CMDLINE_LINUX/value[. = "elevator=deadline"] 
elevator=deadline',
+            ],
+            notify  => Exec['update-grub'],
+        }
+    } else {
+        # Disable the 'quiet' kernel command line option so console messages
+        # will be printed.
+        exec { 'grub2 remove quiet':
+            path    => '/bin:/usr/bin',
+            command => "sed -r -i '/^GRUB_CMDLINE_LINUX_DEFAULT/s/quiet( 
splash)?//' /etc/default/grub",
+            onlyif  => "grep -E -q '^GRUB_CMDLINE_LINUX_DEFAULT=.*quiet( 
splash)?' /etc/default/grub",
+            notify  => Exec['update-grub'],
+        }
 
-    # show the GRUB menu on both console & serial (default is serial)
-    exec { 'grub2 terminal':
-        path    => '/bin:/usr/bin',
-        command => "sed -i '/^GRUB_TERMINAL/s/=.*/=\"console serial\"/' 
/etc/default/grub",
-        unless  => "grep -q '^GRUB_TERMINAL=.*console serial' 
/etc/default/grub",
-        onlyif  => 'test -f /etc/default/grub',
-        notify  => Exec['update-grub'],
-    }
+        # show the GRUB menu on both console & serial (default is serial)
+        exec { 'grub2 terminal':
+            path    => '/bin:/usr/bin',
+            command => "sed -i '/^GRUB_TERMINAL/s/=.*/=\"console serial\"/' 
/etc/default/grub",
+            unless  => "grep -q '^GRUB_TERMINAL=.*console serial' 
/etc/default/grub",
+            onlyif  => 'test -f /etc/default/grub',
+            notify  => Exec['update-grub'],
+        }
 
-    # The CFQ I/O scheduler is rather # suboptimal for some of our I/O
-    # workloads. Override with deadline. (the installer does this too)
-    exec { 'grub2 iosched deadline':
-        path    => "/bin:/usr/bin",
-        command => "sed -i '/^GRUB_CMDLINE_LINUX=/s/\\\"\$/ 
elevator=deadline\\\"/' /etc/default/grub",
-        unless  => "grep -q '^GRUB_CMDLINE_LINUX=.*elevator=deadline' 
/etc/default/grub",
-        onlyif  => 'test -f /etc/default/grub',
-        notify  => Exec['update-grub'];
+        # The CFQ I/O scheduler is rather # suboptimal for some of our I/O
+        # workloads. Override with deadline. (the installer does this too)
+        exec { 'grub2 iosched deadline':
+            path    => "/bin:/usr/bin",
+            command => "sed -i '/^GRUB_CMDLINE_LINUX=/s/\\\"\$/ 
elevator=deadline\\\"/' /etc/default/grub",
+            unless  => "grep -q '^GRUB_CMDLINE_LINUX=.*elevator=deadline' 
/etc/default/grub",
+            onlyif  => 'test -f /etc/default/grub',
+            notify  => Exec['update-grub'];
+        }
     }
 
     exec { 'update-grub':

-- 
To view, visit https://gerrit.wikimedia.org/r/178897
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I889d095a92bdb511f315e2b76af01da7152bfae8
Gerrit-PatchSet: 5
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <fai...@wikimedia.org>
Gerrit-Reviewer: Alexandros Kosiaris <akosia...@wikimedia.org>
Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@wikimedia.org>
Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to