A simple Ansible connection plugin that uses gRPC. This project includes both client and server implementations.
Features
gRPC-based connection plugin for Ansible
SSH key-based authentication
Dynamic SSH key reloading
Support for user-specific environment variables
Systemd service configuration for gRPC server
Installation
Clone the repository:
git clone https://github.com/HZ89/simple-ansible-connection-plugin.git
cd simple-ansible-connection-plugin
Build the project:
make
Ensure the required Python packages are installed:
pip install paramiko grpcio
Configuration
Dockerfile
The Dockerfile uses the golang:1.22-buster base image. If this image is not accessible, replace it with any suitable
Golang image from Docker Hub.
gRPC Plugin Enhancements
The plugin now includes improved SSH key handling and error management.
The grpc_plugin.py script fetches SSH keys and handles multiple keys dynamically.
The SSHAuthenticator class in ssh_key.go uses fsnotify to monitor changes in the authorized keys file and reload
keys automatically.
The main server code has been updated to parse structured metadata for authentication and support user-specific
environment variables during command execution.
Home directory tilde expansion is implemented for file paths in PutFile and FetchFile methods.
Systemd Service
A systemd service file ansible-grpc-connection-server.service is added to manage the gRPC server as a systemd
service.