-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
playbook.yml
218 lines (207 loc) Β· 6.64 KB
/
playbook.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
---
- name: 'This will compute a while. Good read: https://mafinto.sh/blog/'
hosts: localhost
connection: local
become: true
tasks:
- name: Determine local username
become: false
local_action: command whoami
register: local_username
- name: Determine distribution codename
become: false
local_action: command lsb_release -cs
register: codename
- name: Create temporary directory
become: false
tempfile:
state: directory
register: tmp_dir
- block: # Utilities
- name: '[Utilities / Gimp / Gedit] Install'
apt:
name: ['build-essential', 'htop', 'iperf3', 'mosh', 'nano', 'nmap', 'nload', 'ufw', 'screen', 'tmux', 'sshfs', 'gimp', 'gedit']
update_cache: yes
- block: # VS Code
- name: '[VS Code] Get GPG key'
get_url:
url: https://packages.microsoft.com/keys/microsoft.asc
dest: '{{tmp_dir.path}}/microsoft.asc'
- name: '[VS Code] Dearmor GPG key'
command:
chdir: '{{tmp_dir.path}}'
cmd: gpg --dearmor microsoft.asc
creates: microsoft.asc.gpg
- name: '[VS Code] Ensure key dir exists'
file:
path: /etc/apt/keyrings
state: directory
- name: '[VS Code] Install GPG key'
copy:
src: '{{tmp_dir.path}}/microsoft.asc.gpg'
dest: /etc/apt/keyrings/packages.microsoft.gpg
mode: 0644
- name: '[VS Code] Add reporsitory'
apt_repository:
repo: deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main
filename: vscode
- name: '[VS Code] Install'
apt:
name: ['gnome-keyring', 'code']
update_cache: yes
- block: # NodeJS, PNPM and Yarn
- name: '[NodeJS] Add NodeJS GPG key'
apt_key:
url: http://deb.nodesource.com/gpgkey/nodesource.gpg.key
id: 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280
- name: '[NodeJS] Add NodeJS repository'
apt_repository:
repo: deb http://deb.nodesource.com/node_20.x {{codename.stdout}} main
filename: nodesource
update_cache: no
- name: '[NodeJS] Install'
apt:
name: ['nodejs']
update_cache: yes
- name: '[NodeJS] Set package root of NPM to the home directory'
become: false
lineinfile:
path: ~/.npmrc
line: prefix = ${HOME}/.npm
create: yes
- name: '[NodeJS] Create directory'
become: false
file:
path: ~/.npm/lib
state: directory
- name: '[NodeJS] Activate Corepack'
become: true
command: corepack enable
- name: '[NodeJS] Activate Yarn'
become: false
command: corepack prepare yarn@stable --activate
- name: '[NodeJS] Activate PNPM'
become: false
command: corepack prepare pnpm --activate
- name: '[NodeJS] Add NPM directory to PATH'
become: false
lineinfile:
path: ~/.bashrc
line: export PATH=$HOME/.npm/bin:$PATH
- name: '[NodeJS] Install Socket package scanner'
become: false
command: npm install -g @socketsecurity/cli
- name: '[NodeJS] Set NPM alias'
become: false
lineinfile:
path: ~/.bashrc
line: alias npm="socket-npm"
- name: '[NodeJS] Set NPX alias'
become: false
lineinfile:
path: ~/.bashrc
line: alias npx="socket-npx"
- name: '[NodeJS] Enable auto-completion'
become: false
lineinfile:
path: ~/.bashrc
line: $(complete -p npm | sed 's/npm$/socket-npm/')
- block: # Docker and Docker Compose
- name: '[Docker] Add Docker GPG key'
apt_key:
url: https://download.docker.com/linux/debian/gpg
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
- name: '[Docker] Add Docker repository'
apt_repository:
repo: deb https://download.docker.com/linux/debian {{codename.stdout}} stable
filename: docker
update_cache: no
- name: '[Docker] Install Docker'
apt: update_cache=yes name=docker-ce
- name: '[Docker] Create docker group'
group:
name: docker
state: present
- name: '[Docker] Add user to docker group'
user:
name: '{{local_username.stdout}}'
groups: docker
- name: '[Docker] Determine download URL'
shell: echo "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)"
register: docker_compose_url
- name: '[Docker] Install Docker Compose'
get_url:
url: '{{docker_compose_url.stdout}}'
mode: 0755
dest: /usr/local/bin/docker-compose
- block: # Golang
- name: '[Golang] Determine latest version'
uri:
url: https://go.dev/VERSION?m=text
return_content: yes
register: golang_version
- name: '[Golang] Set Golang version'
set_fact:
golang_version_first_line: "{{ golang_version.content.split('\n')[0] }}"
- name: '[Golang] Get tarball'
get_url:
url: 'https://go.dev/dl/{{ golang_version_first_line }}.linux-amd64.tar.gz'
dest: '{{tmp_dir.path}}'
- name: '[Golang] Extract'
unarchive:
src: '{{tmp_dir.path}}/{{ golang_version_first_line }}.linux-amd64.tar.gz'
copy: no
dest: /usr/local
- name: '[Golang] Configure `~/.bashrc`'
become: false
lineinfile:
path: ~/.bashrc
line: '{{item}}'
with_items:
- export GOROOT=/usr/local/go
- export GOPATH=$HOME/go
- export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
- block: # Rust
- name: '[Rust] Get installer'
become: false
get_url:
url: https://sh.rustup.rs
mode: 0755
dest: '{{tmp_dir.path}}/rustup-init'
- name: '[Rust] Install'
become: false
command: '{{tmp_dir.path}}/rustup-init -y'
args:
creates: ~/.rustup
- name: '[Rust] Add to PATH'
become: false
lineinfile:
path: ~/.bashrc
line: source $HOME/.cargo/env
- block: # Deno
- name: '[Deno] Get installer'
become: false
get_url:
url: https://github.com/denoland/deno/releases/latest/download/deno-x86_64-unknown-linux-gnu.zip
mode: 0755
dest: '{{tmp_dir.path}}/deno.zip'
- name: '[Deno] Create directory'
become: false
file:
path: ~/.deno/bin
state: directory
- name: '[Deno] Extract binary'
become: false
unarchive:
src: '{{tmp_dir.path}}/deno.zip'
dest: ~/.deno/bin
mode: 0755
- name: '[Deno] Add to PATH'
become: false
lineinfile:
path: ~/.bashrc
line: export PATH=$HOME/.deno/bin:$PATH
- name: Clean up
file:
path: '{{tmp_dir}}'
state: absent