aboutsummaryrefslogblamecommitdiffstats
path: root/roles/_workstation/env/tasks/main.yml
blob: 757592296fd5a5238b6c73a64b0ef7d96068b8a8 (plain) (tree)
1
2
3
4
5
6
7
8



                                   



                                          






                                             




                                           



                                                                                             
                                         
- name: retrieve BECOME method
  stat: path=/usr/bin/doas 
  register: _workstation_env_become

- name: retrieve existing users
  shell: cat /etc/passwd | cut -d ":" -f 1
  register: result

- name: retrieve current user
  shell: whoami
  register: result_

- set_fact:
    _ws_user: "{{ result_.stdout_lines[0] }}"

- 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: "{{ _ws_user }}"
remember that computers suck.