roles/devbox/tasks/main.yml

Sat, 13 Feb 2016 23:33:26 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 13 Feb 2016 23:33:26 -0500
changeset 8
b2d82cd36d68
parent 6
0fe74156183f
child 10
ee86092e374a
permissions
-rw-r--r--

update for new homedir-setup

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

mercurial