ansible/test/integration/targets/file/tasks/link_rewrite.yml
Alexander Sowitzki e804fccf1c 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.
2021-03-01 15:14:03 +01:00

47 lines
899 B
YAML

- 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'"