Always work on current user, no hardcoding
This commit is contained in:
@@ -2,16 +2,19 @@
|
|||||||
connection: local
|
connection: local
|
||||||
become: false
|
become: false
|
||||||
tasks:
|
tasks:
|
||||||
|
- set_fact:
|
||||||
|
user: "{{ ansible_user_id }}"
|
||||||
|
|
||||||
- name: configure sudoers
|
- name: configure sudoers
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /etc/sudoers
|
path: /etc/sudoers
|
||||||
line: hannes ALL=(ALL) NOPASSWD:ALL
|
line: "{{ user }} ALL=(ALL) NOPASSWD:ALL"
|
||||||
regexp: '^hannes\s+'
|
regexp: "^{{ user }}\\s+"
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: set shell
|
- name: set shell
|
||||||
user:
|
user:
|
||||||
name: hannes
|
name: "{{ user }}"
|
||||||
shell: /usr/bin/zsh
|
shell: /usr/bin/zsh
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user