diff --git a/test/integration/targets/file/tasks/main.yml b/test/integration/targets/file/tasks/main.yml index 14f99fdd110..c1ff007d24f 100644 --- a/test/integration/targets/file/tasks/main.yml +++ b/test/integration/targets/file/tasks/main.yml @@ -135,6 +135,22 @@ that: - "file6_touch_result.changed == true" +- name: stat1 + stat: path={{output_file}} + register: hlstat1 + +- name: stat2 + stat: path={{output_dir}}/hard.txt + register: hlstat2 + +- name: verify that hard link was made + assert: + that: + - "hlstat1.stat.inode == hlstat2.stat.inode" + +- name: create hard link to file 2 + file: src={{output_file}} dest={{output_dir}}/hard.txt state=hard + - name: create a directory file: path={{output_dir}}/foobar state=directory register: file7_result diff --git a/test/integration/targets/template/tasks/main.yml b/test/integration/targets/template/tasks/main.yml index 4d5c4fa20e2..35246c62a85 100644 --- a/test/integration/targets/template/tasks/main.yml +++ b/test/integration/targets/template/tasks/main.yml @@ -306,6 +306,46 @@ that: - "template_result|changed" +## demonstrate copy module failing to overwrite a file that's been hard linked +## https://github.com/ansible/ansible/issues/10834 + +- name: ensure test dir is absent + file: + path: /tmp/10834.2_test + state: absent + +- name: create test dir + file: + path: /tmp/10834.2_test + state: directory + +- name: template out test file to system 1 + template: + src: foo.j2 + dest: /tmp/10834.2_test/test_file + +# not an issue when not hard linked +- name: template out test file to system 2 + template: + src: foo.j2 + dest: /tmp/10834.2_test/test_file + +- name: make hard link + file: + src: /tmp/10834.2_test/test_file + dest: /tmp/10834.2_test/test_file_hardlink + state: hard + +- name: template out test file to system 3 + template: + src: foo.j2 + dest: /tmp/10834.2_test/test_file + +- name: cleanup + file: + path: /tmp/10834.2_test + state: absent + - name: change var for the template set_fact: templated_var: "templated_var_loaded"