From 5d07c5c3ea19bf03232ab6c90c3176f1ab0388f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Mon, 3 May 2021 20:21:31 +0200 Subject: sshdns: Refactor role for _workstation only --- roles/_workstation/env/tasks/main.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'roles/_workstation/env') 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 }}" -- cgit v1.2.3