roles/devbox/tasks/main.yml

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

mercurial