aboutsummaryrefslogtreecommitdiffstats
path: root/roles/_workstation/env/tasks
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2021-05-03 20:21:31 +0200
committerRomain Gonçalves <me@rgoncalves.se>2021-05-03 20:21:31 +0200
commit5d07c5c3ea19bf03232ab6c90c3176f1ab0388f2 (patch)
tree4e992c28bb8114ac9cbb412146f5fbcf1b42ddb1 /roles/_workstation/env/tasks
parent2a4483132d4fea880c19283c9fadfe1e4e3a1b06 (diff)
downloadinfrastructure-5d07c5c3ea19bf03232ab6c90c3176f1ab0388f2.tar.gz
sshdns: Refactor role for _workstation only
Diffstat (limited to 'roles/_workstation/env/tasks')
-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.