summaryrefslogtreecommitdiffstats
path: root/roles/user
diff options
context:
space:
mode:
authorAhmed AbdelHalim <[email protected]>2025-09-10 17:52:58 +0200
committerAhmed AbdelHalim <[email protected]>2025-09-10 17:52:58 +0200
commit48e2ad4c1e081b9e6a336132a7f78cb7399c43d9 (patch)
tree6353c98fa1b6ad69c21931ac299e8522f48c645f /roles/user
parentdb5127984ff77d0ff78ca37f521cc6b1d6d33423 (diff)
Refactor role dependencies to be more module modular
This modularity means that each role can be installed in a playbook by itself as long as the other roles exist around it. This also straps the ensure dependency packages exist in any of the roles tasks, they should be moved to their own roles and configured properly if needed.
Diffstat (limited to 'roles/user')
-rw-r--r--roles/user/meta/main.yml3
-rw-r--r--roles/user/tasks/main.yml24
2 files changed, 3 insertions, 24 deletions
diff --git a/roles/user/meta/main.yml b/roles/user/meta/main.yml
index 996a5fc3..50cb8081 100644
--- a/roles/user/meta/main.yml
+++ b/roles/user/meta/main.yml
@@ -1,6 +1,7 @@
---
dependencies:
- - "bash"
+ - role: "bash"
+ - role: "sudo"
galaxy_info:
author: "a14m"
description: "Configure user and sudo"
diff --git a/roles/user/tasks/main.yml b/roles/user/tasks/main.yml
index e6e2a306..8fcb101b 100644
--- a/roles/user/tasks/main.yml
+++ b/roles/user/tasks/main.yml
@@ -1,29 +1,7 @@
---
-- name: "Ensure sudo is installed"
- become: true
- ansible.builtin.package:
- name:
- - "sudo"
- state: "present"
-
-- name: "Set sudo group fact"
- ansible.builtin.set_fact:
- # noqa var-naming[no-role-prefix] the sudo group is global and better named this way than user_sudo_group
- sudo_group: "sudo"
-
- name: "Set user groups fact"
ansible.builtin.set_fact:
- user_groups: "{{ ([username, sudo_group] + user_groups) | unique }}"
-
-- name: "Configure permissions for group: {{ sudo_group }}"
- become: true
- community.general.sudoers:
- name: "enable-sudo-group"
- group: "{{ sudo_group }}"
- commands: "ALL"
- nopassword: false
- sudoers_path: "/etc/sudoers.d"
- state: present
+ user_groups: "{{ ([username, 'sudo'] + user_groups) | unique }}"
- name: "Ensure user groups are created"
become: true