-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yml
More file actions
237 lines (210 loc) · 6.71 KB
/
playbook.yml
File metadata and controls
237 lines (210 loc) · 6.71 KB
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
---
- hosts: localhost
connection: local
become: false
gather_facts: true
roles:
- role: wsl_colours
become: false
tasks:
# Azure CLI - Official Installation Script
# https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux#option-1-install-with-one-command
- name: Install Azure CLI using official Microsoft script
become: true
ansible.builtin.shell: |
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
args:
creates: /usr/bin/az
# HashiCorp Tools - Terraform and Packer
# https://www.hashicorp.com/official-packaging-guide
- name: Install HashiCorp GPG key
become: true
ansible.builtin.shell: |
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
args:
creates: /usr/share/keyrings/hashicorp-archive-keyring.gpg
- name: Remove old HashiCorp .list format if exists
become: true
ansible.builtin.file:
path: /etc/apt/sources.list.d/hashicorp.list
state: absent
- name: Remove old HashiCorp .asc keyring
become: true
ansible.builtin.file:
path: /usr/share/keyrings/hashicorp-archive-keyring.asc
state: absent
- name: Add HashiCorp repository (DEB822 format)
become: true
ansible.builtin.copy:
dest: /etc/apt/sources.list.d/hashicorp.sources
mode: '0644'
content: |
Types: deb
URIs: https://apt.releases.hashicorp.com
Suites: {{ ansible_distribution_release }}
Components: main
Signed-By: /usr/share/keyrings/hashicorp-archive-keyring.gpg
- name: Install Terraform and Packer
become: true
ansible.builtin.apt:
name:
- terraform
- packer
state: present
update_cache: yes
# wslu - WSL Utilities
# https://github.com/wslutilities/wslu
- name: Remove orphaned wslu keyring (PPA manages its own)
become: true
ansible.builtin.file:
path: /usr/share/keyrings/wslutilities-archive-keyring.gpg
state: absent
- name: Add wslu PPA
become: true
ansible.builtin.shell: |
add-apt-repository -y ppa:wslutilities/wslu
args:
creates: /etc/apt/sources.list.d/wslutilities-ubuntu-wslu-{{ ansible_distribution_release }}.sources
- name: Install wslu
become: true
ansible.builtin.apt:
name: wslu
state: present
update_cache: yes
- name: Create WSL Interop fix systemd service
become: true
ansible.builtin.copy:
content: |
[Unit]
Description=Fix WSL Interop naming conflict for wslu utilities
After=systemd-binfmt.service
Wants=systemd-binfmt.service
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo ":WSLInterop:M::MZ::/init:P" | tee /proc/sys/fs/binfmt_misc/register'
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/wsl-interop-fix.service
mode: '0644'
- name: Enable and start WSL Interop fix service
become: true
ansible.builtin.systemd:
name: wsl-interop-fix.service
enabled: yes
state: started
daemon_reload: yes
- name: Enable passwordless sudo
become: true
ansible.builtin.lineinfile:
path: /etc/sudoers.d/group
state: present
create: true
owner: root
group: root
mode: 440
regexp: '^%sudo'
line: '%sudo ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'
- name: Base utility packages
become: true
ansible.builtin.apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- git
- jq
- jp
- tree
- figlet
- stress
- speedtest-cli
- hugo
- aha
- unzip
- name: Ansible .bashrc - root customisations
become: true
ansible.builtin.blockinfile:
path: ~/.bashrc
block: |
export EDITOR=vi
alias ll='ls -l'
set -o vi
- name: Ansible .bashrc - jwt()
ansible.builtin.blockinfile:
path: ~richeney/.bashrc
block: |
{% raw %}
# Decode JWT tokens
_decode_base64_url() {
local len=$((${#1} % 4))
local result="$1"
if [ $len -eq 2 ]; then result="$1"'=='
elif [ $len -eq 3 ]; then result="$1"'='
fi
echo "$result" | tr '_-' '/+' | base64 -d
}
# $1 => JWT to decode
# $2 => either 1 for header or 2 for body (default is 2)
jwt() { _decode_base64_url $(echo -n $1 | cut -d "." -f ${2:-2}) | jq .; }
{% endraw %}
marker: "# <!-- {mark} of Ansible automated JWT function -->"
marker_begin: Start
marker_end: End
backup: yes
- name: Ansible .bashrc - user customisations
ansible.builtin.blockinfile:
path: ~richeney/.bashrc
block: "{{ lookup('file', 'bashrc_user_customisations') }}"
marker: "# <!-- {mark} of Ansible automated user customisations -->"
marker_begin: Start
marker_end: End
backup: yes
- name: /git
become: true
ansible.builtin.file:
path: /git
state: directory
mode: '0755'
owner: richeney
group: richeney
- name: Git config
ansible.builtin.copy:
dest: ~richeney/.gitconfig
owner: richeney
group: richeney
mode: 0644
content: |
[user]
email = richeney@microsoft.com
name = Richard Cheney
[credential]
user = richeney
helper = store
[init]
defaultBranch = main
# Node.js via nvm and GitHub Copilot CLI
- name: Install nvm (Node Version Manager)
ansible.builtin.shell: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
args:
creates: ~/.nvm/nvm.sh
- name: Install Node.js LTS via nvm
ansible.builtin.shell: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install --lts
nvm alias default lts/*
args:
executable: /bin/bash
creates: ~/.nvm/alias/default
- name: Install GitHub Copilot CLI
ansible.builtin.shell: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npm install -g @github/copilot@latest
args:
executable: /bin/bash
creates: ~/.nvm/versions/node/*/bin/github-copilot-cli