aboutsummaryrefslogtreecommitdiffstats
path: root/roles/_workstation/env
diff options
context:
space:
mode:
Diffstat (limited to 'roles/_workstation/env')
-rw-r--r--roles/_workstation/env/tasks/main.yml12
1 files changed, 10 insertions, 2 deletions
diff --git a/roles/_workstation/env/tasks/main.yml b/roles/_workstation/env/tasks/main.yml
index 3c54210..261170e 100644
--- a/roles/_workstation/env/tasks/main.yml
+++ b/roles/_workstation/env/tasks/main.yml
@@ -8,9 +8,17 @@
stat: path=/usr/bin/doas
register: _workstation_env_become
+- name: retrieve existing users
+ shell: cat /etc/passwd | cut -d ":" -f 1
+ register: result
+
+- name: check if target user exists
+ fail:
+ msg: _ws_user is not a valid user
+ when: _ws_user not in result.stdout_lines
+
- name: retrieve host facts
set_fact:
#ansible_become_method: "{{ 'doas' if _workstation_env_become.stat.exists else 'sudo' }}"
ansible_become_method: "su"
- ansible_become_user: "{{ _workstation_env_user }}"
-
+ ansible_become_user: "{{ _ws_user }}"
remember that computers suck.