How to manage a same-model relation

See also:


Add a same-model relation

See also: juju relate

To set up a relation between two applications, for example, mysql and wordpress, all you need to do is execute:

juju relate mysql wordpress

This will satisfy WordPress’s database requirement where MySQL provides the appropriate schema and access credentials required for WordPress to run properly.

The code above however works only if there is no ambiguity in what relation the charm requires and what the related charm provides.

If the charms in question are able to establish multiple relation types, Juju may need to be supplied with more information as to how the charms should be joined. For example, if we try instead to relate the ‘mysql’ charm to the ‘mediawiki’ charm:

juju relate mysql mediawiki 

the result is an error:

error: ambiguous relation: "mediawiki mysql" could refer to
  "mediawiki:db mysql:db"; "mediawiki:slave mysql:db"

The solution is to be explicit when referring to an endpoint, where the latter has a format of <application>:<application endpoint>. In this case, it is ‘db’ for both applications. However, it is not necessary to specify the MySQL endpoint because only the MediaWiki endpoint is ambiguous (according to the error message). Therefore, the command becomes:

juju add-relation mysql mediawiki:db

The relation endpoints provided or required by a charm are listed in the result of the juju info command. They are also listed on the page for the charmed operator at Charmhub.

The output of juju status --relations will display the relations:

Relation provider  Requirer       Interface  Type     Message
mysql:cluster      mysql:cluster  mysql-ha   peer     
mysql:db           mediawiki:db   mysql      regular

Remove a same-model relation

See also: juju remove-relation

A relation is removed by calling out both (application) sides of the relation:

juju remove-relation <application-name> <application-name>

For example:

juju remove-relation mediawiki mysql

In cases where there is more than one relation between the two applications, it is necessary to specify the interface at least once:

juju remove-relation mediawiki mysql:db

Last updated a month ago.