aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonan Amicel <ronan.amicel@gmail.com>2012-10-25 23:11:10 +0200
committerRonan Amicel <ronan.amicel@gmail.com>2012-10-25 23:12:52 +0200
commitde3dc4e0e9a0244b9b06ca40c26ed07df8eeba0a (patch)
treee4f75fe7bd9a0bfb89404b960c0f77f78412efbb
parentNo need to sudo to run getent [#40] (diff)
downloadfabtools-de3dc4e0e9a0244b9b06ca40c26ed07df8eeba0a.tar.xz
Add extra options to create_user (thanks to Gaƫl Pasgrimaud) [#40]
-rw-r--r--fabtools/user.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/fabtools/user.py b/fabtools/user.py
index 3cbdd00..1dd676f 100644
--- a/fabtools/user.py
+++ b/fabtools/user.py
@@ -15,7 +15,8 @@ def exists(name):
return run('getent passwd %(name)s' % locals()).succeeded
-def create(name, home=None, shell=None, uid=None, gid=None, groups=None):
+def create(name, home=None, shell=None, uid=None, gid=None, groups=None,
+ gecos=None, disabled_password=False, disabled_login=False):
"""
Create a new user.
@@ -37,8 +38,14 @@ def create(name, home=None, shell=None, uid=None, gid=None, groups=None):
if home:
options.append('--home-dir "%s"' % home)
if shell:
- options.append('--shell "%s"' % (shell))
+ options.append('--shell "%s"' % shell)
if uid:
options.append('--uid %s' % uid)
+ if gecos:
+ options.append('--gecos "%s"' % gecos)
+ if disabled_password:
+ options.append('--disabled-password')
+ if disabled_login:
+ options.append('--disabled-login')
options = " ".join(options)
sudo('useradd %(options)s %(name)s' % locals())