Skip to content

Commit e1a1699

Browse files
fix: add better security guarentees
1 parent 623a74c commit e1a1699

10 files changed

Lines changed: 96 additions & 44 deletions

File tree

.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ ansible-playbook scripts/ansible/playbook.yml -c local
6161

6262
- Edit source `dot_*` files and `*.tmpl` templates. Examples: `dot_bashrc`, `dot_config/nvim/init.lua.tmpl`.
6363
- Avoid editing rendered/user files on remote machines; those are managed by chezmoi and will be overwritten.
64+
- **Avoid allowing Ansible to modify dotfiles (e.g. via `lineinfile` or `blockinfile`) as these are managed by chezmoi.** If a tool requires configuration in a dotfile, add the logic to the `dot_` source file itself (using templates or conditionals if necessary) rather than having Ansible patch it post-creation.
6465
- If you change package lists or provisioning logic, update `scripts/ansible/playbook.yml` and corresponding `roles/` implementations.
6566
- Under no circumstances should unsigned commits be created, if GPG signing fails then defer to the user to resolve.
6667

scripts/ansible/roles/foundry/tasks/main.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,25 @@
1616
path: "{{ ansible_env.HOME }}/.foundry/bin/foundryup"
1717
register: foundryup_stat
1818

19-
- name: Download and install Foundry
20-
shell: "curl -L https://foundry.paradigm.xyz | bash"
19+
- name: Download Foundry installer
20+
get_url:
21+
url: "https://foundry.paradigm.xyz"
22+
dest: "/tmp/foundry_install.sh"
23+
mode: '0755'
24+
when: not foundryup_stat.stat.exists
25+
26+
- name: Run Foundry installer
27+
command: "/bin/bash /tmp/foundry_install.sh"
2128
args:
2229
creates: "{{ ansible_env.HOME }}/.foundry/bin/foundryup"
2330
when: not foundryup_stat.stat.exists
2431

32+
- name: Remove Foundry installer
33+
file:
34+
path: "/tmp/foundry_install.sh"
35+
state: absent
36+
when: not foundryup_stat.stat.exists
37+
2538
- name: Initialize Foundry
2639
shell: "{{ ansible_env.HOME }}/.foundry/bin/foundryup"
2740
args:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
nvm_version: "v0.40.3"
3+
nvm_install_url: "https://raw.githubusercontent.com/nvm-sh/nvm/{{ nvm_version }}/install.sh"
4+
nvm_install_checksum: "sha256:2d8359a64a3cb07c02389ad88ceecd43f2fa469c06104f92f98df5b6f315275f"
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
---
2+
- name: Download nvm installer
3+
ansible.builtin.get_url:
4+
url: "{{ nvm_install_url }}"
5+
dest: "/tmp/nvm_install.sh"
6+
mode: '0755'
7+
checksum: "{{ nvm_install_checksum }}"
8+
29
- name: Install nvm
310
ansible.builtin.shell: >
4-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
11+
/tmp/nvm_install.sh
512
args:
613
creates: "{{ ansible_facts['env'].HOME }}/.nvm/nvm.sh"
14+
15+
- name: Remove nvm installer
16+
ansible.builtin.file:
17+
path: "/tmp/nvm_install.sh"
18+
state: absent

scripts/ansible/roles/oh-my-posh/defaults/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ oh_my_posh_arch_map:
77
aarch64: "arm64"
88
riscv64: "riscv64"
99

10+
oh_my_posh_version: "v29.0.1"
11+
12+
oh_my_posh_checksums:
13+
amd64: "sha256:57088003d36ab5089de45c0ff3d6a713fabeff4668c165c7ac50042ed8c9abaf"
14+
# Add other architectures' checksums here when needed
15+
1016
oh_my_posh_arch: "{{ oh_my_posh_arch_map[ansible_architecture] | default('amd64') }}"
17+
oh_my_posh_checksum: "{{ oh_my_posh_checksums[oh_my_posh_arch] | default(omit) }}"
1118
oh_my_posh_supported_architectures:
1219
- x86_64
1320
- aarch64

scripts/ansible/roles/oh-my-posh/tasks/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
- name: Download Oh My Posh binary
1818
ansible.builtin.get_url:
19-
url: "https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-{{ oh_my_posh_arch }}"
19+
url: "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/{{ oh_my_posh_version }}/posh-linux-{{ oh_my_posh_arch }}"
2020
dest: "{{ oh_my_posh_bin_path }}"
2121
mode: '0755'
22+
checksum: "{{ oh_my_posh_checksum | default(omit) }}"
2223
become: true
2324

2425
- name: Verify Oh My Posh installation
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
tmux_version: "3.6a"
3+
tmux_checksum: "sha256:b6d8d9c76585db8ef5fa00d4931902fa4b8cbe8166f528f44fc403961a3f3759"

scripts/ansible/roles/tmux/tasks/main.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,17 @@
1717
state: present
1818
when: ansible_facts['os_family'] == "Debian"
1919

