Using Ansible with Teleport
Using Ansible with Teleport⌗
What is Teleport ?⌗
Gravitational Teleport is a gateway for managing access to clusters of Linux servers via SSH or the Kubernetes API. It is intended to be used instead of traditional OpenSSH.
What is Ansible⌗
Ansible is an open source DevOps tool which can help the business in configuration management, deployment, provisioning, etc. It is straightforward to deploy; it leverages SSH to communicate between servers. It uses the playbook to describe automation jobs, and playbook uses a very simple language YAML.
What is the matter in combining them ?⌗
Ansible is using native SSH client, so it is necessary to make some changes in order to be able to use ansible through Teleport.
First, ssh config⌗
When you are going through teleport to connect to the desired server, you need to precise the hostname and only the hostname. Teleport does not care about the IP adddress per se. So if your ip address is something like mysuperhost.aws-test.mydomain.com, Teleport will know it by mysuperhost only. So we need to do a bit of cutting to extract the hostname.
Host *.aws-test.mydomain.com
Port 3022
ProxyCommand ssh -p 3023 %r@teleport.mydomain.com -s proxy:$(echo %h | cut -d "." -f 1):%p
This particular ssh config will connect to the teleport proxy (teleport.mydomain.com) and pass it the hostname which is the result of the cut command (to simplify, it will only pass the first part before the first dot of the FQDN –> mysuperhost).
Second, ansible config⌗
As noted in https://gravitational.com/teleport/docs/admin-guide/#ansible-integration
You need to enable scp mode in the Ansible config file (default /etc/ansible/ansible.cfg) by adding this simple line:
scp_if_ssh = True