# Hostname specification

> Choose how hostnames are assigned to new servers, from manual entry to dynamically generated templates

---

Site [llms.txt](/llms.txt)

---

There are four main ways to set a server's hostname:

- **Manual entry:** the user enters a hostname when ordering a server. This is the default.
- **Resource pool:** a pool of hostnames associated with the environment.
- **Hostname template:** a template that generates hostnames dynamically, covered here.
- **Orchestration action:** a pre-create resource orchestration action runs code to determine the hostname. See [Plugins](/docs/cmp/use/orchestration/plugins/).

## Using hostname templates

The *Hostname Template* parameter specifies how hostnames are generated for new servers. Instead of a static hostname pool, a hostname template dynamically generates hostnames from order attributes, such as a group code, an environment code, a location code, and a user-provided purpose (for example, "web").

### Context variables available within hostname templates

- *environment:* the environment chosen on the order form
- *group:* the group chosen on the order form
- *os_build:* the OS build chosen on the order form (for example, Windows Server 2022 Template)
- *os_family:* the OS family of the chosen OS build (for example, CentOS)
- *all parameters:* hidden and visible order form parameters, referenced by name rather than label (for example, "dc_code" instead of "Datacenter Code")
- *resource:* the deployed resource object created as part of this order (only when ordering a resource)
- *requestor:* the user profile of the person requesting the server or resource

### Uniquification

If the hostname template contains one or more zeros followed by a capital X, Cloud Management Platform (CMP) replaces that during the provisioning job with the first number that makes the hostname unique, padded with zeros to match the digit count.

For example, the template *svr-00X* expands to *svr-002* if a server named *svr-001* already exists.

If the template doesn't include a 0X component, CMP appends the lowest integer that makes the hostname unique.

For example, the template *prodsvr-* expands to *prodsvr-3* if servers named *prodsvr-1* and *prodsvr-2* already exist.

### Hostname template examples

| Template | Output example |
| --- | --- |
| `svr0X` | svr05 |
| `{{ group.name }}{{ environment.name }}00X` | AcmeQA002 |
| `{{ requestor.user.username }}-{{ os_family.get_base_name\|lower\|first }}svr00X` | auggy-lsvr005 or bernard-wsvr005 |
| `{{ lifecycle }}svr000X` | prodsvr0020 or qasvr1796.<br>*lifecycle* is a parameter created by an admin, set on the environment or group, or chosen by the user at order time. |
| `{{ dc_code }}{{ env_code }}{{ os_family.name\|first\|lower }}{{ app_code }}00X{{ cluster_code }}` | nydlweb001b (New York dev Linux web server 001 b) |
| `svr-{{ resource.name\|slugify }}-00X` | Injects the deployed resource name into the hostname. |
| `svr-{% get_str_id %}` | Randomly generates a six-character hostname. Append a number to change the length; for example, `svr-{% get_str_id 10 %}` generates 10 characters. |

## Related

- [Order form customization](/docs/cmp/use/blueprints/customize-order-form/order-form-customization/): Every way to customize the order form.
- [Parameter templates](/docs/cmp/configure/order-forms-and-pricing/parameters/parameter-templates/): Fields that compute their value from a template.
