Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

up vote 1 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

$JUJU_UNIT_NAME

This is documented here:

https://juju.ubuntu.com/docs/charm.html

$JUJU_UNIT_NAME - The name of the local unit executing, in the form /. E.g. myblog/3.

share|improve this answer

Your Answer

 
discard

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.