diff options
| author | Ahmed Abdelhalim <[email protected]> | 2025-09-10 17:52:58 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2025-09-10 17:52:58 +0200 |
| commit | e9e609e89ad879e10e58f2c4fcfa572f60d6dfad (patch) | |
| tree | 6353c98fa1b6ad69c21931ac299e8522f48c645f /roles/user | |
| parent | a5983fd890fc94650e9cc0b890220931ad3b3a88 (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.yml | 3 | ||||
| -rw-r--r-- | roles/user/tasks/main.yml | 24 |
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 |
