Issue using delegate_to and with_items

79 views
Skip to first unread message

Julien Tognazzi

unread,
May 24, 2016, 10:34:15 AM5/24/16
to Ansible Project
Hi,

Is the use of delegate_to with with_items supposed to work ?

$ ansible --version
ansible
2.0.1.0
  config file
= /vagrant/sysadmin/ansible/atlassian/ansible.cfg
  configured
module search path = /usr/local/share/ansible_modules/


Using the following playbook show that it always delegate to the first item, is it a bug ?

---
- hosts: localhost

  tasks
:
 
- shell: hostname -f
    delegate_to
: "{{ item }}"
    with_items
:
   
- server1
   
- server2



$ ansible-playbook test.yml -vv
Using /vagrant/sysadmin/ansible/atlassian/ansible.cfg as config file
 
[WARNING]: provided hosts list is empty, only localhost is available


1 plays in test.yml


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


TASK
[setup] *******************************************************************
Tuesday 24 May 2016  16:28:43 +0200 (0:00:00.034)       0:00:00.034 ***********
ok
: [localhost]


TASK
[command] *****************************************************************
task path
: /vagrant/sysadmin/ansible/atlassian/test.yml:5
Tuesday 24 May 2016  16:28:43 +0200 (0:00:00.247)       0:00:00.282 ***********
changed
: [localhost -> server1] => (item=server1) => {"changed": true, "cmd": "hostname -f", "delta": "0:00:00.013899", "end": "2016-05-24 16:28:50.279268", "item": "server1", "rc": 0, "start": "2016-05-24 16:28:50.265369", "stderr": "", "stdout": "server1", "stdout_lines": ["server1"], "warnings": []}
changed
: [localhost -> server2] => (item=server2) => {"changed": true, "cmd": "hostname -f", "delta": "0:00:00.009186", "end": "2016-05-24 16:28:50.695290", "item": "server2", "rc": 0, "start": "2016-05-24 16:28:50.686104", "stderr": "", "stdout": "server1", "stdout_lines": ["server1"], "warnings": []}


PLAY RECAP
*********************************************************************
localhost                  
: ok=2    changed=1    unreachable=0    failed=0


Tuesday 24 May 2016  16:28:50 +0200 (0:00:06.694)       0:00:06.976 ***********
===============================================================================
TASK
: command ----------------------------------------------------------- 6.69s
TASK
: setup ------------------------------------------------------------- 0.25s
Playbook run took 0 days, 0 hours, 0 minutes, 6 seconds

It looks like it connects to the two servers but the output of the hostname command shows that it connects twice to the first server...

regards,

Julien.

Julien Tognazzi

unread,
May 24, 2016, 10:36:32 AM5/24/16
to Ansible Project

Julien Tognazzi

unread,
May 24, 2016, 11:09:55 AM5/24/16
to Ansible Project
This is fixed with ansible 2.0.2.0
sorry for the noise.


On Tuesday, May 24, 2016 at 4:34:15 PM UTC+2, Julien Tognazzi wrote:
Reply all
Reply to author
Forward
0 new messages