From 9cc8b2e915114c846014f9aa10acf04a2d35c2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Thu, 8 Feb 2018 21:44:41 +0100 Subject: [PATCH] Always work on current user, no hardcoding --- playbook.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/playbook.yml b/playbook.yml index fc27575..23b5510 100644 --- a/playbook.yml +++ b/playbook.yml @@ -2,16 +2,19 @@ connection: local become: false tasks: + - set_fact: + user: "{{ ansible_user_id }}" + - name: configure sudoers lineinfile: path: /etc/sudoers - line: hannes ALL=(ALL) NOPASSWD:ALL - regexp: '^hannes\s+' + line: "{{ user }} ALL=(ALL) NOPASSWD:ALL" + regexp: "^{{ user }}\\s+" become: true - name: set shell user: - name: hannes + name: "{{ user }}" shell: /usr/bin/zsh become: true