summaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-09-08 12:23:48 +0300
committerLars Wirzenius <liw@liw.fi>2020-10-06 12:08:24 +0300
commit746ddbc6e17d9ab8238cc4a8e3a348ccb44878b5 (patch)
tree404e18d59a99bcc516cc7f3f07d12a168967f165 /roles
parent4819295206d7e1ef2f384dd8b66259434181a3d7 (diff)
downloaddebian-ansible-746ddbc6e17d9ab8238cc4a8e3a348ccb44878b5.tar.gz
test: add a subplot to verify the roles work
Diffstat (limited to 'roles')
-rw-r--r--roles/unix_users/subplot.md19
-rw-r--r--roles/unix_users/subplot.py7
-rw-r--r--roles/unix_users/subplot.yaml2
3 files changed, 28 insertions, 0 deletions
diff --git a/roles/unix_users/subplot.md b/roles/unix_users/subplot.md
new file mode 100644
index 0000000..049bfc2
--- /dev/null
+++ b/roles/unix_users/subplot.md
@@ -0,0 +1,19 @@
+# unix_users &ndash; manage Unix users
+
+This role creates or updates Unix users.
+
+## Create user with unix_users
+
+~~~scenario
+given a host running Debian
+when I use role unix_users
+and I use variables from foo.yml
+and I run the playbook
+then the host has user foo
+~~~
+
+~~~{#foo.yml .file .yaml}
+unix_users:
+- username: foo
+ comment: Foo Bar
+~~~
diff --git a/roles/unix_users/subplot.py b/roles/unix_users/subplot.py
new file mode 100644
index 0000000..118d007
--- /dev/null
+++ b/roles/unix_users/subplot.py
@@ -0,0 +1,7 @@
+def host_has_user(ctx, username=None):
+ assert_eq = globals()["assert_eq"]
+ qemu = ctx["qemu"]
+ output, exit = qemu.ssh(["getent", "passwd", username])
+ assert_eq(exit, 0)
+ output = output.decode("UTF8")
+ assert f"\n{username}:" in output
diff --git a/roles/unix_users/subplot.yaml b/roles/unix_users/subplot.yaml
new file mode 100644
index 0000000..9fcc961
--- /dev/null
+++ b/roles/unix_users/subplot.yaml
@@ -0,0 +1,2 @@
+- then: the host has user {username}
+ function: host_has_user