diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2019-06-25 17:13:35 +0200 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2019-06-25 11:13:34 -0400 |
commit | 9069a681aabdef45aa201bf39577405070d63af6 (patch) | |
tree | c0d857f3f80f63a63ae4f623a87229ca0601cc93 /lib | |
parent | a09aa205e12ddcd6ca979c52ab719197f87d269d (diff) | |
download | ansible-9069a681aabdef45aa201bf39577405070d63af6.tar.gz |
sysctl: fix 'err' referenced before assignment (#58161)
* sysctl: fix 'err' referenced before assignment
Fixes #58158
* Add changelog
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansible/modules/system/sysctl.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ansible/modules/system/sysctl.py b/lib/ansible/modules/system/sysctl.py index 2a09aa6ff5..34b1d00ece 100644 --- a/lib/ansible/modules/system/sysctl.py +++ b/lib/ansible/modules/system/sysctl.py @@ -271,7 +271,6 @@ class SysctlModule(object): # Run sysctl -p def reload_sysctl(self): - # do it if self.platform == 'freebsd': # freebsd doesn't support -p, so reload the sysctl service rc, out, err = self.module.run_command('/etc/rc.d/sysctl reload', environ_update=self.LANG_ENV) @@ -282,10 +281,16 @@ class SysctlModule(object): rc = 0 if k != self.args['name']: rc = self.set_token_value(k, v) + # FIXME this check is probably not needed as set_token_value would fail_json if rc != 0 if rc != 0: break if rc == 0 and self.args['state'] == "present": rc = self.set_token_value(self.args['name'], self.args['value']) + + # set_token_value would have called fail_json in case of failure + # so return here and do not continue to the error processing below + # https://github.com/ansible/ansible/issues/58158 + return else: # system supports reloading via the -p flag to sysctl, so we'll use that sysctl_args = [self.sysctl_cmd, '-p', self.sysctl_file] |