Skip to content

Commit 32e72e2

Browse files
feat(git): enable opt-in SSH commit and tag signing
2 parents f04c4a7 + d7204f0 commit 32e72e2

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

ansible/inventory/group_vars/local.yml.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
# Copy this file to local.yml (gitignored) and fill in your details.
44
git_user_name: "Your Name"
55
git_user_email: "you@example.com"
6+
7+
# SSH public key used to sign commits and tags (enables "Verified" badges).
8+
# Works with the Bitwarden SSH agent already wired up in .zshrc. Get the key
9+
# from Bitwarden, or run: cat ~/.ssh/id_ed25519.pub
10+
# Leave this commented out to skip commit signing entirely.
11+
# git_signing_key: "ssh-ed25519 AAAA... you@example.com"

ansible/roles/git/tasks/main.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,26 @@
3535
value: "{{ git_user_email }}"
3636
when: git_user_name is defined and git_user_email is defined
3737

38+
- name: Configure SSH commit and tag signing
39+
community.general.git_config:
40+
name: "{{ item.key }}"
41+
value: "{{ item.value }}"
42+
scope: global
43+
loop:
44+
- key: "gpg.format"
45+
value: "ssh"
46+
- key: "user.signingkey"
47+
value: "{{ git_signing_key }}"
48+
- key: "commit.gpgsign"
49+
value: "true"
50+
- key: "tag.gpgsign"
51+
value: "true"
52+
when: git_signing_key is defined
53+
3854
- name: Reminder about git signing
3955
ansible.builtin.debug:
4056
msg: |
41-
Git signing is not managed automatically. See principle 12.
42-
To enable SSH signing:
43-
git config --global gpg.format ssh
44-
git config --global user.signingkey ~/.ssh/<key>.pub
45-
git config --global commit.gpgsign true
57+
Git signing is not enabled. Set git_signing_key in
58+
ansible/inventory/group_vars/local.yml to your SSH public key
59+
(e.g. from Bitwarden) to sign commits and tags automatically.
60+
when: git_signing_key is not defined

cspell.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ words:
2424
- asciinema
2525
- atuin
2626
- binstall
27+
- Bitwarden
2728
- bootstrapper
2829
- cask
2930
- checkov

0 commit comments

Comments
 (0)