handle ignoreerrors consistently

This commit is contained in:
mubashir.Ijaz 2025-08-08 16:13:08 +02:00
parent 571e80cdba
commit 560afe8217
2 changed files with 5 additions and 1 deletions

View file

@ -358,7 +358,10 @@ class SysctlModule(object):
if self.system_wide:
for sysctl_file in self.SYSCTL_DIRS:
for conf_file in glob.glob(sysctl_file):
rc, out, err = self.module.run_command([self.sysctl_cmd, '-p', conf_file], environ_update=self.LANG_ENV)
sysctl_args = [self.sysctl_cmd, '-p', conf_file]
if self.args['ignoreerrors']:
sysctl_args.insert(1, '-e')
rc, out, err = self.module.run_command(sysctl_args, environ_update=self.LANG_ENV)
if rc != 0 or self._stderr_failed(err):
self.module.fail_json(msg="Failed to reload sysctl: %s" % to_native(out) + to_native(err))
else:

View file

@ -140,6 +140,7 @@
ansible.posix.sysctl:
name: test.invalid
value: 1
ignoreerrors: true
register: sysctl_test3
ignore_errors: true