Because paramiko using a pty can't distinguish stderr and stdout, remove handling that
treated -D as a way to show stderr, and make sure modules don't include things on stderr. Update docs and test module script to come into line.
This commit is contained in:
parent
7c9c3b306a
commit
31f6cd6408
3 changed files with 0 additions and 21 deletions
3
apt
3
apt
|
@ -30,9 +30,6 @@ import traceback
|
||||||
APT_PATH = "/usr/bin/apt-get"
|
APT_PATH = "/usr/bin/apt-get"
|
||||||
APT = "DEBIAN_PRIORITY=critical %s" % APT_PATH
|
APT = "DEBIAN_PRIORITY=critical %s" % APT_PATH
|
||||||
|
|
||||||
def debug(msg):
|
|
||||||
print >>sys.stderr, msg
|
|
||||||
|
|
||||||
def exit_json(rc=0, **kwargs):
|
def exit_json(rc=0, **kwargs):
|
||||||
print json.dumps(kwargs)
|
print json.dumps(kwargs)
|
||||||
sys.exit(rc)
|
sys.exit(rc)
|
||||||
|
|
9
group
9
group
|
@ -31,14 +31,8 @@ GROUPADD = "/usr/sbin/groupadd"
|
||||||
GROUPDEL = "/usr/sbin/groupdel"
|
GROUPDEL = "/usr/sbin/groupdel"
|
||||||
GROUPMOD = "/usr/sbin/groupmod"
|
GROUPMOD = "/usr/sbin/groupmod"
|
||||||
|
|
||||||
def debug(msg):
|
|
||||||
# ansible ignores stderr, so it's safe to use for debug
|
|
||||||
print >>sys.stderr, msg
|
|
||||||
#pass
|
|
||||||
|
|
||||||
def exit_json(rc=0, **kwargs):
|
def exit_json(rc=0, **kwargs):
|
||||||
if 'name' in kwargs:
|
if 'name' in kwargs:
|
||||||
debug("add group info to exit_json")
|
|
||||||
add_group_info(kwargs)
|
add_group_info(kwargs)
|
||||||
print json.dumps(kwargs)
|
print json.dumps(kwargs)
|
||||||
sys.exit(rc)
|
sys.exit(rc)
|
||||||
|
@ -59,7 +53,6 @@ def add_group_info(kwargs):
|
||||||
|
|
||||||
def group_del(group):
|
def group_del(group):
|
||||||
cmd = [GROUPDEL, group]
|
cmd = [GROUPDEL, group]
|
||||||
debug("Arguments to groupdel: %s" % (" ".join(cmd)))
|
|
||||||
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return True
|
return True
|
||||||
|
@ -73,7 +66,6 @@ def group_add(group, **kwargs):
|
||||||
cmd.append('-g')
|
cmd.append('-g')
|
||||||
cmd.append(kwargs[key])
|
cmd.append(kwargs[key])
|
||||||
cmd.append(group)
|
cmd.append(group)
|
||||||
debug("Arguments to groupadd: %s" % (" ".join(cmd)))
|
|
||||||
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return True
|
return True
|
||||||
|
@ -91,7 +83,6 @@ def group_mod(group, **kwargs):
|
||||||
if len(cmd) == 1:
|
if len(cmd) == 1:
|
||||||
return False
|
return False
|
||||||
cmd.append(group)
|
cmd.append(group)
|
||||||
debug("Arguments to groupmod: %s" % (" ".join(cmd)))
|
|
||||||
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return True
|
return True
|
||||||
|
|
9
user
9
user
|
@ -33,14 +33,8 @@ USERADD = "/usr/sbin/useradd"
|
||||||
USERMOD = "/usr/sbin/usermod"
|
USERMOD = "/usr/sbin/usermod"
|
||||||
USERDEL = "/usr/sbin/userdel"
|
USERDEL = "/usr/sbin/userdel"
|
||||||
|
|
||||||
def debug(msg):
|
|
||||||
# ansible ignores stderr, so it's safe to use for debug
|
|
||||||
print >>sys.stderr, msg
|
|
||||||
#pass
|
|
||||||
|
|
||||||
def exit_json(rc=0, **kwargs):
|
def exit_json(rc=0, **kwargs):
|
||||||
if 'name' in kwargs:
|
if 'name' in kwargs:
|
||||||
debug("add user info to exit_json")
|
|
||||||
add_user_info(kwargs)
|
add_user_info(kwargs)
|
||||||
print json.dumps(kwargs)
|
print json.dumps(kwargs)
|
||||||
sys.exit(rc)
|
sys.exit(rc)
|
||||||
|
@ -75,7 +69,6 @@ def user_del(user, **kwargs):
|
||||||
elif key == 'remove' and kwargs[key]:
|
elif key == 'remove' and kwargs[key]:
|
||||||
cmd.append('-r')
|
cmd.append('-r')
|
||||||
cmd.append(user)
|
cmd.append(user)
|
||||||
debug("Arguments to userdel: %s" % (" ".join(cmd)))
|
|
||||||
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return True
|
return True
|
||||||
|
@ -118,7 +111,6 @@ def user_add(user, **kwargs):
|
||||||
else:
|
else:
|
||||||
cmd.append('-M')
|
cmd.append('-M')
|
||||||
cmd.append(user)
|
cmd.append(user)
|
||||||
debug("Arguments to useradd: %s" % (" ".join(cmd)))
|
|
||||||
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return True
|
return True
|
||||||
|
@ -172,7 +164,6 @@ def user_mod(user, **kwargs):
|
||||||
if len(cmd) == 1:
|
if len(cmd) == 1:
|
||||||
return False
|
return False
|
||||||
cmd.append(user)
|
cmd.append(user)
|
||||||
debug("Arguments to usermod: %s" % (" ".join(cmd)))
|
|
||||||
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in a new issue