roles/devbox/tasks/main.yml

Mon, 21 Sep 2015 18:49:25 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 21 Sep 2015 18:49:25 -0400
changeset 3
e84673846cd7
parent 1
18da47fe753c
child 6
0fe74156183f
permissions
-rw-r--r--

let's apply this hostkey to both the real name and alias

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
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3 - include: debian.yml
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 when: ansible_distribution == 'Debian'
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5
1
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
6
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
7 # 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
8 - name: Enable sudo for sudo group
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 lineinfile:
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 dest: /etc/sudoers
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11 state: present
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12 regexp: '^%sudo'
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13 line: '%sudo ALL=(ALL:ALL) ALL'
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14
1
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
15
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
16 # 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
17 - name: User setup
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 user:
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19 name: "{{user.name}}"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 comment: "{{user.comment}}"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21 shell: /bin/zsh
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22 groups: sudo
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23 append: true
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24 register: user
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
25
1
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
26
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
27 - name: ssh | Pubkey for user
0
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
28 authorized_key:
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
29 manage_dir: true
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
30 user: "{{user.name}}"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
31 key: "{{item}}"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
32 with_file:
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
33 - public_keys/{{user.name}}
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
34
1
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
35 - name: ssh | Ensure known_hosts keys
0
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
36 sudo: true
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
37 sudo_user: "{{user.name}}"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
38 lineinfile:
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
39 dest: "{{user.home}}/.ssh/known_hosts"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
40 state: present
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
41 line: "{{item.value}}"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
42 create: true
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
43 mode: 0600
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
44 with_dict: hostkeys
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
45
1
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
46 - name: ssh | Purge invalid known_hosts keys
0
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
47 sudo: true
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
48 sudo_user: "{{user.name}}"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
49 lineinfile:
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
50 dest: "{{user.home}}/.ssh/known_hosts"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
51 state: absent
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
52 line: "{{item.value}}"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
53 with_dict: hostkeys_removed
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
54
1
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
55
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
56 # 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
57 # 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
58 # conflicts with /etc/skel stuff.
0
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
59 - name: Check for dotfiles checkout in homedir
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
60 stat: path={{user.home}}/.hg
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
61 register: dotfiles
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
62
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
63 - name: Clone dotfiles
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
64 when: dotfiles.stat.exists == false
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
65 shell: >
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
66 hg clone -U {{dotfiles_repository}} {{user.home}}/_dotfiles_
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
67 && mv {{user.home}}/_dotfiles_/.hg {{user.home}}
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
68 && rmdir {{user.home}}/_dotfiles_
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
69 && chown -R {{user.name}}:{{user.group}} {{user.home}}/.hg
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
70 && sudo -u {{user.name}} hg -R {{user.home}} update -C
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
71
1
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
72
18da47fe753c Add some useful comments
Meredith Howard <mhoward@roomag.org>
parents: 0
diff changeset
73 # 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
74 # My dotfiles use each if the right directory exists.
0
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
75 - name: Run homedir-setup
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
76 sudo: true
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
77 sudo_user: "{{user.name}}"
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
78 shell: ./.homedir-setup.rb -su chdir={{user.home}}
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
79 register: homedir_setup
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
80 changed_when: homedir_setup.stdout | match("Updating|Installing")
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
81 failed_when: homedir_setup.rc != 0
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
82
f834f140ebad Initial commit of devbox-ansible
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
83

mercurial