The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Getting Started

Follow the same guidelines as normal for creating a Juju charm.

Directory Layout

Structure your project should look similar to:

  charm-project/
    hooks/
      install
      config-changed
      start
      stop
    tests/
      00-basic.test
    config.yaml
    metadata.yaml
    LICENSE
    README.md
    Makefile

Writing charm hooks

Hooks are written using perl with automatically imported helpers for convenience. When developing hooks they should reside in hooks.

A typical hook starts with

   #!/usr/bin/env perl

   use charm;

   log 'Starting install hook for database';

   apt_install(['mysql-server', 'nginx', 'php5-fpm'])

   my $dbhost = sh 'relation-get dbhost';
   my $dbuser = sh 'relation-get dbuser';

   service_control 'nginx', 'restart';