-
Notifications
You must be signed in to change notification settings - Fork 4
/
ansible-ubuntu.yml
183 lines (167 loc) · 5.6 KB
/
ansible-ubuntu.yml
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
# This ansible playbook configures remote ubuntu 22.04 machines on AWS as basic
# development machines. I mostly develop on macOS, but some stuff needs linux.
- hosts: all
vars:
go_path: '~/src/github.com/golang/go'
go_version: go1.22.1
duckdb_version: v0.10.1
node_version: v20.11.1
tasks:
- name: update apt
tags: [apt]
become: true
apt:
update_cache: yes
cache_valid_time: 3600
- name: add neovim apt repo
tags: [apt]
become: true
apt_repository:
repo: ppa:neovim-ppa/unstable
- name: install apt packages
tags: [apt]
become: true
apt:
pkg:
- atop # great overall system monitoring tool
- bpftrace # dtrace is dead, long live dtrace
- build-essential # gcc toolchain
- curl # needed for docker
- errno # view C error codes
- fzf # fuzzy finder
- gdb # debugger
- golang-go # bootstrap Go, other versions are installed below
- graphviz # visualize graphs, needed for pprof
- linux-tools-aws # linux perf
- linux-tools-common # linux perf
- make # build system
- neovim # good editor
- ripgrep # fast search
- systemtap # bpftrace's older brother
- tmux # session multiplexer
- unzip # decompression
- htop # htop
- name: check if docker is already installed
tags: [docker]
command: which docker
register: docker_installed
failed_when: docker_installed.rc == 1
ignore_errors: true
changed_when: false
- name: install docker deps
tags: [docker]
become: true
apt:
pkg:
- gpg # crypto stuff
- gnupg # needed for docker
- ca-certificates # needed for docker
when: docker_installed.failed
- name: add docker GPG apt key
tags: [docker]
become: true
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
when: docker_installed.failed
- name: add docker apt repo
tags: [docker]
become: true
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu jammy stable
when: docker_installed.failed
- name: install docker
tags: [docker]
become: true
apt:
name: docker-ce
state: latest
when: docker_installed.failed
- name: Create nvim config directory
tags: [nvim]
file:
path: '~/.config/nvim/'
state: directory
- name: Create nvim config
tags: [nvim]
copy:
src: 'nvim-ubuntu/init.lua'
dest: '~/.config/nvim/init.lua'
- name: Create gdb config
tags: [gdb]
copy:
src: 'nvim-ubuntu/gdbinit'
dest: '~/.gdbinit'
- name: install node.js
tags: [nodejs]
shell: |
case "$(uname -m)" in
x86_64) arch="x64" ;;
arm64|aarch64) arch="arm64" ;;
*) arch="unknown" ;;
esac
node_dir="node-{{node_version}}-linux-$arch"
node_tar="${node_dir}.tar.xz"
curl -L "https://nodejs.org/dist/{{node_version}}/$node_tar" -O
tar -xvf "$node_tar"
sudo mv "$node_dir" /usr/local/nodejs
- name: Configure bashrc
tags: [bashrc]
blockinfile:
insertbefore: BOF
path: '~/.bashrc'
block: |
export EDITOR="$(which nvim)"
PATH="$HOME/go/bin:/usr/local/nodejs/bin:$PATH"
alias vim="$(which nvim)"
cl() {
cloned=$(command cl -dir "$HOME/src" "$1")
cd "$cloned"
}
# fzf key bindings
source /usr/share/doc/fzf/examples/key-bindings.bash
- name: Disable NMI watchdog (so perf stat can report branch misses)
tags: [nmi]
become: true
shell: 'echo 0 > /proc/sys/kernel/nmi_watchdog'
ignore_errors: yes # only works on bare metal instances
- name: install {{ go_version }}
tags: [go]
shell: "bash -lc 'go install golang.org/dl/{{ go_version }}@latest && {{ go_version }} download' && ln -s $(which {{ go_version }}) && go env -w GOTOOLCHAIN={{ go_version }}+auto"
args:
executable: /bin/bash
- name: install go packages
tags: [goinstall]
command: "{{ go_version }} install {{ item }}"
with_items:
- github.com/boyter/scc/v3@latest # count lines of code
- github.com/felixge/cl@latest # git clone helper
- github.com/go-delve/delve/cmd/dlv@latest # debugger
- github.com/goreleaser/goreleaser@latest # release go apps
- github.com/maruel/panicparse/v2@latest # analyze go stack traces
- github.com/spf13/cobra-cli@latest # cli scaffold generator
- github.com/x-motemen/gore/cmd/gore@latest # repl
- golang.org/x/perf/cmd/benchstat@latest # benchmark analysis
- golang.org/x/review/git-codereview@latest # for contributing to go
- golang.org/x/tools/cmd/go-contrib-init@latest # for contributing to go
- gotest.tools/gotestsum@latest # pretty test output
- name: Schedule a cron job to shut down the machine at midnight
tags: [cron]
become: true
cron:
name: "Shutdown machine at midnight"
cron_file: "shutdown_midnight"
minute: "0"
hour: "0"
user: "root"
job: "/sbin/shutdown -h now"
when: "'EC2' in ansible_facts['system_vendor']"
- name: install duckdb
tags: [duckdb]
shell: |
arch=$(uname -m) && [ "$arch" = "x86_64" ] && url="https://github.com/duckdb/duckdb/releases/download/{{ duckdb_version }}/duckdb_cli-linux-amd64.zip" || url="https://github.com/duckdb/duckdb/releases/download/{{ duckdb_version }}/duckdb_cli-linux-aarch64.zip"; curl -L $url -o duckdb.zip && unzip -f duckdb.zip -d ~/go/bin/ && rm duckdb.zip
- name: install clickhouse
tags: [clickhouse]
shell: |
curl https://clickhouse.com/ | sh
sudo ./clickhouse install