Skip to content

Commit

Permalink
Use .ssh/config to setup SSH proxy jump
Browse files Browse the repository at this point in the history
Unfortunately, my previous attempt to route deployment through a
jumphost[^1] doesn't work. Turns out that specifying a proxyjump host
inline doesn't support specifying an SSH key to authenticate with. It
worked well on my machine because some _default_ key was used
transparently, but it fails on CD where no such key exist.

The new approach tries to address the problem by moving away from inline
SSH configuration towards the .ssh/config file, which has everything
needed specified.

[^1]: 7aec773
  • Loading branch information
ikalnytskyi committed Jan 1, 2025
1 parent 1312406 commit 8f22f3b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CD

on:
push:
branches: [master]
branches: [master, bug/cd-fixes]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -37,10 +37,20 @@ jobs:
# Ensure that servers we're deploying to are known. Otherwise,
# Ansible may fail with host key verification error.
mkdir -p ~/.ssh && echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts
cat <<EOF > ~/.ssh/config
Host _jumphost
User bunny
HostName hoth.kalnytskyi.com
IdentityFile ${{ steps.ssh-key.outputs.uri }}
Host xsnippet.org
HostName 2a02:8084:4:e480:244a:d5a5:ac59:617d
ProxyJump _jumphost
IdentityFile ${{ steps.ssh-key.outputs.uri }}
EOF
ansible-playbook \
-vv \
-e ansible_ssh_private_key_file="${{ steps.ssh-key.outputs.uri }}" \
-e goaccess_basicauth_password="${{ secrets.GOACCESS_PASSWORD }}" \
--inventory inventories/production \
site.yml
3 changes: 1 addition & 2 deletions inventories/production/hosts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[xsnippet]
2a02:8084:4:e480:244a:d5a5:ac59:617d
xsnippet.org

[xsnippet:vars]
ansible_user = provisioner
ansible_ssh_common_args = -J [email protected]

0 comments on commit 8f22f3b

Please sign in to comment.