From 0b554d4ab6209c15a214db1d65ce39a7e0e05424 Mon Sep 17 00:00:00 2001 From: L3D Date: Fri, 23 Feb 2024 19:13:13 +0100 Subject: [PATCH 1/2] Add ability to add additional groups --- README.md | 1 + roles/admin/README.md | 1 + roles/sshd/README.md | 1 + roles/user/README.md | 1 + roles/user/defaults/main.yml | 1 + roles/user/tasks/users.yml | 1 + roles/user/vars/main.yml | 2 +- 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ff4a86b..4c2bf21 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ The Option of these directory-variables are the following. | ``pubkeys`` | string or lookup | - | see examples | | ``exklusive_pubkeys`` | ``true`` | - | delete all undefined ssh keys | | ``password`` | password hash | - | See [official FAQ](https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-encrypted-passwords-for-the-user-module) | +| ``groups`` | list | - | Additional groups for your user | | ``remove`` | ``false`` | - | completly remove user if ``state: absent`` | ### Other variables diff --git a/roles/admin/README.md b/roles/admin/README.md index b294772..462b140 100644 --- a/roles/admin/README.md +++ b/roles/admin/README.md @@ -29,6 +29,7 @@ The Option of these directory-variables are the following. | ``pubkeys`` | string or lookup | - | see examples | | ``exklusive_pubkeys`` | ``true`` | - | delete all undefined ssh keys | | ``password`` | password hash | - | See [official FAQ](https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-encrypted-passwords-for-the-user-module) | +| ``groups`` | list | - | Additional groups for your user | | ``remove`` | ``false`` | - | completly remove user if ``state: absent`` | ### Other diff --git a/roles/sshd/README.md b/roles/sshd/README.md index 88b8573..26d93f1 100644 --- a/roles/sshd/README.md +++ b/roles/sshd/README.md @@ -27,6 +27,7 @@ The Option of these directory-variables are the following. | ``pubkeys`` | string or lookup | - | see examples | | ``exklusive_pubkeys`` | ``true`` | - | delete all undefined ssh keys | | ``password`` | password hash | - | See [official FAQ](https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-encrypted-passwords-for-the-user-module) | +| ``groups`` | list | - | Additional groups for your user | | ``remove`` | ``false`` | - | completly remove user if ``state: absent`` | There is a third directory-variable called ``l3d_users__ssh_login: []`` which only support ``name`` and ``state`` for users, that sould be able to login on that system. diff --git a/roles/user/README.md b/roles/user/README.md index 10a7411..6734375 100644 --- a/roles/user/README.md +++ b/roles/user/README.md @@ -28,6 +28,7 @@ The Option of these directory-variables are the following. | ``pubkeys`` | string or lookup | - | see examples | | ``exklusive_pubkeys`` | ``true`` | - | delete all undefined ssh keys | | ``password`` | password hash | - | See [official FAQ](https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-encrypted-passwords-for-the-user-module) | +| ``groups`` | list | - | Additional groups for your user | | ``remove`` | ``false`` | - | completly remove user if ``state: absent`` | ### Other Variables diff --git a/roles/user/defaults/main.yml b/roles/user/defaults/main.yml index f7f3d72..2022b5e 100644 --- a/roles/user/defaults/main.yml +++ b/roles/user/defaults/main.yml @@ -15,6 +15,7 @@ l3d_users__default_users: [] # admin_commands: 'ALL' # admin_nopassword: false # admin_ansible_login: true +# groups: ['admin', 'foo', 'bar'] # - name: 'bob' # state: 'present' # shell: '/bin/zsh' diff --git a/roles/user/tasks/users.yml b/roles/user/tasks/users.yml index de16f15..b682cfd 100644 --- a/roles/user/tasks/users.yml +++ b/roles/user/tasks/users.yml @@ -15,6 +15,7 @@ ansible.builtin.user: name: "{{ user.name }}" group: "{{ user.name }}" + groups: "{{ user.groups | default() }}" state: 'present' create_home: "{{ user.create_home | default(true) }}" comment: "User created by ansible" diff --git a/roles/user/vars/main.yml b/roles/user/vars/main.yml index 954fcd2..476ca0b 100644 --- a/roles/user/vars/main.yml +++ b/roles/user/vars/main.yml @@ -1,3 +1,3 @@ --- -playbook_version_number: 8 +playbook_version_number: 9 playbook_version_path: 'l3d.users.user.version' From a8da61e8959c92722d6e5c0aa5bae92f3710da5b Mon Sep 17 00:00:00 2001 From: L3D Date: Fri, 23 Feb 2024 19:16:37 +0100 Subject: [PATCH 2/2] Increase version 1.0.1 --- README.md | 31 +++++++++++++++++++++++++++++++ galaxy.yml | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c2bf21..278954a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,37 @@ And it is possible to delete users too. + ``l3d.users.admin``: [roles/admin](roles/admin) ![logo](https://ansible.l3d.space/svg/l3d.users.admin_ansible-role.svg) + ``l3d.users.sshd``: [roles/sshd](roles/admin) ![logo](https://ansible.l3d.space/svg/l3d.users.sshd_ansible-role.svg) +## Using this Collection +You can install the collection using ansible-galaxy by running: +```bash +ansible-galaxy collection install l3d.users:1.0.1 +``` + +Remember you can to Upgrade to the latest version of the l3d.git collection using the ``--upgrade`` parameter: +```bash +ansible-galaxy collection install l3d.users --upgrade +``` + +Or you could clone this collection in your local ansible project for example to ``collections/ansible_collections/l3d/users/``. +``` +# Clone git Repo to specified path +git clone https://github.com/roles-ansible/ansible_collection_users.git collections/ansible_collections/l3d/users/ + +# change directory +cd collections/ansible_collections/l3d/users/ + +# optionally install all requirements +ansible-galaxy collection install -r requirements.yml --upgrade +``` + +You can also list a collection in ``requirements.yml``: +```yaml +--- +collections: + - name: l3d.users + version: ">=1.0.1" +``` + Global Variables: ------------------- diff --git a/galaxy.yml b/galaxy.yml index 8ee080a..5edc4e4 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -9,7 +9,7 @@ namespace: l3d name: users # The version of the collection. Must be compatible with semantic versioning -version: 1.0.0 +version: 1.0.1 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md