From 0bc3546ef3192b30eb1290873a40327176dfd526 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 10 Oct 2020 14:17:23 +0300 Subject: feat(unix_users): user MUST declare compat version they want --- roles/unix_users/defaults/main.yml | 6 ++++++ roles/unix_users/subplot.md | 2 ++ roles/unix_users/tasks/main.yml | 5 +++++ 3 files changed, 13 insertions(+) (limited to 'roles') diff --git a/roles/unix_users/defaults/main.yml b/roles/unix_users/defaults/main.yml index ea33fc9..8982001 100644 --- a/roles/unix_users/defaults/main.yml +++ b/roles/unix_users/defaults/main.yml @@ -1,3 +1,9 @@ +# The user of the role MUST define the version they want to use. If +# it's not what the version of unix_users being used actually +# provides, the role will fail. +unix_users_version: null + + # List of system users to create. Value a list of dicts with keys: # # username -- the username of the new user diff --git a/roles/unix_users/subplot.md b/roles/unix_users/subplot.md index 9bd5f6e..f0acf36 100644 --- a/roles/unix_users/subplot.md +++ b/roles/unix_users/subplot.md @@ -17,6 +17,8 @@ and the user foo on host has authorized_keys containing "ssh-rsa" ~~~ ~~~{#foo.yml .file .yaml} +unix_users_version: 0 + unix_users: - username: foo comment: Foo Bar diff --git a/roles/unix_users/tasks/main.yml b/roles/unix_users/tasks/main.yml index 00c49fd..7681632 100644 --- a/roles/unix_users/tasks/main.yml +++ b/roles/unix_users/tasks/main.yml @@ -1,3 +1,8 @@ +- name: "check unix_users_version" + shell: | + [ "{{ unix_users_version }}" = "0" ] || \ + (echo "Unexpected version {{ unix_users_version }}" 1>&2; exit 1) + - name: create system users with_items: "{{ unix_users }}" user: -- cgit v1.2.1