From 7358bf88e26a4c44afd088f5cbd5b5732384e7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Strahinja=20Kustudi=C4=87?= Date: Fri, 9 Dec 2016 22:44:04 +0100 Subject: [PATCH] Fixes ignoreerrors not working with sysctl_set --- lib/ansible/modules/system/sysctl.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/system/sysctl.py b/lib/ansible/modules/system/sysctl.py index e3468d2a80..7d89cbd21d 100644 --- a/lib/ansible/modules/system/sysctl.py +++ b/lib/ansible/modules/system/sysctl.py @@ -250,8 +250,17 @@ class SysctlModule(object): if self.platform == 'openbsd': # openbsd doesn't accept -w, but since it's not needed, just drop it thiscmd = "%s %s=%s" % (self.sysctl_cmd, token, value) + elif self.platform == 'freebsd': + ignore_missing = '' + if self.args['ignoreerrors']: + ignore_missing = '-i' + # freebsd doesn't accept -w, but since it's not needed, just drop it + thiscmd = "%s %s %s=%s" % (self.sysctl_cmd, ignore_missing, token, value) else: - thiscmd = "%s -w %s=%s" % (self.sysctl_cmd, token, value) + ignore_missing = '' + if self.args['ignoreerrors']: + ignore_missing = '-e' + thiscmd = "%s %s -w %s=%s" % (self.sysctl_cmd, ignore_missing, token, value) rc,out,err = self.module.run_command(thiscmd) if rc != 0: self.module.fail_json(msg='setting %s failed: %s' % (token, out + err))