fix become setup

Thu, 15 Jun 2017 20:43:24 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Thu, 15 Jun 2017 20:43:24 -0400
changeset 69
292cb125556d
parent 68
539425ad28ce
child 70
04beed510fa3

fix become setup

local.yml file | annotate | diff | comparison | revisions
roles/user/tasks/main.yml file | annotate | diff | comparison | revisions
--- a/local.yml
+++ b/local.yml
@@ -1,7 +1,6 @@
 ---
 - name: Devbox Setup
   hosts: all
-  become: yes
   roles:
     - devbox
     - user
--- a/roles/user/tasks/main.yml
+++ b/roles/user/tasks/main.yml
@@ -20,21 +20,23 @@
   tags: user, ssh
 
 - name: Clone dotfiles
-  become: "{{user_name}}"
+  become: true
+  become_user: "{{user_name}}"
   shell: >
     hg clone -U {{dotfiles_default | quote}} _dotfiles_
     && mv _dotfiles_/.hg .
     && rmdir _dotfiles_
     && hg -R ~ update -C master
   args:
-    chdir: "~"
-    creates: "~/.hg"
+    chdir: "{{user.home}}"
+    creates: "{{user.home}}/.hg"
   tags: user, dotfiles
 
 - name: Assert hg sources
-  become: "{{user_name}}"
+  become: true
+  become_user: "{{user_name}}"
   ini_file:
-    dest: "~/.hg/hgrc"
+    dest: "{{user.home}}/.hg/hgrc"
     section: paths
     option: "{{item.name}}"
     value:  "{{item.url}}"
@@ -46,20 +48,22 @@
   tags: user, dotfiles
 
 - name: Update dotfiles
-  become: "{{user_name}}"
+  become: true
+  become_user: "{{user_name}}"
   command: hg pull -u
   args:
-    chdir: "~"
+    chdir: "{{user.home}}"
   register: update_dotfiles
   changed_when: update_dotfiles.stdout | match("added|updated")
   failed_when: update_dotfiles.rc > 1
   tags: user, dotfiles
 
 - name: Run bin/homedir-setup
-  become: "{{user_name}}"
+  become: true
+  become_user: "{{user_name}}"
   shell: bin/homedir-setup
   args:
-    chdir: "~"
+    chdir: "{{user.home}}"
   register: homedir_setup
   changed_when: homedir_setup.stdout | match("Updating|Cloning")
   failed_when: homedir_setup.rc != 0

mercurial