mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 15:15:26 +01:00
Merge pull request #101 from schurzi/main
do not persist sysctl when value is invalid Reviewed-by: https://github.com/apps/ansible-zuul
This commit is contained in:
commit
5988748999
2 changed files with 23 additions and 2 deletions
|
|
@ -182,12 +182,12 @@ class SysctlModule(object):
|
||||||
|
|
||||||
# Do the work
|
# Do the work
|
||||||
if not self.module.check_mode:
|
if not self.module.check_mode:
|
||||||
|
if self.set_proc:
|
||||||
|
self.set_token_value(self.args['name'], self.args['value'])
|
||||||
if self.write_file:
|
if self.write_file:
|
||||||
self.write_sysctl()
|
self.write_sysctl()
|
||||||
if self.changed and self.args['reload']:
|
if self.changed and self.args['reload']:
|
||||||
self.reload_sysctl()
|
self.reload_sysctl()
|
||||||
if self.set_proc:
|
|
||||||
self.set_token_value(self.args['name'], self.args['value'])
|
|
||||||
|
|
||||||
def _values_is_equal(self, a, b):
|
def _values_is_equal(self, a, b):
|
||||||
"""Expects two string values. It will split the string by whitespace
|
"""Expects two string values. It will split the string by whitespace
|
||||||
|
|
|
||||||
|
|
@ -289,3 +289,24 @@
|
||||||
- sysctl_check_mode2 is changed
|
- sysctl_check_mode2 is changed
|
||||||
- "'vm.swappiness=22' in sysctl_check_mode_conf_content.stdout_lines"
|
- "'vm.swappiness=22' in sysctl_check_mode_conf_content.stdout_lines"
|
||||||
- sysctl_check_mode_current_vm_swappiness.stdout == '22'
|
- sysctl_check_mode_current_vm_swappiness.stdout == '22'
|
||||||
|
|
||||||
|
# Test sysctl: invalid value
|
||||||
|
- name: Set invalid sysctl property using module
|
||||||
|
sysctl:
|
||||||
|
name: vm.mmap_rnd_bits
|
||||||
|
value: '1024'
|
||||||
|
state: present
|
||||||
|
reload: yes
|
||||||
|
sysctl_set: True
|
||||||
|
ignore_errors: True
|
||||||
|
register: sysctl_invalid_set1
|
||||||
|
|
||||||
|
- name: Read /etc/sysctl.conf
|
||||||
|
command: 'cat /etc/sysctl.conf'
|
||||||
|
register: sysctl_invalid_conf_content
|
||||||
|
|
||||||
|
- name: Ensure changes were not made
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- sysctl_invalid_set1 is failed
|
||||||
|
- "'vm.mmap_rnd_bits' not in sysctl_invalid_conf_content.stdout"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue