Skip to content

Commit 345a909

Browse files
authored
Merge pull request #22264 from Fryguy/fix_ruby3_issue_in_ansible_runner
2 parents 131a0af + 8ad256d commit 345a909

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

lib/ansible/runner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def run_via_cli(hosts, credentials, env_vars, extra_vars, tags: nil, ansible_run
195195

196196
validate_params!(env_vars, extra_vars, tags, ansible_runner_method, playbook_or_role_args)
197197

198-
base_dir = Pathname.new(Dir.mktmpdir("ansible-runner"))
198+
base_dir = Pathname.new(Dir.mktmpdir("ansible-runner")).realpath
199199
debug = verbosity.to_i >= 5 || env_vars["ANSIBLE_KEEP_REMOTE_FILES"]
200200

201201
cred_command_line, cred_env_vars, cred_extra_vars = credentials_info(credentials, base_dir)

lib/ansible/runner/response_async.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ def dump
5454

5555
# Creates the Ansible::Runner::ResponseAsync object from hash data
5656
#
57-
# @param [Hash] Dumped Ansible::Runner::ResponseAsync object
57+
# @param hash [Hash] Dumped Ansible::Runner::ResponseAsync object
5858
# @return [Ansible::Runner::ResponseAsync] Ansible::Runner::ResponseAsync Object created from hash data
59-
def self.load(kwargs)
60-
new(kwargs)
59+
def self.load(hash)
60+
# Dump dumps a hash and load accepts a hash, so we must expand the hash to kwargs as new expects kwargs
61+
new(**hash)
6162
end
6263
end
6364
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
RSpec.describe Ansible::Runner::ResponseAsync do
2+
subject { described_class.new(:base_dir => "/path/to/results") }
3+
4+
it "#dump" do
5+
expect(subject.dump).to eq(
6+
:base_dir => "/path/to/results",
7+
:debug => false,
8+
:ident => "result"
9+
)
10+
end
11+
12+
it ".load" do
13+
response = described_class.load(subject.dump)
14+
15+
expect(response).to be_a(described_class)
16+
expect(response.base_dir).to eq("/path/to/results")
17+
end
18+
end

0 commit comments

Comments
 (0)