roles/devbox/tasks/main.yml

Sat, 19 Mar 2016 03:38:09 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 19 Mar 2016 03:38:09 -0400
changeset 13
42977b3af38d
parent 11
8e5dcc6e199a
child 15
8331067f9c8c
permissions
-rw-r--r--

empty freebsd

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
0fe74156183f add tags
Meredith Howard <mhoward@roomag.org>
parents: 1
diff changeset
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
0fe74156183f add tags
Meredith Howard <mhoward@roomag.org>
parents: 1
diff changeset
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
0fe74156183f add tags
Meredith Howard <mhoward@roomag.org>
parents: 1
diff changeset
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
11
8e5dcc6e199a sudo deprecated for 'become'
Meredith Howard <mhoward@roomag.org>
parents: 10
diff changeset
45 become: true
8e5dcc6e199a sudo deprecated for 'become'
Meredith Howard <mhoward@roomag.org>
parents: 10
diff changeset
46 become_user: "{{user.name}}"
0
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
0fe74156183f add tags
Meredith Howard <mhoward@roomag.org>
parents: 1
diff changeset
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
11
8e5dcc6e199a sudo deprecated for 'become'
Meredith Howard <mhoward@roomag.org>
parents: 10
diff changeset
57 become: true
8e5dcc6e199a sudo deprecated for 'become'
Meredith Howard <mhoward@roomag.org>
parents: 10
diff changeset
58 become_user: "{{user.name}}"
0
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
0fe74156183f add tags
Meredith Howard <mhoward@roomag.org>
parents: 1
diff changeset
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
0fe74156183f add tags
Meredith Howard <mhoward@roomag.org>
parents: 1
diff changeset
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
0fe74156183f add tags
Meredith Howard <mhoward@roomag.org>
parents: 1
diff changeset
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
11
8e5dcc6e199a sudo deprecated for 'become'
Meredith Howard <mhoward@roomag.org>
parents: 10
diff changeset
86 # This is an existing script that clones/updates zgen, rbenv, and plenv.
1
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
11
8e5dcc6e199a sudo deprecated for 'become'
Meredith Howard <mhoward@roomag.org>
parents: 10
diff changeset
89 become: true
8e5dcc6e199a sudo deprecated for 'become'
Meredith Howard <mhoward@roomag.org>
parents: 10
diff changeset
90 become_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
0fe74156183f add tags
Meredith Howard <mhoward@roomag.org>
parents: 1
diff changeset
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

mercurial