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

Query registry via puppet resource

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: registry
    • Labels:
      None
    • Environment:

      Windows Server 2012
      Puppet Enterprise 2016.4.3

    • Template:
    • Acceptance Criteria:
      Hide

      puppet resource [some provider] <some registry path> returns code like the following:

      [some type]

      { "<some registry path>: value => $registryName, type => $type, data => $value, }

      Some keys contain multiple values and data, of course, so that would need to be accommodated, too...

      Show
      puppet resource [some provider] <some registry path> returns code like the following: [some type] { "<some registry path>: value => $registryName, type => $type, data => $value, } Some keys contain multiple values and data, of course, so that would need to be accommodated, too...
    • QA Risk Assessment:
      Needs Assessment

      Description

      I'm working with a Puppet user who is trying to puppetize their Windows and Linux systems.

      With many standard types, it's possible to use puppet resource to interrogate various resources on a known-good system and quickly paste them into a new module.

      This is not possible with the existing puppetlabs-registry module, as puppet resource registry_key <path> or registry_value <path> don't return anything other than whether or not the resource is present.

      It would be a great feature to help windows users get going with Puppet if we had a way to interrogate the registry and have it return puppet code. This avenue is especially appealing if a user has powershell scripts they're looking to puppetize, as powershell and puppet call the same things by different names. For instance, here is what a user must consider when translating between Powershell and Puppet. (There must be an easier way, especially for a new user!):

      Here is a Powershell script to handle Limited User account settings:
      $registryPath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System'
      $registryName = 'EnableLUA' #Note the collision with $name
      $value = '0x00000000'
      $type = 'DWORD'
      New-ItemProperty -Path $registryPath -Name $registryName -Value $value `
      -PropertyType $type -Force | Out-Null

      If we magically had access to the same variables in Puppet, we would have to transmogrify them to work:
      registry::value

      { "Disable_UAC": key => $registryPath, value => $registryName, type => downcase($type), data => $value, }

      The caveats:
      1. the registry Path gets resolved by the underlying windows API, and may look different than what we present (in this case, with a colon)
      2. What powershell (new-item) calls a name, we call a value.
      3. What powershall (new-item) calls a value, we call data.
      4. We have to lowercase the type, but they prefer it upper case
      5. We have to single quote the registry path to avoid backslash issues, windows doesn't
      6. We simplify a few registry types by calling them string and not accepting what Microsoft calls them (e.g. REG_SZ and REG_EXPANDED_SZ are strings, but we force everything to be a string, requiring the human to translate between Microsoft and Puppet when Puppet should be able to do that under the hood.

      (A much better solution would be, rather to translate the powershell script, to copy the path from the script and paste it after puppet resource [something], and copy/paste the result into a manifest... This would save typos, translation errors, time and frustration)

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            paul.anderson Paul Anderson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Zendesk Support