1

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.

1 Answer 1

2

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

From the documentation:

JUJU_UNIT_NAME

The name of the local unit being executed.

JUJU_UNIT_NAME=vanilla/0

(source)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .