Remote execution ansible job over several hosts => erb host.shortname var equal for all hosts!

Hello,
Running one Ansible job template over two (or more) hosts (host1,host2) shows extrange (and erroneus) behaivour.

The code:

- name: “Create de bloqueo que hace <%=@host.shortname%>”
  hosts: all
  gather_facts: False

  vars:
    hostname_: '<%=@host.shortname%>'

  tasks:
    - debug:     
           msg: " El hostname es: {{hostname_}} "

First job runned (alphabetical order), host1, runs ok. Second job runs whith strange beh.
Target job details for host1
OUTPUT: PLAY [Create de bloqueo que hace host1] ***
Rendered job template (seeing with Toogle command buttom):
- name: “Create de bloqueo que hace host1”
hosts: all

Target job details for host2
OUTPUT: PLAY [Create de bloqueo que hace host1] ***
Rendered job template (seeing with Toogle command buttom):
- name: “Create de bloqueo que hace host2”
hosts: all

Expected outcome:
Target job details for host2
OUTPUT: PLAY [Create de bloqueo que hace host2] ***
Rendered job templated (seein with Toogle command buttom):
- name: “Create de bloqueo que hace host2”
hosts: all

Updating to 1.24.2 not resolve the problem.

The execution creates only one dir called:
/tmp/d20200131-29238-1eoj1i
and one file artifacts/a3edf9e1-6456-4e83-aec1-f8d7a65f29c6/stdout

PLAY [##################################### Mensaje debug de host1] *******

TASK [debug] *******************************************************************
ok: [host2] => {
“msg”: " El hostname es: host1"
}
ok: [host1] => {
“msg”: " El hostname es: host1"
}

PLAY RECAP *********************************************************************
host1 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
host2 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

It’s like foreman executes only one job template over the the hosts and not one job template over each host.

Please help!
When I was in 1.21 version all runned ok.

I’m seeing at dynflow_executor.output, I’m not sure if it can be relevant

E, [2020-01-31T17:27:34.989267 #29391] ERROR -- /parallel-executor-core: no     manager for Dynflow::Director::Event[request_id: 77ad22ff-c5a6-49ac-b69b-797e7836b61c-620, execution_plan_id: 6d74fc83-c77a-47dc-a3ae-56e734465276, step_id: 2, event: Actions::Middleware::WatchDelegatedProxySubTasks::CheckOnProxyActions, result: #<Concurrent::Promises::ResolvableFuture:0x0000000016be7588 pending>] (Dynflow::Error)
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.2/lib/dynflow/director.rb:167:in `handle_event'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.2/lib/dynflow/executors/abstract/core.rb:35:in `handle_event'
[ concurrent-ruby ]
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.2/lib/dynflow/executors/abstract/core.rb:113:in `on_message'
[ concurrent-ruby ]
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.2/lib/dynflow/executors/parallel.rb:42:in `delayed_event'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.2/lib/dynflow/clock.rb:36:in `apply'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.2/lib/dynflow/clock.rb:75:in `run_ready_timers'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.2/lib/dynflow/clock.rb:57:in `tick'
[ concurrent-ruby ]
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.2/lib/dynflow/clock.rb:96:in `block in sleep_to'
[ concurrent-ruby ]

Ok, I find the problem and a workaround. Change at settings:
foreman_tasks_proxy_batch_size => from 100 to 1
Disable foreman_tasks_proxy_batch_trigger its not solution for me because generate authentication errores from Ansible with remote hosts (Error initializing command: Net::SSH::AuthenticationFailed - Authentication failed for user. Bug?).

Explanation:
At 1.21 ansible job templates was invocated from ansible-playbook. One command (invocation) by one host.
At 1.24 ansible is invocate from ansible-runner. One command (invocation) for all hosts. The play constructed for that invocation (/tmp/xxxxxx/project/playbook.yml) is rendered with the erb vars from the first host in the execution list.
So YOU HAVE A PROBLEM if you want to use ERB parameters as host.shortname.
Putting foreman_tasks_proxy_batch_size to 1 resolve the problems and emulate the same manner like foreman-playbook, one host one invocation. you the same work

Another and best solution: dont use specific host vars from foreman direct (at erb code).
Foreman pass tha vars as hostvars to ansible so you can use them “inside” ansible.
Some changes in your code to use the good things of ansible-runner (one ansible execution for all your selected hosts, which its a good thing because bring to foreman ansible remote execution the same form of do things as directly with ansible).

cc @aruzicka, is this resolved with Bug #28095: Concurrency control doesn't work when batch planning is enabled - foreman-tasks - Foreman as well?

Disable foreman_tasks_proxy_batch_trigger its not solution for me because generate authentication errores from Ansible with remote hosts (Error initializing command: Net::SSH::AuthenticationFailed - Authentication failed for user. Bug?).

We’re tracking it as Bug #28612: Ansible runs fail when proxy batch triggering is disabled - Ansible - Foreman, the PR should be ready