roles/user/tasks/main.yml

changeset 36
745c6a77bf68
parent 29
9b3befb1c773
child 50
8be666ca059e
equal deleted inserted replaced
35:5da50e754d33 36:745c6a77bf68
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: "ssh : Ensure known_hosts keys"
23 become: true
24 become_user: "{{user.name}}"
25 lineinfile:
26 dest: "{{user.home}}/.ssh/known_hosts"
27 state: present
28 line: "{{item.value}}"
29 create: true
30 mode: 0600
31 with_dict: "{{hostkeys}}"
32 tags: user, ssh
33
34 - name: "ssh : Purge invalid known_hosts keys"
35 become: true
36 become_user: "{{user.name}}"
37 lineinfile:
38 dest: "{{user.home}}/.ssh/known_hosts"
39 state: absent
40 line: "{{item.value}}"
41 with_dict: "{{hostkeys_removed}}"
42 tags: user, ssh
43
44
45 # I like to make my ~ my dotfiles working directory (some folks symlink
46 # everything) Here that means I clone, move hg, then checkout, clobbering any
47 # conflicts with /etc/skel stuff.
48 - name: Clone dotfiles
49 shell: >
50 hg clone -U {{dotfiles_repository}} {{user.home}}/_dotfiles_
51 && mv {{user.home}}/_dotfiles_/.hg {{user.home}}
52 && rmdir {{user.home}}/_dotfiles_
53 && chown -R {{user.name}}:{{user.group}} {{user.home}}/.hg
54 && sudo -u {{user.name}} hg -R {{user.home}} update -C
55 args:
56 create: "{{user.home}}/.hg"
57 tags: user, dotfiles
58
59
60 # This is an existing script that clones/updates zgen, rbenv, and plenv.
61 # My dotfiles use each if the right directory exists.
62 - name: Run homedir-setup
63 become: true
64 become_user: "{{user.name}}"
65 shell: bin/homedir-setup
66 args:
67 chdir: "{{user.home}}"
68 register: homedir_setup
69 changed_when: homedir_setup.stdout | match("Updating|Cloning")
70 failed_when: homedir_setup.rc != 0
71 tags: user, install

mercurial