You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ansible 1.7 (devel 74f20eb) last updated 2014/06/04 13:35:25 (GMT +1000)
Environment:
Fedora 20 but will happen for other Linux OSs at least
Summary:
This seems to be a result of 202ac68 - nominally fixes for #7515 and #7537.
The check for whether a symlink that exists points to the correct destination is incorrect if that destination is a directory.
Steps To Reproduce:
The following playbook reproduces the issue. It works fine the first time, but not the second time:
- hosts: localhost
connection: local
tasks:
- name: create a directory
action: file state=directory path=/tmp/this_is_a_dir
- name: create a link to a directory
action: file state=link src=/tmp/this_is_a_dir dest=/tmp/this_is_a_link
Expected Results:
The playbook is idemptotent
Actual Results:
[will@fedora ansible]$ ansible-playbook broken-links.yml -v
PLAY [localhost] **************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [create a directory] ****************************************************
ok: [localhost] => {"changed": false, "gid": 1000, "group": "will", "mode": "0775", "owner": "will", "path": "/tmp/this_is_a_dir", "secontext": "unconfined_u:object_r:user_tmp_t:s0", "size": 40, "state": "directory", "uid": 1000}
TASK: [create a link to a directory] ******************************************
failed: [localhost] => {"failed": true, "gid": 1000, "group": "will", "mode": "0777", "owner": "will", "path": "/tmp/this_is_a_link", "secontext": "unconfined_u:object_r:user_tmp_t:s0", "size": 18, "src": "/tmp/this_is_a_dir", "state": "link", "uid": 1000}
msg: src file does not exist, use "force=yes" if you really want to create the link: /tmp/this_is_a_link/this_is_a_dir
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/will/broken-links.retry
localhost : ok=2 changed=0 unreachable=0 failed=1
Note that it's trying to create a link to /tmp/this_is_a_link/this_is_a_dir, rather than to /tmp/this_is_a_dir.
One reason might be that os.path.isdir is True for symlinks that point to directories. I did not expect that.
I agree, and have added that to the check on that line, which does appear to correct this issue. Thanks for reporting it, and let us know if you have any further problems related to this!
Issue Type:
Bug Report
Ansible Version:
ansible 1.7 (devel 74f20eb) last updated 2014/06/04 13:35:25 (GMT +1000)
Environment:
Fedora 20 but will happen for other Linux OSs at least
Summary:
This seems to be a result of 202ac68 - nominally fixes for #7515 and #7537.
The check for whether a symlink that exists points to the correct destination is incorrect if that destination is a directory.
Steps To Reproduce:
The following playbook reproduces the issue. It works fine the first time, but not the second time:
Expected Results:
The playbook is idemptotent
Actual Results:
Note that it's trying to create a link to /tmp/this_is_a_link/this_is_a_dir, rather than to /tmp/this_is_a_dir.
One reason might be that os.path.isdir is True for symlinks that point to directories. I did not expect that.
I suspect
https://github.com/ansible/ansible/blob/devel/library/files/file#L192
should have a not os.path.islink(path) too.
The text was updated successfully, but these errors were encountered: