Juju relations can be confusing or deceptively simple, at first. Some background is here: https://jujucharms.com/docs/stable/authors-hook-environment
juju run
runs commands in a Juju context, that is to say JUJU_CONTEXT_ID
environment variable is set.
$ juju run --unit haproxy/0 'echo $JUJU_CONTEXT_ID'
haproxy/0-juju-run-9100131373820979914
$ juju run --unit haproxy/0 'echo $JUJU_CONTEXT_ID'
haproxy/0-juju-run-8230555870602207522
This means you can run charm hook tools.
For example, use relation-ids
to see all of the reverse proxy relations for a given haproxy unit:
$ juju run --unit haproxy/0 'relation-ids reverseproxy'reverseproxy:110
reverseproxy:111
reverseproxy:112
reverseproxy:113
reverseproxy:114
reverseproxy:115
reverseproxy:116
reverseproxy:117
reverseproxy:118
reverseproxy:119
Wow! That is a lot of relations. Use relation-list
to see the units for a given relation-id.
$ juju run --unit haproxy/0 'relation-list -r reverseproxy:115'
kibana/2
Ok, only one unit, kibana/2 for the kibana application. If there were more than one unit, both would be listed.
Now to see the relation data for each unit (in this case there is only one), use relation-get
:
$ juju run --unit haproxy/0 'relation-get -r reverseproxy:115 - kibana/2'
host: 10.142.0.7
port: "80"
private-address: 10.142.0.7
There, now we know what data kibana charm is sending to haproxy charm.