summaryrefslogtreecommitdiff
path: root/roles/unix_users/subplot.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-11-08 09:32:29 +0200
committerLars Wirzenius <liw@liw.fi>2020-11-08 09:44:36 +0200
commit0467496724b8875a5ba5fa95d07740aa51f6c780 (patch)
tree21a218b35165a3a6025cc56e5f4ee93d8c3706fd /roles/unix_users/subplot.py
parentedac7f326c8138d7377d595a3cf26f7f3d36b0fb (diff)
downloaddebian-ansible-0467496724b8875a5ba5fa95d07740aa51f6c780.tar.gz
feat(unix_users): allow a user to be added to extra groups
Diffstat (limited to 'roles/unix_users/subplot.py')
-rw-r--r--roles/unix_users/subplot.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/roles/unix_users/subplot.py b/roles/unix_users/subplot.py
index 7bf921d..05330fd 100644
--- a/roles/unix_users/subplot.py
+++ b/roles/unix_users/subplot.py
@@ -14,7 +14,7 @@ def host_has_user(ctx, username=None):
output, exit = qemu.ssh(["getent", "passwd", username])
assert_eq(exit, 0)
output = output.decode("UTF8")
- assert f"\n{username}:" in output
+ assert f"{username}:" in output
def host_user_has_shell(ctx, username=None, shell=None):
@@ -46,3 +46,14 @@ def host_user_has_authorized_keys_containing(ctx, username=None, substring=None)
assert_eq(exit, 0)
output = output.decode("UTF8")
assert substring in output
+
+
+def host_user_is_in_group(ctx, username=None, group=None):
+ assert_eq = globals()["assert_eq"]
+ qemu = ctx["qemu"]
+ output, exit = qemu.ssh(["sudo", "-u", username, "groups"])
+ assert_eq(exit, 0)
+ output = output.decode("UTF8")
+ groups = output.split()
+ logging.debug(f"host_user_is_in_group: groups={groups}")
+ assert group in groups