$OpenBSD: patch-salt_modules_openbsd_sysctl_py,v 1.2 2018/04/25 10:02:48 jasper Exp $

https://github.com/saltstack/salt/pull/45228

Index: salt/modules/openbsd_sysctl.py
--- salt/modules/openbsd_sysctl.py.orig
+++ salt/modules/openbsd_sysctl.py
@@ -4,6 +4,7 @@ Module for viewing and modifying OpenBSD sysctl parame
 '''
 from __future__ import absolute_import, print_function, unicode_literals
 import os
+import re
 
 # Import salt libs
 from salt.ext import six
@@ -76,7 +77,11 @@ def assign(name, value):
     cmd = 'sysctl {0}="{1}"'.format(name, value)
     data = __salt__['cmd.run_all'](cmd)
 
-    if data['retcode'] != 0:
+    # Certain values cannot be set from this console, at the current
+    # securelevel or there are other restrictions that prevent us
+    # from applying the setting rightaway.
+    if re.match(r'^sysctl:.*: Operation not permitted$', data['stderr']) or \
+      data['retcode'] != 0:
         raise CommandExecutionError('sysctl failed: {0}'.format(
             data['stderr']))
     new_name, new_value = data['stdout'].split(':', 1)
