1 --- |
1 --- |
2 |
2 |
3 - include: dist-debian.yml |
3 - include: dist-debian.yml |
4 when: ansible_os_family == 'Debian' |
4 when: ansible_os_family == 'Debian' |
5 |
5 |
6 - include: dist-macosx.yml |
|
7 when: ansible_os_family == 'MacOSX' |
|
8 |
6 |
9 - include: dist-freebsd.yml |
|
10 when: ansible_os_family == 'FreeBSD' |
|
11 |
|
12 |
|
13 # sudo may not be everywhere. wheel is a common alternative |
|
14 - name: Enable sudo for sudo group |
|
15 lineinfile: |
|
16 dest: /etc/sudoers |
|
17 state: present |
|
18 regexp: '^%sudo' |
|
19 line: '%sudo ALL=(ALL:ALL) ALL' |
|
20 tags: sudo |
|
21 |
|
22 |
|
23 # Create/update my user, don't clobber my extra groups. |
|
24 - name: User setup |
|
25 user: |
|
26 name: "{{user.name}}" |
|
27 comment: "{{user.comment}}" |
|
28 shell: /bin/zsh |
|
29 groups: sudo |
|
30 append: true |
|
31 register: user |
|
32 tags: user |
|
33 |
|
34 |
|
35 - name: ssh | Pubkey for user |
|
36 authorized_key: |
|
37 manage_dir: true |
|
38 user: "{{user.name}}" |
|
39 key: "{{item}}" |
|
40 with_file: |
|
41 - public_keys/{{user.name}} |
|
42 tags: user, ssh |
|
43 |
|
44 - name: ssh | Ensure known_hosts keys |
|
45 become: true |
|
46 become_user: "{{user.name}}" |
|
47 lineinfile: |
|
48 dest: "{{user.home}}/.ssh/known_hosts" |
|
49 state: present |
|
50 line: "{{item.value}}" |
|
51 create: true |
|
52 mode: 0600 |
|
53 with_dict: "{{hostkeys}}" |
|
54 tags: user, ssh |
|
55 |
|
56 - name: ssh | Purge invalid known_hosts keys |
|
57 become: true |
|
58 become_user: "{{user.name}}" |
|
59 lineinfile: |
|
60 dest: "{{user.home}}/.ssh/known_hosts" |
|
61 state: absent |
|
62 line: "{{item.value}}" |
|
63 with_dict: "{{hostkeys_removed}}" |
|
64 tags: user, ssh |
|
65 |
|
66 |
|
67 # I like to make my ~ my dotfiles working directory (some folks symlink |
|
68 # everything) Here that means I clone, move hg, then checkout, clobbering any |
|
69 # conflicts with /etc/skel stuff. |
|
70 - name: Check for dotfiles checkout in homedir |
|
71 stat: path={{user.home}}/.hg |
|
72 register: dotfiles |
|
73 tags: user, dotfiles |
|
74 |
|
75 - name: Clone dotfiles |
|
76 when: dotfiles.stat.exists == false |
|
77 shell: > |
|
78 hg clone -U {{dotfiles_repository}} {{user.home}}/_dotfiles_ |
|
79 && mv {{user.home}}/_dotfiles_/.hg {{user.home}} |
|
80 && rmdir {{user.home}}/_dotfiles_ |
|
81 && chown -R {{user.name}}:{{user.group}} {{user.home}}/.hg |
|
82 && sudo -u {{user.name}} hg -R {{user.home}} update -C |
|
83 tags: user, dotfiles |
|
84 |
|
85 |
|
86 # This is an existing script that clones/updates zgen, rbenv, and plenv. |
|
87 # My dotfiles use each if the right directory exists. |
|
88 - name: Run homedir-setup |
|
89 become: true |
|
90 become_user: "{{user.name}}" |
|
91 shell: bin/homedir-setup chdir={{user.home}} |
|
92 register: homedir_setup |
|
93 changed_when: homedir_setup.stdout | match("Updating|Cloning") |
|
94 failed_when: homedir_setup.rc != 0 |
|
95 tags: user, install |
|
96 |
|
97 |
|