Closed nautics889 closed 1 year ago
Passing a full file path (like /tmp/some_file.yml
) as the extravars
argument worked for me.
But the implementation of this is super weird. Instead of directly passing that string as a process argument, the file path is written to env/extravars
(now containing a plain string instead of YAML data) and then read from there. I also tried using the cmdline
argument, but even there, a env/cmdline
file is created.
There seems to be no way to not do a filesystem round trip, which is super annoying, because it seems inefficient and could cause race conditions when trying to run multiple Ansible processes in parallel.
Futhermore, according to docstring of .run() method the argument extravars can be dict and only dict instance.
Yep, docs are wrong here. Got confused by this as well.
@muety thank you and apologies for late reply.
The option with full path worked for me as well.
I guess the issue can be closed for now, perharps it should be mentioned somewhen if somebody wants to refactor current implemention of handling of extravars.
Ansible provides feature when extra variables can be loaded from file. So, let's suppose, i have
some_file.yaml
and i want to display variable from the file usingshell
module. That's going to be something like this:How can i make exactly the same in a context of Python?
I tried to make something like below passing
"@some_file.yaml"
as anextravars
, but it's failing:According to the log, runner tries to read data from some temporary file:
/tmp/tmp7j7lw95h/env/extravars
. Is this correct behavior?Futhermore, according to docstring of
.run()
method the argumentextravars
can bedict
and onlydict
instance.I've found there was a similar issue (https://github.com/ansible/ansible-runner/issues/303) and related PR was merged long time ago, but i'm still not following how would i set extra variables to be read from a file. I've also tried to use full path like
extravars="/full/path/to/some_file.yaml"
— same.WAIDW?