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