diff --git a/salt/modules/groupadd.py b/salt/modules/groupadd.py index e3e1aa00b4..a5c1cfb444 100644 --- a/salt/modules/groupadd.py +++ b/salt/modules/groupadd.py @@ -13,7 +13,10 @@ def __virtual__(): ''' Set the user module if the kernel is Linux or OpenBSD ''' - return 'group' if __grains__['kernel'] in ('Linux', 'OpenBSD') else False + return ( + 'group' if __grains__['kernel'] in ('Linux', 'OpenBSD', 'NetBSD') + else False + ) def add(name, gid=None, system=False): diff --git a/salt/modules/shadow.py b/salt/modules/shadow.py index b59321b56e..77905c5e07 100644 --- a/salt/modules/shadow.py +++ b/salt/modules/shadow.py @@ -19,7 +19,9 @@ def __virtual__(): ''' # Disable on Windows, a specific file module exists: - if salt.utils.is_windows() or __grains__['kernel'] == 'SunOS': + if salt.utils.is_windows() or __grains__['kernel'] in ( + 'SunOS', 'NetBSD' + ): return False return 'shadow' diff --git a/salt/modules/useradd.py b/salt/modules/useradd.py index a523bd2936..0658c0720f 100644 --- a/salt/modules/useradd.py +++ b/salt/modules/useradd.py @@ -34,7 +34,8 @@ def __virtual__(): 'list_groups', 'list_users', '__virtual__'): delattr(mod, attr) return ( - 'user' if __grains__['kernel'] in ('Linux', 'Darwin', 'OpenBSD') + 'user' if __grains__['kernel'] in ('Linux', 'Darwin', 'OpenBSD', + 'NetBSD') else False ) @@ -120,7 +121,8 @@ def add(name, if not unique: cmd += '-o ' if system: - cmd += '-r ' + if not __grains__['kernel'] == 'NetBSD': + cmd += '-r ' cmd += name ret = __salt__['cmd.run_all'](cmd)['retcode'] if ret != 0: diff --git a/salt/states/user.py b/salt/states/user.py index b133efbe29..6e1e675514 100644 --- a/salt/states/user.py +++ b/salt/states/user.py @@ -49,7 +49,7 @@ def _changes(name, otherwise return False. ''' - if __grains__['os'] not in ('FreeBSD', 'OpenBSD'): + if __grains__['os'] not in ('FreeBSD', 'OpenBSD', 'NetBSD'): lshad = __salt__['shadow.info'](name) lusr = __salt__['user.info'](name) @@ -96,7 +96,7 @@ def _changes(name, if lusr['shell'] != shell: change['shell'] = shell if password: - if __grains__['os'] not in ('FreeBSD', 'OpenBSD'): + if __grains__['os'] not in ('FreeBSD', 'OpenBSD', 'NetBSD'): if lshad['pwd'] == '!' or \ lshad['pwd'] != '!' and enforce_password: if lshad['pwd'] != password: @@ -263,7 +263,7 @@ def present(name, ret['comment'] += '{0}: {1}\n'.format(key, val) return ret # The user is present - if not __grains__['os'] in ('FreeBSD', 'OpenBSD'): + if not __grains__['os'] in ('FreeBSD', 'OpenBSD', 'NetBSD'): lshad = __salt__['shadow.info'](name) pre = __salt__['user.info'](name) for key, val in changes.items(): @@ -282,14 +282,14 @@ def present(name, post = __salt__['user.info'](name) spost = {} - if __grains__['os'] not in ('FreeBSD', 'OpenBSD'): + if __grains__['os'] not in ('FreeBSD', 'OpenBSD', 'NetBSD'): if lshad['pwd'] != password: spost = __salt__['shadow.info'](name) # See if anything changed for key in post: if post[key] != pre[key]: ret['changes'][key] = post[key] - if __grains__['os'] not in ('FreeBSD', 'OpenBSD'): + if __grains__['os'] not in ('FreeBSD', 'OpenBSD', 'NetBSD'): for key in spost: if lshad[key] != spost[key]: ret['changes'][key] = spost[key]