diff --git a/molecule/deletion/molecule.yml b/molecule/deletion/molecule.yml index 86935c6..5e503eb 100644 --- a/molecule/deletion/molecule.yml +++ b/molecule/deletion/molecule.yml @@ -22,7 +22,7 @@ provisioner: all: linux_accounts_additional_users: { "bob": "bobssshkey" } - linux_accounts_default_users: { "alice": "alicessshkey" } + linux_accounts_default_users: { "alice": "alicessshkey", "erwin": "erwinsshkey" } linux_accounts_additional_sudo_users: - "bob" diff --git a/molecule/deletion/prepare.yml b/molecule/deletion/prepare.yml index 691e8cb..7ca63e9 100644 --- a/molecule/deletion/prepare.yml +++ b/molecule/deletion/prepare.yml @@ -16,3 +16,10 @@ loop: - "charlie" - "dave" + - "erwin" + + - name: Grant sudo privileges to erwin + user: + name: "erwin" + groups: sudo + append: yes diff --git a/molecule/deletion/verify.yml b/molecule/deletion/verify.yml index 3a553ce..d7cdb4b 100644 --- a/molecule/deletion/verify.yml +++ b/molecule/deletion/verify.yml @@ -18,3 +18,15 @@ database: passwd fail_key: true key: dave + + - name: Get sudo group members + getent: + database: group + key: sudo + register: sudo_group + changed_when: false + + - name: Assert 'erwin' is not in 'sudo' group + assert: + that: + - "'erwin' not in sudo_group['ansible_facts']['getent_group']['sudo'][2].split(',')" # Index 2 typically holds the user list for the group.