roles/user/tasks/main.yml

changeset 57
6172fc31a08f
parent 54
2a04e6d7bfcc
child 63
f49b84e25dcc
equal deleted inserted replaced
56:b5103023562e 57:6172fc31a08f
1 --- 1 ---
2 # Create/update my user, don't clobber my extra groups. 2 # Create/update my user, don't clobber my extra groups.
3 - name: User setup 3 - name: User setup
4 user: 4 user:
5 name: "{{user.name}}" 5 name: "{{user_name}}"
6 comment: "{{user.comment}}" 6 comment: "{{user_comment}}"
7 shell: /bin/zsh 7 shell: /bin/zsh
8 groups: sudo 8 groups: sudo
9 append: true 9 append: true
10 register: user 10 register: user
11 tags: user 11 tags: user
12 12
13 - name: "ssh : Pubkey for user" 13 - name: "ssh : Pubkey for user"
14 authorized_key: 14 authorized_key:
15 manage_dir: true 15 manage_dir: true
16 user: "{{user.name}}" 16 user: "{{user_name}}"
17 key: "{{item}}" 17 key: "{{item}}"
18 with_file: 18 with_file:
19 - public_keys/{{user.name}} 19 - public_keys/{{user_name}}
20 tags: user, ssh 20 tags: user, ssh
21 21
22 - name: Clone dotfiles 22 - name: Clone dotfiles
23 become: "{{user.name}}" 23 become: "{{user_name}}"
24 shell: > 24 shell: >
25 hg clone -U {{dotfiles_default | quote}} _dotfiles_ 25 hg clone -U {{dotfiles_default | quote}} _dotfiles_
26 && mv _dotfiles_/.hg . 26 && mv _dotfiles_/.hg .
27 && rmdir _dotfiles_ 27 && rmdir _dotfiles_
28 && hg -R ~ update -C master 28 && hg -R ~ update -C master
29 args: 29 args:
30 chdir: "~" 30 chdir: "~"
31 creates: "~/.hg" 31 creates: "~/.hg"
32 32
33 - name: Assert hg sources 33 - name: Assert hg sources
34 become: "{{user.name}}" 34 become: "{{user_name}}"
35 ini_file: 35 ini_file:
36 dest: "~/.hg/hgrc" 36 dest: "~/.hg/hgrc"
37 section: paths 37 section: paths
38 option: "{{item.name}}" 38 option: "{{item.name}}"
39 value: "{{item.url}}" 39 value: "{{item.url}}"
42 with_items: 42 with_items:
43 - {name: 'default', url: "{{dotfiles_default}}"} 43 - {name: 'default', url: "{{dotfiles_default}}"}
44 - {name: 'default-push', url: "{{dotfiles_default_push}}"} 44 - {name: 'default-push', url: "{{dotfiles_default_push}}"}
45 45
46 - name: Update dotfiles 46 - name: Update dotfiles
47 become: "{{user.name}}" 47 become: "{{user_name}}"
48 command: hg pull -u 48 command: hg pull -u
49 args: 49 args:
50 chdir: "~" 50 chdir: "~"
51 register: update_dotfiles 51 register: update_dotfiles
52 changed_when: update_dotfiles.stdout | match("added|updated") 52 changed_when: update_dotfiles.stdout | match("added|updated")
53 failed_when: update_dotfiles.rc > 1 53 failed_when: update_dotfiles.rc > 1
54 54
55 - name: Run bin/homedir-setup 55 - name: Run bin/homedir-setup
56 become: "{{user.name}}" 56 become: "{{user_name}}"
57 shell: bin/homedir-setup 57 shell: bin/homedir-setup
58 args: 58 args:
59 chdir: "~" 59 chdir: "~"
60 register: homedir_setup 60 register: homedir_setup
61 changed_when: homedir_setup.stdout | match("Updating|Cloning") 61 changed_when: homedir_setup.stdout | match("Updating|Cloning")

mercurial