Repository navigation
fix: [#181] use ansible_user variable instead of hardcoded username - #183
Merged
josecelano merged 1 commit intoNov 18, 2025
Merged
Conversation
- Updated inventory template to use {{ansible_user}} variable
- Added ansible_user field to InventoryContext struct
- Updated all builders and tests to pass ansible_user
- Fixed hardcoded 'torrust' username in inventory.yml.tera
- Ansible now respects ssh_credentials.username from environment config
This allows users to specify custom usernames (ubuntu, admin, etc.)
instead of being forced to use 'torrust'.
Member
Author
|
ACK 06ccd74 |
josecelano
deleted the
181-fix-hardcoded-ansible-user-in-inventory-template
branch
April 15, 2026 16:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #181 - Removes hardcoded
ansible_user: torrustfrom the inventory template and makes it configurable via the environment's SSH credentials.Changes
Template Update
templates/ansible/inventory.yml.tera: Changed from hardcodedansible_user: torrustto variableansible_user: {{ansible_user}}Data Structure Updates
InventoryContextstruct: Addedansible_user: StringfieldInventoryContextBuilder: Addedwith_ansible_user()builder methodMissingAnsibleUsererror variantansible_user()methodProduction Code
create_inventory_context(): Now extracts username fromssh_credentials.ssh_usernameand passes it to the builderTests
{{ansible_user}}variableVerification
✅ All 1150 unit tests pass
✅ All integration tests pass
✅ Pre-commit checks pass
✅ Manual E2E test verified with custom username
testuser123✅ Rendered inventory file correctly shows configurable username
Impact
Users can now specify custom SSH usernames (ubuntu, admin, etc.) in their environment configuration instead of being forced to use the hardcoded 'torrust' username.
Before: SSH connections always used hardcoded username "torrust"
After: SSH connections use the username specified in
ssh_credentials.usernamefrom environment config