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 = relation_get 'dbhost';
my $dbuser = relation_get 'dbuser';
service_control('nginx', 'restart');