Since I've set this up a number of times, but I just realized I've never documented it on my blog, I thought I'd finally do that.
I have a set of servers that are running on a private network. That network is connected to the Internet through a single reverse proxy / 'bastion' host.
But I still want to be able to manage the servers on the private network behind the bastion from outside.
The way to do that with Ansible is to describe how to connect through the proxy server in Ansible's inventory.
In my case, I had an inventory file like the following:
[proxy] bastion.example.com [nodes] private-server-1.example.com private-server-2.example.com private-server-3.example.com
If I am connected to the private network directly, I can just run
ansible commands and playbooks, and Ansible can see all the servers and connect to them (assuming my SSH config is otherwise correct).
From the outside, though, I need to modify my inventory to look like the following: