summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--roles/unix_users/subplot.md1
-rw-r--r--roles/unix_users/subplot.py7
-rw-r--r--roles/unix_users/subplot.yaml3
3 files changed, 11 insertions, 0 deletions
diff --git a/roles/unix_users/subplot.md b/roles/unix_users/subplot.md
index 049bfc2..9a0356a 100644
--- a/roles/unix_users/subplot.md
+++ b/roles/unix_users/subplot.md
@@ -6,6 +6,7 @@ This role creates or updates Unix users.
~~~scenario
given a host running Debian
+then the host has no user foo
when I use role unix_users
and I use variables from foo.yml
and I run the playbook
diff --git a/roles/unix_users/subplot.py b/roles/unix_users/subplot.py
index 118d007..9b77e49 100644
--- a/roles/unix_users/subplot.py
+++ b/roles/unix_users/subplot.py
@@ -1,3 +1,10 @@
+def host_does_not_have_user(ctx, username=None):
+ assert_ne = globals()["assert_ne"]
+ qemu = ctx["qemu"]
+ output, exit = qemu.ssh(["getent", "passwd", username])
+ assert_ne(exit, 0)
+
+
def host_has_user(ctx, username=None):
assert_eq = globals()["assert_eq"]
qemu = ctx["qemu"]
diff --git a/roles/unix_users/subplot.yaml b/roles/unix_users/subplot.yaml
index 9fcc961..e59c9a0 100644
--- a/roles/unix_users/subplot.yaml
+++ b/roles/unix_users/subplot.yaml
@@ -1,2 +1,5 @@
+- then: the host has no user {username}
+ function: host_does_not_have_user
+
- then: the host has user {username}
function: host_has_user