Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-10964

unable to use package task to install gems with puppet_gem provider on Windows

    XMLWordPrintable

Details

    • Night's Watch
    • 3
    • NW - 2021-03-31, NW - 2021-04-14
    • Needs Assessment
    • Bug Fix
    • Hide
      When puppet is used as a library, `environment.bat` is not sourced and this leads to `PUPPET_DIR` to not be set. Because `puppet_gem` is relying on that to build the `gem.bat` path, it will end-up using a non-existing path, making this provider not suitable.
      Updated the puppet_gem provider to use `Gem.default_bindir` to determine the location of the executables. To avoid accidental usage of `puppet_gem` provider with system ruby, a confine to the existence of `aio_agent_version` fact has been added.
      Show
      When puppet is used as a library, `environment.bat` is not sourced and this leads to `PUPPET_DIR` to not be set. Because `puppet_gem` is relying on that to build the `gem.bat` path, it will end-up using a non-existing path, making this provider not suitable. Updated the puppet_gem provider to use `Gem.default_bindir` to determine the location of the executables. To avoid accidental usage of `puppet_gem` provider with system ruby, a confine to the existence of `aio_agent_version` fact has been added.
    • Needs Assessment

    Description

      Puppet Version: 7.0.0 - 7.5.0
      Puppet Server Version: PE 2021
      OS Name/Version: Windows agents

      After the changes done in PUP-10677, the puppet_gem provider is no longer functional on Windows if the PUPPET_DIR environment variable is not present. The variable is set in environment.bat, which we source when executing puppet.bat and the puppet service.
      However, if Puppet is used without envionment.bat, or as a library in a ruby file, the variables may not be present. See https://github.com/puppetlabs/puppetlabs-package/blob/main/tasks/init.rb for an example.

      Desired Behavior:

      Running the package task with the following parameters in PE passes:

      Task parameters:
      action: install
      name: pry
      provider: puppet_gem

      Actual Behavior:

      Running the task fails with the following:

      Error: Provider puppet_gem package command is not functional on this host
       
      {
        "status" : "failure"
      }
      

      Note that the package task has to be executed through PE/Orchestrator in order to be able to specify the provider parameter. When run on open source installations the task defaults to the powershell implementation which hardcodes choco and does not support setting a custom provider.

      Suggestion: Gem.default_bindir provides the path to gem.bat, but we don't have the certainty that puppet is being run with the system ruby or the vendored ruby.

      Attachments

        Issue Links

          Activity

            People

              gheorghe.popescu Gheorghe Popescu
              gabriel.nagy Gabriel Nagy
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support