delegate_to in loop: only connecting to first host in list

1,145 views
Skip to first unread message

alvl...@gmail.com

unread,
Jan 14, 2016, 3:55:00 PM1/14/16
to Ansible Development
Hi (again!)

Found another unexpected issue with my code.
I'm trying to automate the deployment of an application which consists of some java processes in Linux servers, and then a GUI client running on Windows. So, I'm using a delegated task to clear some cached files in the Windows servers when I change the app version in the backend.

I've simplified the problem I'm seeing into the following play:

---

- hosts: server1.example.com
  tasks
:
   
- win_file: path="c:\\ansible\\test\\" state=absent
      delegate_to
: "{{ item }}"
      with_items
: groups['gui']


"server1.example.com" is a server on which the backend processes run. The "gui" group has two different windows servers, accessed via AD login.

In the logs, I see a connection attempt to the first windows server, and an OK notice for both servers in the GUI group, but I don't see a connection attempt to the second server (and the directory is not removed by the win_file module)

user@server1 ~/ansible $ ansible-playbook test-play.yml -vvv
Using /
home/user/ansible/ansible.cfg as config file
1 plays in test-play.yml

PLAY
***************************************************************************

TASK
[win_file path=c:\ansible\test state=absent] ******************************
task path
: /home/user/ansible/test-play.yml:5
<win_server1.example.com> ESTABLISH WINRM CONNECTION FOR USER: user@AD.EXAMPLE.COM on PORT 5986 TO win_server1.example.com
<win_server1.example.com> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1452798020.43-89194208822402").FullName | Write-Host -Separator '';
<win_server1.example.com> PUT "/tmp/tmptYf5CN" TO "C:\Users\user\AppData\Local\Temp\ansible-tmp-1452798020.43-89194208822402\win_file.ps1"
<win_server1.example.com> EXEC Set-StrictMode -Version Latest [removed powershell code]

<win_server1.example.com> EXEC Set-StrictMode -Version Latest
(New-Item -Type Directory -Path $env:temp -Name "ansible-tmp-1452798023.15-66214194598336").FullName | Write-Host -Separator '';
<win_server1.example.com> PUT "/tmp/tmpENwt43" TO "C:\Users\user\AppData\Local\Temp\ansible-tmp-1452798023.15-66214194598336\win_file.ps1"
<win_server1.example.com> EXEC Set-StrictMode -Version Latest [removed powershell code]

ok
: [server1.example.com -> win_server1.example.com] => (item=win_server1.example.com) => {"changed": false, "invocation": {"module_args": {"path": "c:\\ansible\\test", "state": "absent"}, "module_name": "win_file"}, "item": "win_server1.example.com"}
ok
: [server1.example.com -> win_server2.example.com] => (item=win_server2.example.com) => {"changed": false, "invocation": {"module_args": {"path": "c:\\ansible\\test", "state": "absent"}, "module_name": "win_file"}, "item": "win_server1.example.com"}

PLAY RECAP
*********************************************************************
server1
.example.com : ok=1    changed=0    unreachable=0    failed=0

I'm thinking on several other ways to do what led me to need the above code, but it certainly looks like unexpected behavior.

Regards

Brian Coca

unread,
Jan 14, 2016, 6:09:36 PM1/14/16
to alvl...@gmail.com, Ansible Development
open bug, it seems that delegation uses the connection data of the
first host delegated to
https://github.com/ansible/ansible/issues/13880
> us...@AD.EXAMPLE.COM on PORT 5986 TO win_server1.example.com
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-deve...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Florin Andrei

unread,
Mar 4, 2016, 4:33:54 PM3/4/16
to Ansible Development, alvl...@gmail.com
I just hit this exact same bug with ansible-2.0.1.0. The bug report was submitted for ansible-2.0.0.0. My use case is same as the original report - enabling/disabling backend servers via the haproxy module.

The ticket says: "We believe the above commit should resolve this problem for you. This will also be included in the next major release."

What is the "next major release" that is supposed to fix this bug?
Reply all
Reply to author
Forward
0 new messages