Ansible Dev Server using VSCode Remote SSH
Why USe Remote SSH for Ansible Development?
When developing Ansible playbooks, you might want to:
- Keep all dependencies on a central development server.
- Avoid installing Ansible tools locally.
- Work from multiple devices without reconfiguring each one.
- Access servers in secure or restricted environments.
Remote SSH in VS Code allows you to connec to a remote machine and use it as your development environment as if it were local.
Prerequisites
- Remote Development Server (Linux, with SSH enabled)
- VS Code installed on your local machine
- SSH key-based authentication configured between your local machine and the remote server.
Setup
- Install the Remote SSH Extension in VS Code
- Open VS Code.
- Go to Extensions
- Search for Remote - SSH and install it.
- Configure SSH connection
- Edit your local
~/.ssh/config
file:Host ansible-dev HostName 203.0.113.10 User devuser IdentityFile ~/.ssh/id_rsa
- Connect from VS Code
- Press F1, type in Remote-SSH: Connect to Host…
- Select ansible-dev
- Or go to the Remote Explorer and click on the remote server from the SSH list
- Set Up your Ansible Remote Workspace
-
Once connected, instrall VS Code extensions in the remote environment
- Red Hat Ansible
- Dev Containers
or via the terminal
code-server --install-extension redhat.ansible
-
Install Podman (for container execution)
-
Git
sudo apt install podman sudo apt install git podman --version git --version
-
Ansible-Navigator
sudo apt install python3-pip pip install ansible-navigator --user echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.profile source ~/.profile
-
Test playbook run
git clone https://github.com/enzobercasio/ansible-demo.git
Remote SSH in VS Code is a powerful and flexible way to develop Ansible playbooks without worrying about local setup inconsistencies. It’s ideal for enterprise teams, secure environments, and scenarios where maintaining one central Ansible development server simplifies operations.