Publish to the Juju charm store¶
This is quick guide on how to publish a charm/bundle to the official Juju charm store, taken from the official guide.
Prerequisites¶
An Ubuntu One account. You can create an account here:
With the Ubuntu One account you can login on jujucharms.com via SSO. A user area will be created:
Install the charm tools:
$ sudo add-apt-repository ppa:juju/stable $ sudo apt update $ sudo apt install charm-tools
Prepare the code¶
Follow the instructions for:
Put the source code for the charm or bundle in a separate directory.
For bundles, the name of the directory will become the name of the bundle and the directory must contain a metadata file called bundle.yaml as well as a README.md file:
bundle.yaml
README.md
Login to the store¶
Execute login using the charm tools in interactive mode:
$ charm login
During login you will be prompted for the following information:
Username - typically the email address used to access Ubuntu SSO
Password - Ubuntu SSO password
Two-factor auth - If enabled, enter two-factor authentication (2FA) information. Otherwise Return for None)
Note
To allow the above command to succeed the following must hold:
the latest charm command is installed
the user has an Ubuntu SSO account
the user has logged into Launchpad at least once
the user is logged in the Charm Store with her browser
Verify that the login was successful with:
$ charm whoami
Pushing to the store¶
Go to the directory with the sources of your charm or bundle and perform a push:
$ cd $SOURCE_DIR
$ charm push .
Note
If your charm is a reactive charm
, the directory with the sources will be located in /tmp/charm-builds/<your_charm_name>
The push command will return the ID of charm/bundle in this form:
cs:~$USER/$NAME-$REV
where $USER is the User from the output of charm whoami and $NAME is the metadata.yaml name for charms and directory basename for bundles. The revision number ($REV) will be incremented on every push. It starts at 0.
Optionally you can give a different name to the charm/bundle, for example:
$ charm push . cs:~team-name/bundle-name
where team-name is the Group membership from the charm whoami command: this will set $USER to team-name and $NAME to bundle-name.
Optionally add a home page or bugs URL for the given charm/bundle:
$ charm set cs:~$USER/$NAME bugs-url=$URL
$ charm set cs:~$USER/$NAME homepage=$URL
The charm/bundle pushed to jujucharms.com is now available at this link, but accessible only by login:
https://jujucharms.com/u/$USER/$NAME/$REV
In order to make your submission public, you have to release the entity to one of the 4 channels: edge, beta, release candidate, stable:
$ charm release cs:~$USER/$NAME-$REV --channel stable
After that, you have to grant permissions to everyone:
$ charm grant cs:~$USER/$NAME-$REV everyone --channel stable
Now your charm or bundle will appear in search results on jujucharms.com without the need to login.
You can now deploy it:
$ juju deploy cs:~$USER/$NAME
Note
If no revision number is specified, the latest version will be used.
Attaching resources¶
If you have declared resources in metadata.yaml of your charm, you need to attach them using these commands:
$ charm attach cs:~$USER/$NAME-$REV resource=<path/to/resource>
Then you can publish your charm using the following command:
$ charm release cs:~$USER/$NAME-$REV --channel stable --resource $RESOURCE_NAME-$REV
e.g:
$ sudo charm attach cs:~csd-garr/openstack-integrator-3 openstackclients=/var/lib/snapd/snaps/openstackclients_37.snap
$ charm release cs:~csd-garr/openstack-integrator-3 --channel stable --resource openstackclients-0
Or, if you get an "ERROR cannot release charm or bundle: resources are missing from publish request"
message, you may need to replace the charm push
command with something similar to the following:
$ charm push . cs:~csd-garr/keystone-saml-mellon --resource idp-metadata=/tmp/idp-metadata.xml --resource sp-private-key=/tmp/sp-private-key.pem --resource sp-signing-keyinfo=/tmp/sp-signing-keyinfo.xml
(which works also with empty resource files) and then issue the charm release
command.