20-
- name: Get latest tmux release info
21-
uri:
22-
url: "https://api.github.com/repos/tmux/tmux/releases/latest"
23-
return_content: true
24-
register: github_response
25-
26-
- name: Extract latest tarball URL
27-
set_fact:
28-
tmux_tarball_url: "{{ github_response.json.tarball_url }}"
29-
tmux_version: "{{ github_response.json.tag_name }}"
30-
31-
- name: Debug - Show latest tmux version
32-
debug:
33-
msg: "Latest tmux version: {{ tmux_version }}"
34-
3520
- name: Create source directory
3621
file:
3722
path: "{{ tmux_src_dir }}"
3823
state: directory
3924
mode: "0755"
4025

41-
- name: Download latest tmux source code
26+
- name: Download tmux source code
4227
get_url:
43-
url: "{{ tmux_tarball_url }}"
28+
url: "https://github.com/tmux/tmux/releases/download/{{ tmux_version }}/tmux-{{ tmux_version }}.tar.gz"
4429
dest: "{{ tmux_src_dir }}/tmux.tar.gz"
30+
checksum: "{{ tmux_checksum }}"
4531

4632
- name: Extract tmux source
4733
ansible.builtin.unarchive:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
uv_version: "0.9.22"
3+
uv_platform: "x86_64-unknown-linux-gnu"
4+
uv_download_url: "https://github.com/astral-sh/uv/releases/download/{{ uv_version }}/uv-{{ uv_platform }}.tar.gz"
5+
uv_checksum: "sha256:e170aed70ac0225feee612e855d3a57ae73c61ffb22c7e52c3fd33b87c286508"
6+
uv_install_dir: "{{ ansible_env.HOME }}/.local/bin"

scripts/ansible/roles/uv/tasks/main.yml

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,53 @@
55
ignore_errors: true
66
changed_when: false
77

8-
- name: Install uv using the official standalone installer
9-
shell: "curl -fsSL {{ uv_install_script_url }} | sh"
10-
register: uv_install_result
11-
when: uv_check.rc != 0
12-
environment:
13-
UV_INSTALL_DIR: "{{ ansible_env.HOME }}/.local/bin"
14-
args:
15-
executable: /bin/bash
16-
17-
- name: Add uv shell completion for zsh
18-
lineinfile:
19-
path: "{{ ansible_env.HOME }}/.zshrc"
20-
line: 'eval "$(uv generate-shell-completion zsh)"'
21-
create: true
22-
when: uv_check.rc == 0 or uv_install_result.changed
23-
24-
- name: Add uv shell completion for bash
25-
lineinfile:
26-
path: "{{ ansible_env.HOME }}/.bashrc"
27-
line: 'eval "$(uv generate-shell-completion bash)"'
28-
create: true
29-
when: uv_check.rc == 0 or uv_install_result.changed
8+
- name: Create temporary directory for uv download
9+
tempfile:
10+
state: directory
11+
suffix: uv_download
12+
register: uv_temp_dir
13+
when: uv_check.rc != 0 or uv_version not in uv_check.stdout
14+
15+
- name: Download uv tarball
16+
get_url:
17+
url: "{{ uv_download_url }}"
18+
dest: "{{ uv_temp_dir.path }}/uv.tar.gz"
19+
checksum: "{{ uv_checksum }}"
20+
mode: '0644'
21+
when: uv_check.rc != 0 or uv_version not in uv_check.stdout
22+
23+
- name: Extract uv tarball
24+
unarchive:
25+
src: "{{ uv_temp_dir.path }}/uv.tar.gz"
26+
dest: "{{ uv_temp_dir.path }}"
27+
remote_src: true
28+
when: uv_check.rc != 0 or uv_version not in uv_check.stdout
29+
30+
- name: Install uv binary
31+
copy:
32+
src: "{{ uv_temp_dir.path }}/uv-{{ uv_platform }}/uv"
33+
dest: "{{ uv_install_dir }}/uv"
34+
mode: '0755'
35+
when: uv_check.rc != 0 or uv_version not in uv_check.stdout
36+
37+
- name: Install uvx binary
38+
copy:
39+
src: "{{ uv_temp_dir.path }}/uv-{{ uv_platform }}/uvx"
40+
dest: "{{ uv_install_dir }}/uvx"
41+
mode: '0755'
42+
when: uv_check.rc != 0 or uv_version not in uv_check.stdout
3043

3144
- name: Verify uv installation
32-
command: "{{ ansible_env.HOME }}/.local/bin/uv --version"
45+
command: "{{ uv_install_dir }}/uv --version"
3346
register: uv_verify
3447
changed_when: false
3548

49+
- name: Clean up temporary directory
50+
file:
51+
path: "{{ uv_temp_dir.path }}"
52+
state: absent
53+
when: uv_temp_dir.path is defined
54+
3655
- name: Show uv version
3756
debug:
3857
msg: "uv installed: {{ uv_verify.stdout }}"

0 commit comments

Comments
 (0)