1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Reworked PR to avoid repeating the command

This commit is contained in:
Tom Dymond 2014-02-05 15:35:24 +00:00
parent cf80f9b68b
commit 486d14cb2d

View file

@ -220,10 +220,11 @@ class SysctlModule(object):
rc,out,err = self.module.run_command('/etc/rc.d/sysctl reload') rc,out,err = self.module.run_command('/etc/rc.d/sysctl reload')
else: else:
# system supports reloading via the -p flag to sysctl, so we'll use that # system supports reloading via the -p flag to sysctl, so we'll use that
sysctl_args = [self.sysctl_cmd, '-p', self.sysctl_file]
if self.args['ignoreerrors']: if self.args['ignoreerrors']:
rc,out,err = self.module.run_command([self.sysctl_cmd, '-e', '-p', self.sysctl_file]) sysctl_args.insert(1, '-e')
else:
rc,out,err = self.module.run_command([self.sysctl_cmd, '-p', self.sysctl_file]) rc,out,err = self.module.run_command(sysctl_args)
if rc != 0: if rc != 0:
self.module.fail_json(msg="Failed to reload sysctl: %s" % str(out) + str(err)) self.module.fail_json(msg="Failed to reload sysctl: %s" % str(out) + str(err))