voxpupuli / puppet-augeasproviders_grub

Augeas-based grub type and providers
Apache License 2.0
9 stars 33 forks source link

Duplicate `GRUB_CMDLINE` entries if no `kernel_parameter` `bootmode` is specified #71

Open jamesps-ebi opened 2 years ago

jamesps-ebi commented 2 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Using a puppet lookup with either 'deep', or 'hash' merge type (as below)

class profile::hiera::kernel_parameters {
  # Lookup for kernel_parameter resources
  lookup( 'kernel_parameters', Hash[String, Any], 'deep', {} ).each |String $name, Any $options| {
    # Set kernel_parameter resources
    ensure_resource( 'kernel_parameter', $name, $options )
  }
}

Specifying a kernel parameter in hiera without a specific 'bootmode' given, and also specifying some other kernel parameters elsewhere in the hiera hierarchy.

global.yaml - lowest priority

# Configure kernel parameters at boottime
kernel_parameters:
# disable ipv6 by default on every machine
  ipv6.disable:
    ensure: present
    value: '1'

node.yaml - highest priority

kernel_parameters:
  # quiet splash
  quiet:
    ensure: present
    bootmode: default
  splash:
    ensure: present
    bootmode: default

What are you seeing

The above can result in the kernel parameter (ipv6.disable) being duplicated between the GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX sections of /etc/default/grub file, similar to #38

# grep CMDLINE /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet splash"
GRUB_CMDLINE_LINUX="ipv6.disable=1"

What behaviour did you expect instead

Kernel parameters should only appear in one of either GRUB_CMDLINE_LINUX_DEFAULT or GRUB_CMDLINE_LINUX, but not both.

Explicitly specifying a bootmode will cause the kernel parameter to only appear in one of the two GRUB_CMDLINE* sections as expected.

Output log

Any additional information you'd like to impart