/
ansible-playbook.yaml
197 lines (196 loc) · 6.13 KB
/
ansible-playbook.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
---
- name: update web servers
hosts: remote
remote_user: zed
vars:
gpg_key: E97F24B9C40898D3B46F0DC7ECDA18512085DA3C
dotfiles_repo: https://github.com/zbigniewzolnierowicz/dots/
vars_prompt:
- name: user_username
prompt: Enter username
private: no
- name: user_password
prompt: Enter password
private: yes
confirm: yes
tasks:
- name: Create user
block:
- name: Install packages
become: yes
package:
name: "{{ item }}"
state: latest
loop:
- zsh
- git
- stow
- exa
- name: Create user account
become: yes
register: created_user
user:
name: "{{ user_username }}"
password: "{{ user_password | password_hash('sha512') }}"
shell: /usr/bin/zsh
create_home: yes
- name: Get dotfiles
become_method: su
become_user: "{{ created_user.name }}"
git:
repo: "{{ dotfiles_repo }}"
dest: "{{ created_user.home }}/dots"
rescue:
- name: Remove dotfiles
file:
path: "{{ created_user.home }}/dots"
state: absent
- name: Get dotfiles
become_method: su
become_user: "{{ created_user.name }}"
git:
repo: "{{ dotfiles_repo }}"
dest: "{{ created_user.home }}/dots"
- name: Install zplug
block:
- name: Download zplug
become_method: su
become_user: "{{ created_user.name }}"
get_url:
url: "https://raw.githubusercontent.com/zplug/installer/master/installer.zsh"
dest: "{{ created_user.home }}/zplug_installer.zsh"
- name: Install zplug
become_method: su
become_user: "{{ created_user.name }}"
git:
repo: https://github.com/zplug/zplug
dest: "{{ created_user.home }}/.zplug"
- name: Remove zplug installer
file:
path: "{{ created_user.home }}/zplug_installer.zsh"
state: absent
- name: Link dotfiles
shell: "cd {{ created_user.home }}/dots; stow zsh"
rescue:
- name: Remove zplug installer
file:
path: "{{ created_user.home }}/zplug_installer.zsh"
state: absent
- name: Unstow zsh
shell: "cd {{ created_user.home }}/dots; stow -D zsh"
- name: Install yay
block:
- name: Download yay
become_method: su
become_user: "{{ created_user.name }}"
git:
repo: https://aur.archlinux.org/yay.git
dest: "{{ created_user.home }}/yay"
- name: Install yay
become_method: su
become_user: "{{ created_user.name }}"
shell: "cd {{ created_user.home }}/yay; makepkg -si --noconfirm --needed"
rescue:
- name: Remove yay install dir
become: yes
file:
path: "{{ created_user.home }}/yay"
state: absent
- name: Configure GnuPG
block:
- name: Install packages
become: yes
package:
name: "{{ item }}"
state: latest
loop:
- gnupg
- opensc
- ccid
- pcsc-tools
- name: Start SmartCard daemon
become: yes
service:
name: pcscd
enabled: yes
state: started
- name: Add GPG key
become_method: su
become_user: "{{ created_user.name }}"
shell: "gpg --recv-keys {{ gpg_key }}"
- name: Update GPG config
become_method: su
become_user: "{{ created_user.name }}"
get_url:
url: "https://raw.githubusercontent.com/drduh/config/master/gpg.conf"
dest: "{{ created_user.home }}/.gnupg/gpg.conf"
- name: Install Neovim
block:
- name: Install package
become: yes
package:
name: neovim
state: latest
- name: Install vim-plug
shell: |
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
- name: Link dotfiles
shell: "cd {{ created_user.home }}/dots; stow neovim"
rescue:
- name: Unlink dotfiles
shell: "cd {{ created_user.home }}/dots; stow -D neovim"
- name: Install Alacritty
block:
- name: Install package
become: yes
package:
name: alacritty
state: latest
- name: Link dotfiles
shell: "cd {{ created_user.home }}/dots; stow alacritty"
rescue:
- name: Unlink dotfiles
shell: "cd {{ created_user.home }}/dots; stow -D alacritty"
- name: Install bspwm and sxhkd
block:
- name: Install packages
become: yes
package:
name: "{{ item }}"
state: latest
loop:
- bspwm
- sxhkd
- picom
- wmname
- xorg-xbacklight
- xorg-xsetroot
- xorg-xinit
- xorg-server
- xorg-xrandr
- xorg-xrdb
- arandr
- feh
- udisks2
- udiskie
- dunst
- maim
- slop
- rofi
- pulseaudio
- pulsemixer
- nodejs
- yarn
- ttf-jetbrains-mono
- otf-font-awesome
- name: Install apps from AUR
shell: "yay -Su {{ item }} --noconfirm --needed"
loop:
- polybar
- cherry-font-git
- name: Link dotfiles
shell: "cd {{ created_user.home }}/dots; stow bspwm"
rescue:
- name: Unlink dotfiles
shell: "cd {{ created_user.home }}/dots; stow -D bspwm"