From d49bd27fae0cda7a7a0466205cf3e12b81a985ec Mon Sep 17 00:00:00 2001 From: Jill Rouleau Date: Tue, 7 May 2024 14:42:04 -0700 Subject: [PATCH] Revert "sysctl: Fixed sysctl to work on symlinks(#111)" This reverts commit 34b467719e0dab10d062813cdef11b49f3925ed6. --- .../integration/targets/sysctl/tasks/main.yml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/integration/targets/sysctl/tasks/main.yml b/tests/integration/targets/sysctl/tasks/main.yml index 249bde1..3781109 100644 --- a/tests/integration/targets/sysctl/tasks/main.yml +++ b/tests/integration/targets/sysctl/tasks/main.yml @@ -332,3 +332,36 @@ that: - sysctl_invalid_set1 is failed - "'vm.mmap_rnd_bits' not in sysctl_invalid_conf_content.stdout" + + # Test sysctl: sysctl_file is symlink + - name: Create link source + copy: + content: | + # Testing Ansible Sysctl module on symlink. + dest: /tmp/ansible_sysctl_test.conf + + - name: Create symlink to the conf file + file: + src: /tmp/ansible_sysctl_test.conf + dest: /tmp/ansible_sysctl_test_symlink.conf + state: link + + - name: Use sysctl module with symlink sysctl file + sysctl: + name: 'kernel.randomize_va_space' + value: '1' + sysctl_file: /tmp/ansible_sysctl_test_symlink.conf + state: present + sysctl_set: false + reload: false + + - name: Stat sysctl file + stat: + path: /tmp/ansible_sysctl_test_symlink.conf + register: stat_result + + - name: Ensure the sysctl file remains a symlink + assert: + that: + - stat_result.stat.islnk is defined and stat_result.stat.islnk + - stat_result.stat.lnk_source == /tmp/ansible_sysctl_test.conf