How to update grub with puppet?

Posted by Tombart on Server Fault See other posts from Server Fault or by Tombart
Published on 2013-11-11T09:29:30Z Indexed on 2013/11/11 9:59 UTC
Read the original article Hit count: 440

I would like to change a line in /etc/default/grub with puppet to this:

GRUB_CMDLINE_LINUX="cgroup_enable=memory"

I've tried to used augeas which seems to do this magic:

   exec { "update_grub":
    command => "update-grub",
    refreshonly => true,
   }

  augeas { "grub-serial":
    context => "/files/etc/default/grub",
    changes => [
      "set /files/etc/default/grub/GRUB_CMDLINE_LINUX[last()] cgroup_enable=memory",
    ],
    notify => Exec['update_grub'],
  }

It seems to work, but the result string is not in quotes and also I want to make sure that any other values will be separated by space.

GRUB_CMDLINE_LINUX=cgroup_enable=memory

Is there some mechanism how to append values and escape the whole thing?

GRUB_CMDLINE_LINUX="quiet splash cgroup_enable=memory"

© Server Fault or respective owner

Related posts about puppet

Related posts about configuration-management