Wed, 13 Apr 2016 12:20:22 -0400
break out dotfiles playbook and enable agent forwarding
17 | 1 | --- |
2 | # Create/update my user, don't clobber my extra groups. | |
3 | - name: User setup | |
4 | user: | |
5 | name: "{{user.name}}" | |
6 | comment: "{{user.comment}}" | |
7 | shell: /bin/zsh | |
8 | groups: sudo | |
9 | append: true | |
10 | register: user | |
11 | tags: user | |
12 | ||
29 | 13 | - name: "ssh : Pubkey for user" |
17 | 14 | authorized_key: |
15 | manage_dir: true | |
16 | user: "{{user.name}}" | |
17 | key: "{{item}}" | |
18 | with_file: | |
19 | - public_keys/{{user.name}} | |
20 | tags: user, ssh | |
21 | ||
29 | 22 | - name: "ssh : Ensure known_hosts keys" |
17 | 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 | ||
29 | 34 | - name: "ssh : Purge invalid known_hosts keys" |
17 | 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 | |
28
6f7483dfe742
Don't need separate check
Meredith Howard <mhoward@roomag.org>
parents:
17
diff
changeset
|
55 | args: |
6f7483dfe742
Don't need separate check
Meredith Howard <mhoward@roomag.org>
parents:
17
diff
changeset
|
56 | create: "{{user.home}}/.hg" |
17 | 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}}" | |
28
6f7483dfe742
Don't need separate check
Meredith Howard <mhoward@roomag.org>
parents:
17
diff
changeset
|
65 | shell: bin/homedir-setup |
6f7483dfe742
Don't need separate check
Meredith Howard <mhoward@roomag.org>
parents:
17
diff
changeset
|
66 | args: |
6f7483dfe742
Don't need separate check
Meredith Howard <mhoward@roomag.org>
parents:
17
diff
changeset
|
67 | chdir: "{{user.home}}" |
17 | 68 | register: homedir_setup |
69 | changed_when: homedir_setup.stdout | match("Updating|Cloning") | |
70 | failed_when: homedir_setup.rc != 0 | |
71 | tags: user, install |