Skip to content

Conversation

reidmv
Copy link

@reidmv reidmv commented Nov 30, 2017

When outputing a value the sysctl utility will print tabs for
whitespace, rather than space characters. Users, however, will commonly
use spaces rather than tabs when specifying their values.

Prior to this commit, the discrepancy between user input and sysctl
output caused idempotency problems when Puppet was enforcing sysctl
settings such as the following:

sysctl { 'kernel.sem':
  ensure  => present,
  value   => '1000 32000 32 512',
}

Puppet would run sysctl -n kernel.sem which would output with tabs:

1000    32000   32      512

It would then compare this value to the user input, which had spaces:

1000 32000 32 512

Finding the two values to be different, Puppet would faithfully run
sysctl to "fix" the out-of-sync setting.

sysctl -w kernel.sem='1000 32000 32 512'

This commit fixes the problem by having Puppet compare the output of
sysctl with a tab-whitespace version of the user input, even if the user
specified spaces.

This logic (whitespace normalization) has also been used to fix the
problem in several other Puppet sysctl modules.

When outputing a value the sysctl utility will print tabs for
whitespace, rather than space characters. Users, however, will commonly
use spaces rather than tabs when specifying their values.

Prior to this commit, the discrepancy between user input and sysctl
output caused idempotency problems when Puppet was enforcing sysctl
settings such as the following:

    sysctl { 'kernel.sem':
      ensure  => present,
      value   => '1000 32000 32 512',
    }

Puppet would run `sysctl -n kernel.sem` which would output with tabs:

    1000    32000   32      512

It would then compare this value to the user input, which had spaces:

    1000 32000 32 512

Finding the two values to be different, Puppet would faithfully run
sysctl to "fix" the out-of-sync setting.

    sysctl -w kernel.sem='1000 32000 32 512'

This commit fixes the problem by having Puppet compare the output of
sysctl with a tab-whitespace version of the user input, even if the user
specified spaces.

This logic (whitespace normalization) has also been used to fix the
problem in several other Puppet sysctl modules.
@reidmv
Copy link
Author

reidmv commented Jan 3, 2018

@thias thoughts?

@bovy89
Copy link

bovy89 commented Jan 3, 2020

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants