in cookbooks/aws-parallelcluster-platform/resources/c_states/partial/_c_states_common.rb [20:42]
def append_if_not_present_grub_cmdline(attributes, grub_variable)
grep_grub_cmdline = 'grep "^' + grub_variable + '=" /etc/default/grub'
if shell_out(grep_grub_cmdline).stdout.include? "#{grub_variable}="
Chef::Log.debug("Found #{grub_variable} line")
else
Chef::Log.warn("#{grub_variable} not found - Adding")
shell_out('echo \'' + grub_variable + '=""\' >> /etc/default/grub')
Chef::Log.info("Added #{grub_variable} line")
end
attributes.each do |attribute, properties|
command_out = shell_out(grep_grub_cmdline).stdout
if command_out.include? "#{attribute}"
Chef::Log.warn("Found #{attribute} in #{grub_variable} - #{grub_variable} value: #{command_out}")
else
Chef::Log.info("#{attribute} not found - Adding")
shell_out('sed -i \'s/^\(' + grub_variable + '=".*\)"$/\1 ' + attribute + '=' + properties['value'] + '"/g\' /etc/default/grub')
Chef::Log.info("Added #{attribute}=#{properties['value']} to #{grub_variable}")
end
end
end