mirror of https://github.com/ansible/ansible.git
Let file module not change link to absolute when src not given (#65448)
The file module changes existing sym links from relative to absolute if the src is not stated in the tasks since it uses `os.path.realpath` to fetch the link source and not `os.readlink`. Changed that.pull/72287/head
parent
176beddb3f
commit
e804fccf1c
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- file - prevent link src from being rewritten when src is not specified explicitly (https://github.com/ansible/ansible/issues/65448)
|
@ -0,0 +1,47 @@
|
||||
- name: create temporary build directory
|
||||
tempfile:
|
||||
state: directory
|
||||
suffix: ansible_test_leave_links_alone_during_touch
|
||||
register: tempdir
|
||||
|
||||
- name: create file
|
||||
copy:
|
||||
mode: 0600
|
||||
content: "chicken"
|
||||
dest: "{{ tempdir.path }}/somefile"
|
||||
|
||||
- name: Create relative link
|
||||
file:
|
||||
src: somefile
|
||||
dest: "{{ tempdir.path }}/somelink"
|
||||
state: link
|
||||
|
||||
- stat:
|
||||
path: "{{ tempdir.path }}/somelink"
|
||||
register: link
|
||||
|
||||
- stat:
|
||||
path: "{{ tempdir.path }}/somefile"
|
||||
register: file
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "file.stat.mode == '0600'"
|
||||
- "link.stat.lnk_target == 'somefile'"
|
||||
|
||||
- file:
|
||||
path: "{{ tempdir.path }}/somelink"
|
||||
mode: 0644
|
||||
|
||||
- stat:
|
||||
path: "{{ tempdir.path }}/somelink"
|
||||
register: link
|
||||
|
||||
- stat:
|
||||
path: "{{ tempdir.path }}/somefile"
|
||||
register: file
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "file.stat.mode == '0644'"
|
||||
- "link.stat.lnk_target == 'somefile'"
|
Loading…
Reference in New Issue