Best practice on hooks for educational purpose

I’ve started to dig in on educational material for juju charming.

I’ve created two charms (bash + python) - serving as the intended starting point for the material - probably a tutorial.

Here is the draft:

The focus is on “hooks”.

I want to discuss how the implementation of these “hooks only” charms could be made more “typical” and “best practice” to good charming.

The challenge is to keep it extremely minimal to assist in the learning process. Possibly leading into the reactive framework further down, but not to the expense of adding too much complexity.

I would like to fire off a discussion around how to actually implement the hooks to be:

  • Minimal
  • Best practice or at least typical.
  • “Just enough” introduction to other concepts outside of “hooks”. Hook contexts, configuration validation, juju eventloop etc.
  • Ideally, making the code also “OS agnostic” - not relying on Ubuntu to get juju basic concepts going.

If done right, I hope we can help people getting even easier into juju charming.

So, what are your thoughts! Fork and code.

Some other tutorials helpful in learning of juju charming:

Thanks for your great tutorial and detailed explaination, which is really helpful! There are some minor suggestions regarding your tutorial in GitHub link. :slight_smile:

a. In the part Remove the application
The following command causes an error as ‘Unrecognized command’

$ juju remove application tiny-python

It might be like this:

$ juju remove-application tiny-python

b. In the part Modifying the ‘install’ hook
Before modifying Install script, is it necessary to specify the exact path of install? like ~/tiny_python/hooks/install .
(There is a tree above demonstrating the path though :D)


Thanx, I’ve fixed the “remove-application” part. Thanx for contributing to it!

I have now also added a few things on how to get out of problems with juju resolved…

I will add you to a list of contributors if you like?

That’s great!
yes, please. :smiley: