bug with "become" and "delegate_to" directives and loops with Ansible 2

376 views
Skip to first unread message

fabix

unread,
Feb 3, 2016, 10:31:44 AM2/3/16
to Ansible Project
I've written this little playbook to show the problem:

- name: test become
  hosts
: localhost
  serial
: 1
  tasks
:
 
- name: create test directories
    file
: path=/tmp/test/{{ item }} state=directory
    with_items
:
   
- one
   
- two
    delegate_to
: localhost
    become
: true



It's not very realistic because the delegated host is the same as the target host but the problem is the same with any target hosts.

Make a /tmp/test directory with root's permissions only.

If you run this playbook with a non-root user but who has sudo rights, it will fail on the second item ("two"). The "one" directory will be created correctly.

PLAY [test become] *************************************************************

TASK
[setup] *******************************************************************
ok
: [localhost]

TASK
[create test directories] *************************************************
changed
: [localhost -> localhost] => (item=one)
failed
: [localhost -> localhost] => (item=two) => {"failed": true, "item": "two", "msg": "There was an issue creating /tmp/test/two as requested: 'module' object has no attribute 'EEXISTS'", "path": "/tmp/test/two", "state": "absent"}

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


$ ansible-playbook --version
ansible
-playbook 2.0.0.2
  config file
= /etc/ansible/ansible.cfg
  configured
module search path = Default w/o overrides



fabix

unread,
Feb 3, 2016, 11:44:36 AM2/3/16
to Ansible Project
Hmm, with ansible-playbook 2.1.0, that works. So, the bug is already fixed. Sorry for the noise.
Reply all
Reply to author
Forward
0 new messages