in DevOps

Augeas made my grub.conf too quiet!

A reader contacted me after working through the examples in my last previous post on Augeas. He was having a difficult time figuring out how to add a valueless key back into the kernel command line. This was the opposite of what I was doing with quiet and rhgb

Many thanks. I have been pounding my brain trying to come up with changes => 'setm title[*]/kernel audit 1', for my grub.conf maintenance.

Now my question:

class grub::no_rhgb {
    # disable rhgb and quiet, so we get verbose booting of the kernel.
    augeas { 'grub.conf/no_rhgb':
        incl    => '/boot/grub/grub.conf',
        lens    => 'grub.lns',
        changes => [
            'rm  title[*]/kernel/rhgb',
            'rm  title[*]/kernel/quiet',
        ],
    }
}

How would you reverse this ? (for other kernel binary flags)
“set” does not like a wild-card
“setm” wants a third arg and that makes “quiet=”

In that case, what you’re actually doing is creating an empty node in the tree. You want to use the touch command instead.

  touch title[*]/kernel/quiet

This should do what you want. I’ve included an example of this below using augtool so you can see what I’m talking about. augtool works a little differently than the augeas provider in puppet. With this tool, you need to specify the full path to the element you’re editing. Let’s add quiet back into the kernel command line.

First, I’ll look at all the available kernels in grub.conf.

augtool> ls /files/etc/grub.conf/title[*]
root = (hd0,0)
kernel/ = /vmlinuz-2.6.32-431.11.2.el6.x86_64
initrd = /initramfs-2.6.32-431.11.2.el6.x86_64.img

According to this, there’s only one. But, for the sake of discussion, I’ll pretend there are multiple boot options defined with a kernel field.

I need to see what is in the existing boot option, so I want to list out the contents of the kernel node in the tree.

augtool> ls /files/etc/grub.conf/title[*]/kernel
ro = (none)
root = /dev/mapper/rootvg-root_lv
rd_NO_LUKS = (none)
rd_LVM_LV[1] = rootvg/swap_lv
LANG = en_US.UTF-8
rd_LVM_LV[2] = rootvg/root_lv
KEYTABLE = us
console = hvc0
rd_NO_MD = (none)
SYSFONT = latarcyrheb-sun16
crashkernel = auto
rd_NO_DM = (none)
printk.time = 1
augtool>

As you can see, the current kernel command line is missing the quiet option. To add it back, I want to touch the node. This creates it in the tree but doesn’t give it a value.

augtool> touch /files/etc/grub.conf/title[*]/kernel/quiet
augtool>

Now, I want to look at the kernel command line again to see if it was added.

augtool> ls /files/etc/grub.conf/title[*]/kernel
ro = (none)
root = /dev/mapper/rootvg-root_lv
rd_NO_LUKS = (none)
rd_LVM_LV[1] = rootvg/swap_lv
LANG = en_US.UTF-8
rd_LVM_LV[2] = rootvg/root_lv
KEYTABLE = us
console = hvc0
rd_NO_MD = (none)
SYSFONT = latarcyrheb-sun16
crashkernel = auto
rd_NO_DM = (none)
printk.time = 1
quiet = (none)
augtool>

And there you have it. Using touch, I have added back an entry onto the command line that doesn’t have a value. This wasn’t obvious to me when I first began working with augeas, but now that I know about it, it seems obvious.

Hope that helps!

augeasproviders followup

One aside that might be beneficial for other readers: I ran across a new-to-me module for puppet called augeasproviders. It appears to be managed by the same team that created augeas. The github for this project shows a quiet few examples of what they have done to make this process easier for people by providing some puppet-specific add-on resources and puppet providers that wrap up some of the common augeas editing tasks in puppet, including grub.conf. Definitely worth checking out if you’re having to interact with augeas infrequently or if you don’t want to put a lot of time into learning a new syntax.

Travis Campbell
Staff Systems Engineer at ghostar
Travis Campbell is a seasoned Linux Systems Engineer with nearly two decades of experience, ranging from dozens to tens of thousands of systems in the semiconductor industry, higher education, and high volume sites on the web. His current focus is on High Performance Computing, Big Data environments, and large scale web architectures.