Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-7828

registry : Not idempotent when setting a blank string as registry_value array data

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Duplicate
    • None
    • None
    • None
    • None
    • Hide

      Puppet is idempotent when applying a registry_value resource with an array type and [''] data value.

      Show
      Puppet is idempotent when applying a registry_value resource with an array type and [''] data value.
    • Needs Assessment
    • Needs Assessment

    Description

      Module Version: puppetlabs-registry (v2.0.2)
      Puppet Version: 4.10.12, 6.0.0
      OS Name/Version: Windows Server 2012 R2, Windows Server 2016

      Desired Behavior:

      When a registry_value resource sets a REG_MULTI_SZ key's value data to a blank value (with type => array and data => ['']), Puppet changes the key's value data to an empty REG_MULTI_SZ value if necessary, and otherwise takes no action.

      Actual Behavior:

      Puppet applies the value on every Puppet run, even when the value is equivalent and even when the value is managed by Puppet and has not been changed since the last time Puppet applied the value.

      # test-array.pp
      registry_value {'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => present,
        type   => array,
        data   => [''],
      }
       
      PS C:\Users\Administrator> puppet apply -t ./test-array.pp
      Notice: Compiled catalog for bat7x4sd0in1z3j.delivery.puppetlabs.net in environment production in 0.14 seconds
      Info: Applying configuration version '1537385152'
      Notice: /Stage[main]/Main/Registry_value[HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes]/type: type changed 'string' to 'array'
       
      Notice: Applied catalog in 0.08 seconds
       
      PS C:\Users\Administrator> puppet apply -t ./test-array.pp
      Notice: Compiled catalog for bat7x4sd0in1z3j.delivery.puppetlabs.net in environment production in 0.16 seconds
      Info: Applying configuration version '1537385156'
      Notice: /Stage[main]/Main/Registry_value[HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes]/data: data changed '' to ''
      Notice: Applied catalog in 0.08 seconds
       
      PS C:\Users\Administrator> puppet apply -t ./test-array.pp
      Notice: Compiled catalog for bat7x4sd0in1z3j.delivery.puppetlabs.net in environment production in 0.12 seconds
      Info: Applying configuration version '1537385189'
      Notice: /Stage[main]/Main/Registry_value[HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes]/data: data changed '' to ''
      Notice: Applied catalog in 0.09 seconds
       
      PS C:\Users\Administrator> puppet resource registry_value 'HKLM\SYSTEM\CurrentCo
      ntrolSet\Services\LanManServer\Parameters\NullSessionPipes'
      registry_value { 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters
      \NullSessionPipes':
        ensure => 'present',
        type   => 'array',
      }
      

      Note that on the second and third applications, Puppet continues to change the value (data changed '' to '') as though it cannot equate the key's value to the resource's value. Note also that puppet resource doesn't report a data parameter.

      Puppet's behavior still isn't idempotent if data is omitted from the manifest.

      # test-array-no-data.pp
      registry_value {'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => present,
        type   => array,
      }
       
      PS C:\Users\Administrator> puppet resource registry_value 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes'
      registry_value { 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => 'present',
        type   => 'array',
      }
       
      PS C:\Users\Administrator> puppet apply -t test-array-no-data.pp
      Notice: Compiled catalog for bat7x4sd0in1z3j.delivery.puppetlabs.net in environment production in 0.09 seconds
      Info: Applying configuration version '1537389053'
      Notice: /Stage[main]/Main/Registry_value[HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes]/data: data changed '' to ''
      Notice: Applied catalog in 0.10 seconds
       
      PS C:\Users\Administrator> puppet resource registry_value 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes'
      registry_value { 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => 'present',
        type   => 'array',
      }
      

      Different Behavior in Similar Cases:

      This unexpectedly differs from the behavior when managing a REG_MULTI_SZ (array) value of non-empty strings:

      # test-array-with-non-empty-strings.pp
      registry_value {'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => present,
        type   => array,
        data   => ['foo', 'bar'],
      }
       
      PS C:\Users\Administrator> puppet apply -t test-array-with-values.pp
      Notice: Compiled catalog for bat7x4sd0in1z3j.delivery.puppetlabs.net in environment production in 0.09 seconds
      Info: Applying configuration version '1537387869'
      Notice: /Stage[main]/Main/Registry_value[HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes]/data: data changed '' to 'foo,bar'
      Notice: Applied catalog in 0.10 seconds
       
      PS C:\Users\Administrator> puppet apply -t test-array-with-values.pp
      Notice: Compiled catalog for bat7x4sd0in1z3j.delivery.puppetlabs.net in environment production in 0.09 seconds
      Info: Applying configuration version '1537387873'
      Notice: Applied catalog in 0.08 seconds
       
      PS C:\Users\Administrator> puppet resource registry_value 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes'
      registry_value { 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => 'present',
        data   => ['foo', 'bar'],
        type   => 'array',
      }
      

      This also unexpectedly differs from the behavior when managing a REG_SZ (string) value with an empty string:

      # test-string.pp
      registry_value {'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => present,
        type   => string,
        data   => '',
      }
       
      PS C:\Users\Administrator> puppet apply -t ./test-string.pp
      Notice: Compiled catalog for bat7x4sd0in1z3j.delivery.puppetlabs.net in environment production in 0.15 seconds
      Info: Applying configuration version '1537384983'
      Notice: /Stage[main]/Main/Registry_value[HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes]/type: type changed 'array' to 'string'
       
      Notice: /Stage[main]/Main/Registry_value[HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes]/data: data changed '' to ''
      Notice: Applied catalog in 0.08 seconds
       
      PS C:\Users\Administrator> puppet apply -t ./test-string.pp
      Notice: Compiled catalog for bat7x4sd0in1z3j.delivery.puppetlabs.net in environment production in 0.16 seconds
      Info: Applying configuration version '1537385080'
      Notice: Applied catalog in 0.06 seconds
       
      PS C:\Users\Administrator> puppet resource registry_value 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes'
      registry_value { 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => 'present',
        data   => [''],
        type   => 'string',
      }
      

      In both cases as expected, the value is changed on the initial application, then ignored on subsequent applications when the key value has not changed. Note that the resulting data value for the string type resource is an array containing an empty string.

      When the data is set to an array with no items (data => []), Puppet does not manage the key's value:

      # test-array-empty.pp
      registry_value {'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => present,
        type   => array,
        data   => [],
      }
       
      PS C:\Users\Administrator> puppet apply -t test-array-empty.pp
      Notice: Compiled catalog for bat7x4sd0in1z3j.delivery.puppetlabs.net in environment production in 0.08 seconds
      Info: Applying configuration version '1537388292'
      Notice: Applied catalog in 0.08 seconds
       
      PS C:\Users\Administrator> puppet resource registry_value 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes'
       
      registry_value { 'HKLM\SYSTEM\CurrentControlSet\Services\LanManServer\Parameters\NullSessionPipes':
        ensure => 'present',
        data   => ['foo', 'bar'],
        type   => 'array',
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              garrett.guillotte Garrett Guillotte
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support