Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PE-31696) Require bolt gem before running local tasks #99

Closed
wants to merge 2 commits into from

Conversation

lucywyman
Copy link
Contributor

@lucywyman lucywyman commented Oct 11, 2021

In PE we use the Ruby interpreter shipped with the Puppet Agent to run the
ace server. The ace server is responsible for executing remote tasks.
Remote tasks will often use the puppet library, and run in ACE using the
local transport. Now that puppet has moved to using require_relative
there is a bug where require 'puppet' in the task will load Puppet
from the Ruby vendor path instead of the Puppet gem. The vendor Puppet
will then try to autoload gems from the Gem path including Puppet,
causing a UniqueFile error when the same file is loaded from different
locations.

This updates ACE to run -r bolt before executing tasks on localhost,
which will add Bolt and it's dependencies to the $LOAD_PATH including
Puppet, so that the Gem puppet is prefered over the vendor Puppet.

@lucywyman
Copy link
Contributor Author

Supersedes #96

@lucywyman lucywyman marked this pull request as ready for review October 11, 2021 17:11
@lucywyman lucywyman requested a review from a team as a code owner October 11, 2021 17:11
lib/ace/transport_app.rb Outdated Show resolved Hide resolved
@lucywyman lucywyman force-pushed the hack-puppet-7 branch 2 times, most recently from 5c15fb1 to 9545835 Compare October 14, 2021 16:53
@lucywyman lucywyman force-pushed the hack-puppet-7 branch 2 times, most recently from 9a941ee to 8ab52f1 Compare October 22, 2021 23:06
@lucywyman lucywyman changed the title (hack) Unset GEM_PATH and GEM_HOME when running local tasks (PE-31696) Require bolt gem before running local tasks Oct 22, 2021
In PE we use the Ruby interpreter shipped with the Puppet Agent to run the
ace server. The ace server is responsible for executing remote tasks.
Remote tasks will often use the puppet library, and run in ACE using the
local transport. Now that puppet has moved to using require_relative
there is a bug where `require 'puppet'` in the task will load Puppet
from the Ruby vendor path instead of the Puppet gem. The vendor Puppet
will then try to autoload gems from the Gem path including Puppet,
causing a `UniqueFile` error when the same file is loaded from different
locations.

This updates ACE to run `-r bolt` before executing tasks on localhost,
which will add Bolt and it's dependencies to the `$LOAD_PATH` including
Puppet, so that the Gem puppet is prefered over the vendor Puppet.
target_data = {
'name' => body['target']['host'] || body['target']['name'] || 'remote',
'config' => {
'transport' => 'remote',
'remote' => body['target']
}
}
target = [Bolt::Target.from_hash(target_data, inventory)]
target = [Bolt::Target.from_hash(target_data, local_target.inventory)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
target = [Bolt::Target.from_hash(target_data, local_target.inventory)]
target = [Bolt::Target.from_hash(target_data, inventory)]

local_target.inventory should be equivalent to inventory, no?

@lucywyman lucywyman closed this Oct 27, 2021
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.

3 participants