Jira (PUP-10964) unable to use package task to install gems with puppet_gem provider on Windows

26 views
Skip to first unread message

Gabriel Nagy (Jira)

unread,
Mar 12, 2021, 7:06:03 AM3/12/21
to puppe...@googlegroups.com
Gabriel Nagy created an issue
 
Puppet / Bug PUP-10964
unable to use package task to install gems with puppet_gem provider on Windows
Issue Type: Bug Bug
Affects Versions: PUP 7.5.0
Assignee: Unassigned
Created: 2021/03/12 4:05 AM
Fix Versions: PUP 7.6.0
Labels: jira_escalated
Priority: Normal Normal
Reporter: Gabriel Nagy

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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Mihai Buzgau (Jira)

unread,
Mar 17, 2021, 7:19:03 AM3/17/21
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 17, 2021, 7:19:03 AM3/17/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Mar 18, 2021, 3:51:04 AM3/18/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Mar 18, 2021, 5:12:04 AM3/18/21
to puppe...@googlegroups.com
Gabriel Nagy commented on Bug PUP-10964
 
Re: unable to use package task to install gems with puppet_gem provider on Windows

We can also extend the existing ruby fact to include more keys from RbConfig:

irb(main):006:0> RbConfig::CONFIG['bindir']
=> "/opt/puppetlabs/puppet/bin"

Currently it only includes sitelibdir, platform and version: https://github.com/puppetlabs/facter/blob/main/lib/facter/resolvers/ruby.rb#L15

We can also confine the provider to the existence of the aio_agent_version fact to ensure it's not suitable for non-AIO installations.

Mihai Buzgau (Jira)

unread,
Mar 31, 2021, 5:31:04 AM3/31/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Apr 6, 2021, 12:12:03 PM4/6/21
to puppe...@googlegroups.com
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Gheorghe Popescu (Jira)

unread,
Apr 7, 2021, 1:42:03 AM4/7/21
to puppe...@googlegroups.com

Gheorghe Popescu (Jira)

unread,
Apr 7, 2021, 1:42:04 AM4/7/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Change By: Gheorghe Popescu
Release Notes Summary: 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.

Claire Cadman (Jira)

unread,
Apr 12, 2021, 11:30:03 AM4/12/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages