Enrolling Linux VM Servers with Teleport Using Machine ID and Ansible (Without Long-Lived Certificates) #48544
pnrao1983
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Enrolling Linux VMs to a Teleport cluster efficiently without long-lived certificates is essential for secure, automated workflows. This guide details how to dynamically use Machine ID with Ansible to join Linux VMs to a Teleport cluster, minimizing the need for long-lived certificates.
Steps Overview
1. Log in to the Teleport cluster
tsh login --proxy example.teleport.sh --user user@your_domain.com
2. Generating an Identity File
You must create an identity file using Machine ID to generate certificates automatically. Follow the MachineID guide to create the Identity and rotate it or save it in a secret store based on your use case and as per your infra process: https://goteleport.com/docs/enroll-resources/machine-id/deployment/deployment/
Alternatively, execute the following command to create an identity file (cert), ensuring permissions in your role allow token management:
tctl auth sign --user=user@your_domain.com --out=ansible-identity
Note: Ensure your role has the following permissions:
Once generated, copy the ansible-identity file to Ansible Tower.
3. Configure Ansible for Teleport Enrollment
Create or modify the
ansible.cfg
configuration file for Ansible:Copy your
ansible-identity
file into the same directory asansible.cfg
4. Writing the Ansible Playbook
Below is the ssh-node-join-ansible-playbook.yaml playbook. This playbook will:
Note: If you are going to join the node for the first time, then please remove the first three tasks(stop teleport service, remove the data dir and packages) under
pre_tasks
5. Executing the Playbook
Run the playbook using the following command:
ansible-playbook ssh-node-join-ansible-playbook.yaml
Expected Output
Upon successful execution, you’ll see output indicating each step’s completion:
Verification
Log into your Teleport cluster and verify the node appears in your list of active nodes:
In the destination Node, you can see below:
Summary
This approach leverages Ansible and short-lived tokens to automate the enrollment of Linux VM servers into a Teleport cluster without using long-lived certificates. It’s a secure, efficient solution for maintaining dynamic access across a fleet of servers.
Beta Was this translation helpful? Give feedback.
All reactions