Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When you launch an instance and explicitly name it using:

juju deploy lamp website1

Is there a way on the newly created instance to get the data that tells the machine that its:

  • called website1

or even better:

  • a unit number such as website1/0, website1/1 etc etc

The reason for doing this is that in my charm I wish to set the hostname to this value.

I did wonder if it was set via ec2metadata but it doesn't seem to list this information.

share|improve this question
up vote 2 down vote accepted

Its important to note that you did not name the instance, but rather the service. As your question alludes to, services can have multiple units. For current implementations of juju, one unit does mean one instance, but at some point instances will be split up with multiple service units on them.

To answer your question more directly, yes, the unit name is accessible as


From the documentation:


The name of the local unit being executed.



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.