I'm currently setting up an automation infrastructure for Linux servers that are virtualized and automated through Terraform and GitLab. I'm looking for advice on establishing a reliable naming convention that can be used across different environments, such as engineering and production, along with sub-environments that don't have domain names. I'm curious about how detailed hostnames should be; should they include the sub-environment, or would it be better to keep them generic and just use numbers? Also, do people prefer using UUIDs or mnemonic phrases? I'd really appreciate your experiences and suggestions! Thanks! 🙂
7 Answers
I prefer keeping the actual hostnames a bit generic. I then set up DNS aliases like 'prod-1' for simplicity. This method keeps the naming manageable and straightforward while allowing flexibility in the background.
We tend to go with a format like 'Location-App-Code-Tier-Number'. For example, 'ukinmailp1' breaks down into UK for the location, IN for infrastructure, MAIL for the app purpose, P for Production, and then the number. It's a systematic way to track what each server does.
We utilize a detailed format that includes 3 digits for location, 1 digit for the domain, 1 for Prod/Dev/Stg/Tst, and then 3 digits for the application, function, and numbers. It’s a bit lengthy, but it effectively accommodates numerous similar servers without confusion, giving clarity to each server’s role.
In my experience, a good approach is to use a pattern like location-function-number for clarity in a multi-site environment. This way, you can quickly identify where a server is located and its purpose just by looking at the name. For instance, you might have something like 'NYC-Web-01'.
We operate with a naming scheme that includes Location-App-OS-Number-Org. It yields names like 'J01W237R', which might seem complex at first, but it's quite effective. You can instantly tell what the server is meant for and where it’s located, which is beneficial when you're managing thousands of servers.
Using mnemonics can also work well, especially if you're not keen on mythological names or color themes. However, keep scalability in mind; this helps when you have hundreds of hosts. Just be cautious not to mix geographical details in names of resources that might move around. It's better if servers have names that can stand the test of time without becoming outdated, like 'prod.example.com' for DNS subdomains.
There's a helpful Terraform module for naming Azure resources that you might find useful: https://github.com/Azure/terraform-azurerm-naming. Additionally, there's a cloud-agnostic version: https://github.com/cloudposse/terraform-null-label. Both could provide you some inspiration.
That's a solid format! If there are different departments involved, consider adding the department acronym before the number. It can help in organizing servers used by various teams.