Assign a particular hostname to cloud machine

When juju starts a machine (via add-machine), a hostname is typically generated for it. Is there a way to specify a particular hostname or even a range or name pattern from which a hostname could be selected? Specifying a particular address or an address range might also be an option.

Manual provisioning allows for this (in its way) and the MAAS provider allows a particular host to be acquired by name. But there does not seem to be a general way to do this.

If there is an actual general solution that would be great. If not, is there somewhere in the juju code someone might point me to where the name generation is being done.


So, @jamesbeedy and @heitor would be able to let you know details also.

Since Slurm is using patterns of hostnames to form up “groups” of similar hosts with similar features, without the capability to specify hostnames, it would be difficult to “mimic” behaviors of clouds where this is possible.

This is the bundle that would be affected: Deploy Omnivector Slurm Distribution using Charmhub - The Open Operator Collection

I’ve never explored this myself, but it is a question I also have.

It would be great if we could specify the hostnames (or a pattern and then Juju adds the suffix with the number, e.g. if the pattern is db then juju creates db-1, db-2, and so on).

1 Like

On what basis would this hostnaming be applied: model, application, deploy? E.g., for a model, a pattern would be specified and apply to pretty well every deployed machine of that model? Or something associated with an application? Or something else?

What use cases do you see this helpful with? Slurm has been raised as one. Anything else?

When having nodes that will need to issue certificates perhaps?

Good point. Anything that is tied specifically to a hostname.

1 Like

Another case: deploying VMs with names related to the hosts they’re meant for.

I’m working on deploying a monitoring mesh for OpenStack - a mesh of VMs, one running on each hypervisor, to run some basic checks to ensure networking across the cluster is working as expected and to alert on breakages - and our preference is to have the VMs have names related to the hosts they’re deployed on.

We currently are manually deploying VMs and then add them as SSH machines, but this also means that we need to manually edit security groups or secgroup memberships since the manually-added VMs won’t have the same secgroups as the Juju-deployed VMs. So, while this isn’t a showstopper for our case, it certainly would be a small quality of life improvement to allow specifying hostnames via “juju add-machine” in some way.


Totally. Naming of instances is totally making life easier.

I don’t know if I understand well what the central point of this question is. But, I know that machines don’t have names but numbers: 0 to infinity. So the idea would be to replace the numbers, or add a hostname for each machine created through Juju? Would it be this? Hug to everyone

No, not exactly.

So, Juju assigns a a number to a machine. This is just an index which get automatically incremented with every new machine that is spawned.

The “instance name” is related to the cloud. In maas, you can set these hostnames manually, whereas. In LXD, they get named typically something like “juju-23fa34-0”. This “instance name” becomes related to the hostname in this case.

So you have three entities:

For some clouds (like MaaS and LXD at least) - you would be able to first create a machine or name it (effectively setting the Instance id) . You can then use that “Instance id” as a target with:

juju deploy tiny-bash --to <Instance id>

The cloud would then pick that up and deploy to it. In the process, it will be automatically assigned a new “index”.

1 Like