In FreeBSD, fail if loader.conf shall be reloaded. (#664) (#748)

Fix #663

(cherry picked from commit 3c232a2429)

Co-authored-by: Vladimir Botka <vbotka@gmail.com>
This commit is contained in:
Hideki Saito
2026-05-27 15:45:16 +09:00
committed by GitHub
parent 955acdca44
commit aaacdb9d13
2 changed files with 9 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ options:
- If V(true), performs a C(/sbin/sysctl -p) if the O(sysctl_file) is
updated. If V(false), does not reload C(sysctl) even if the
O(sysctl_file) is updated.
- For FreeBSD, can not be used with O(sysctl_file) other than C(/etc/sysctl.conf) or C(/etc/sysctl.conf.local).
type: bool
default: true
sysctl_file:
@@ -166,6 +167,11 @@ class SysctlModule(object):
self.platform = platform.system().lower()
# system specific tests
freebsd_sysctl_files = ['/etc/sysctl.conf', '/etc/sysctl.conf.local']
if self.platform == 'freebsd' and self.sysctl_file not in freebsd_sysctl_files and self.args['reload']:
self.module.fail_json(msg="%s can not be reloaded. Set reload=False." % self.sysctl_file)
# Whitespace is bad
self.args['name'] = self.args['name'].strip()
self.args['value'] = self._parse_value(self.args['value'])