Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
(#605) Populate the PT__installdir environment variable
Browse files Browse the repository at this point in the history
When Bolt run a task, _installdir is set to the directory where the task
files have been copied.  In our case, we build a simiar hierarchy in the
file directory under the task spool directory, so set this environment
variable accordingly.

https://puppet.com/docs/bolt/latest/writing_tasks.html#sharing-task-code
  • Loading branch information
smortex committed Dec 24, 2020
1 parent f1a1158 commit bf0d875
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/mcollective/util/tasks_support.rb
Expand Up @@ -186,6 +186,8 @@ def task_environment(task, task_id, task_caller)
environment["PT_%s" % k] = v.to_s
end

environment["PT__installdir"] = File.join(request_spooldir(task_id), "files")

environment
end

Expand Down
2 changes: 2 additions & 0 deletions spec/unit/mcollective/util/tasks_support_spec.rb
Expand Up @@ -387,9 +387,11 @@ module Util
describe "#task_environment" do
it "should set the environment for both or environment methods" do
["both", "environment"].each do |method|
ts.stubs(:request_spooldir).returns(File.join(cache, "test_1"))
task_run_request_fixture["input_method"] = method
task_run_request_fixture["input"] = '{"directory": "/tmp", "bool":true}'
expect(ts.task_environment(task_run_request_fixture, "test_id", "caller=spec.mcollective")).to eq(
"PT__installdir" => File.join(cache, "test_1", "files"),
"PT_directory" => "/tmp",
"PT_bool" => "true",
"_task" => "choria::ls",
Expand Down

0 comments on commit bf0d875

Please sign in to comment.