325 lines
29 KiB
HTML
325 lines
29 KiB
HTML
<!doctype html>
|
||
<html>
|
||
<head>
|
||
<title>Zk | 2016-12-16-part-2</title>
|
||
<link rel="stylesheet" type="text/css" href="/style.css" />
|
||
<meta name="viewport" content="width=device-width" />
|
||
<meta charset="utf-8" />
|
||
</head>
|
||
<body>
|
||
<main>
|
||
<header>
|
||
<h1>Zk | 2016-12-16-part-2</h1>
|
||
</header>
|
||
<article class="content">
|
||
<hr />
|
||
<p>type: post
|
||
date: 2016-12-16
|
||
slug: part-2
|
||
title: How Charming - Part 2</p>
|
||
<hr />
|
||
<p><em>In the previous part, we started to nail down what it is that we’re going to do to try and accomplish our task. We’re going to write a charm - a package that represents a way to deploy a piece of software repeatably to the cloud - which does all that’s needed to host a WSGI app. It will be able to talk to several different services and use any WSGI server. If you haven’t yet, <a href="/posts/tech/how-charming/2016/12/13/part-1.html">check that post out first</a>!</em></p>
|
||
<p>“Hey! I think I have deployment all figured out for Honeycomb!” I blurted out in the Guild chat, sharing the link to the previous post.</p>
|
||
<p>Blank stares, then finally, “You wrote about the furry website you’re building for work<sup id="fnref:disclaimer"><a class="footnote-ref" href="#fn:disclaimer">1</a></sup>..?”</p>
|
||
<p><img alt="It's true" src="/assets/tech/how-charming/part-2-furries.jpg" style="max-width: 150px; float: left; margin: 0 1em 1em 0;" /></p>
|
||
<p>Point. But hey, furries make the internet go<sup id="fnref:furries-tech"><a class="footnote-ref" href="#fn:furries-tech">2</a></sup>.</p>
|
||
<p>Anyhow, I digress. The goal of Honeycomb is not to be a furry website but a writing one, and besides, none of the guild really cared about deployment strategies; that’s something for me to worry about. And as a developer with a fascination with the Ops side of things, I <em>do</em> care about deployment strategies.</p>
|
||
<p>Chat aside, Juju is a delightful step in making things much easier for us DevOpsy critters, because it allows us to write general and repeatable solutions that can be used within a ecosystem of other solutions to accomplish a specific goal. In our case, we want to be able to deploy any WSGI compliant application that can connect to a variety of other services and be hosted in the cloud.</p>
|
||
<p>These solutions, charms, are what we’ll need to have to get our stack up and running, so let’s get started in making our <code>wsgi-app</code> charm.</p>
|
||
<hr />
|
||
<h3 id="bootstrapping-the-charm">Bootstrapping the charm</h3>
|
||
<p>As Juju is a Canonical offering (and I’m a Canonical employee), I’ll be working in Ubuntu, so if you’re following along, you’ll need that running on a machine or VM at your disposal (you’ll need 15.10 Wily or 16.04 Xenial, to be specific). Once you’ve got your system up and running, installation of juju and the tools we need is fairly easy:</p>
|
||
<div class="codehilite"><pre><span></span><code>sudo apt install juju lxd charm-tools
|
||
</code></pre></div>
|
||
|
||
|
||
<p>This will install just about everything we need: we’ll get juju itself, of course, as well as LXD, which is used for local and development environments, and <code>charm-tools</code>, which contains a few applications we’ll be using for creating, building, and testing our charm.</p>
|
||
<p>Getting our charm set up after this point is fairly easy, but it does require deciding on how you’re going to work with your charm. I have a work directory in which I keep all of my projects, and when developing a charm, it’s often easiest to have all of your charm related work in its own directory structure. With that in mind, I’m going to set up the following directory structure for working with <code>wsgi-app</code>:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="err">~</span>
|
||
<span class="err">└── work</span>
|
||
<span class="err"> └── charms</span>
|
||
<span class="err"> ├── builds</span>
|
||
<span class="err"> ├── interfaces</span>
|
||
<span class="err"> └── layers</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>We’ll get into what layers are in just a second and interfaces in a later article, but for now, that’s the basic structure that one needs to get started with building a charm. This is because the various charm tools expect to find a certain structure when they do their work. This is all controlled through environment variables:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="nb">export</span> <span class="nv">JUJU_REPOSITORY</span><span class="o">=</span><span class="nv">$HOME</span>/work/charms
|
||
<span class="nb">export</span> <span class="nv">LAYER_PATH</span><span class="o">=</span><span class="nv">$JUJU_REPOSITORY</span>/layers
|
||
<span class="nb">export</span> <span class="nv">INTERFACE_PATH</span><span class="o">=</span><span class="nv">$JUJU_REPOSITORY</span>/interfaces
|
||
|
||
<span class="c1"># or, in fish:</span>
|
||
|
||
<span class="nb">set</span> -x JUJU_REPOSITORY ~/work/charms
|
||
<span class="nb">set</span> -x LAYER_PATH <span class="nv">$JUJU_REPOSITORY</span>/layers
|
||
<span class="nb">set</span> -x INTERFACE_PATH <span class="nv">$JUJU_REPOSITORY</span>/interfaces
|
||
|
||
<span class="c1"># then:</span>
|
||
|
||
mkdir -p <span class="nv">$LAYER_PATH</span> <span class="nv">$INTERFACE_PATH</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>Now that we’ve got our basic directory structure in place, we can start to actually build out our charm. Thankfully, the charm tools give us a way to do so with a simple command:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="c1"># First, get to the layer directory, where we'll be working on our charm</span>
|
||
makyo@corrin:~$ <span class="nb">cd</span> <span class="nv">$LAYER_PATH</span>
|
||
makyo@corrin:~/work/charms/layers$ charm create wsgi-app
|
||
INFO: Using default charm template <span class="o">(</span>reactive-python<span class="o">)</span>. To <span class="k">select</span> a different template, use the -t option.
|
||
INFO: Generating charm <span class="k">for</span> wsgi-app in ./wsgi-app
|
||
INFO: No wsgi-app in apt cache<span class="p">;</span> creating an empty charm instead.
|
||
Cloning into <span class="s1">'/tmp/tmp52ugnq'</span>...
|
||
remote: Counting objects: <span class="m">27</span>, <span class="k">done</span>.
|
||
remote: Total <span class="m">27</span> <span class="o">(</span>delta <span class="m">0</span><span class="o">)</span>, reused <span class="m">0</span> <span class="o">(</span>delta <span class="m">0</span><span class="o">)</span>, pack-reused <span class="m">27</span>
|
||
Unpacking objects: <span class="m">100</span>% <span class="o">(</span><span class="m">27</span>/27<span class="o">)</span>, <span class="k">done</span>.
|
||
Checking connectivity... <span class="k">done</span>.
|
||
</code></pre></div>
|
||
|
||
|
||
<p><code>charm create</code> will do a few things, as shown above, but in short, it will create a <code>wsgi-app</code> directory for us, and populate it with a basic template upon which we’ll build our charm. This winds up giving you a directory like so:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="err">wsgi-app</span>
|
||
<span class="err">├── config.yaml</span>
|
||
<span class="err">├── icon.svg</span>
|
||
<span class="err">├── layer.yaml</span>
|
||
<span class="err">├── metadata.yaml</span>
|
||
<span class="err">├── reactive</span>
|
||
<span class="err">│ └── wsgi_app.py</span>
|
||
<span class="err">├── README.ex</span>
|
||
<span class="err">└── tests</span>
|
||
<span class="err"> ├── 00-setup</span>
|
||
<span class="err"> └── 10-deploy</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>There’s a lot going on here, so it’s time we take a step back and talk about what goes into building a charm, and the two important concepts to learn about: hooks and layers.</p>
|
||
<hr />
|
||
<h3 id="hooks">Hooks</h3>
|
||
<p>Charms, as deployment solutions, are fundamentally reactive. When you deploy a charm, it goes through several stages, and at each stage, the charm has a chance to react to what’s going on during the deployment process. The same with other things going on around the charm: when configuration values are changed, or a relation (a means of communication between two services) is added or removed or changed, the charm can react to that as well.</p>
|
||
<p>As with many other reactive frameworks, we call these sorts of reactions ‘hooks’. For example, when you first deploy a charm with juju, the charm receives several hooks from juju once the machine on which it is to be deployed is up and running. It will start with the <code>install</code> hook, which is usually when the charm has a chance to install all of its software. After that, it will receive the <code>config-changed</code> hook, which is when the charm will learn about all of the configuration options that the user has specified and can react accordingly. Finally, it will receive a <code>start</code> hook, which is when any long-running processes such as servers will be started. <code>stop</code> is another hook, as well, of course, wherein one might back-up any charm data.</p>
|
||
<p>The hook-based lifecycle of a charm looks something like the following<sup id="fnref:rr-diagrams"><a class="footnote-ref" href="#fn:rr-diagrams">3</a></sup>:</p>
|
||
<p>{% include tech/how-charming/part-2-hooks.svg %}</p>
|
||
<p>In reality, most of the work that is done within the charm happens during the <code>config-changed</code> hook, while <code>install</code> is used only for installing ancillary software and <code>start</code> is often just ignored. This is because that is the hook which will always occur after startup and any configuration changes (such as when the user runs <code>juju set</code>). This way, you can just restart all tasks during <code>config-changed</code>, as this will cause config files changed during the hook to be reloaded and so on.</p>
|
||
<p>We’ll get more into relations in a later part, but for now, it’s enough to understand that relations are, primarily, ways in which one service can expose information to another. Contrary to their names or how they appear in visualizations, they’re not means or representations of <em>communication</em> between services. Rather, one can think of them as the juju controller allowing the two services to acknowledge that they exist to each other. In our instance, this will mean that, when a relation is created between <code>wsgi-app</code> and PostGres, <code>wsgi-app</code> will receive connection information for the PostGres database server, and networking will be restructured such that the two instances <em>can</em> talk to each other.</p>
|
||
<p>{% include tech/how-charming/part-2-relation-hooks.svg %}</p>
|
||
<p>Relations follow their own cycle of hooks, through creation, change, and deletion, but again, we’ll be diving into them later - they’re a topic of their own!</p>
|
||
<hr />
|
||
<h3 id="layers">Layers</h3>
|
||
<p>Charms can be written in most any language that’s available on a base ubuntu server image, such as bash or python, or any language installed during the charm hook, which covers just about everything. This works by having a hook directory in the charm with an executable file named for each hook:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="err">hooks</span>
|
||
<span class="err">├── config-changed</span>
|
||
<span class="err">├── hook.template</span>
|
||
<span class="err">├── install</span>
|
||
<span class="err">├── leader-elected</span>
|
||
<span class="err">├── leader-settings-changed</span>
|
||
<span class="err">├── nrpe-external-master-relation-broken</span>
|
||
<span class="err">├── nrpe-external-master-relation-changed</span>
|
||
<span class="err">├── nrpe-external-master-relation-departed</span>
|
||
<span class="err">├── nrpe-external-master-relation-joined</span>
|
||
<span class="err">├── start</span>
|
||
<span class="err">├── stop</span>
|
||
<span class="err">├── update-status</span>
|
||
<span class="err">├── upgrade-charm</span>
|
||
<span class="err">├── website-relation-broken</span>
|
||
<span class="err">├── website-relation-changed</span>
|
||
<span class="err">├── website-relation-departed</span>
|
||
<span class="err">└── website-relation-joined</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>Many charms are still written by hand in this fashion, as it’s quite easy to do. In most cases, all code lives in, for instance, a <code>hooks.py</code> file with all hook files being symlinks to that. Pertinent functions are run through the use of <code>@hook</code> decorators, such as <code>@hook('config-changed')</code>.</p>
|
||
<p>Although you can always write charms more directly like this, one winds up writing a lot of boilerplate code. If you’ve written charms before, you’ll be well versed in this, and if you haven’t, you may find yourself stealing from other charmers more often than not.</p>
|
||
<p>In the spirit of Don’t Repeat Yourself, there’s another way of writing charms: layers.</p>
|
||
<p>Layers are composable packages that allow one to include functionality in the final charm without having to write it yourself. They’re the libraries that the charm ecosystem really needed. As yet, they only exist for python charms, but as we’re charming up python applications, we should be good to go in using them!</p>
|
||
<p>So what can one do with layers? Well, quite a bit. Say one needs to install some software on installation - Honeycomb requires the use of <code>pandoc</code>, for instance, which allows writers to upload many different file types - in which case one require the <code>apt</code> layer, which will allow one to specify in one’s layer configuration what one expects to have installed on the machine by the time we get to running our service. Similarly, we may want to use a git layer which will fetch our website repository as specified in a configuration and use that to deploy our application.</p>
|
||
<p><em>Hooks</em> respond to what is happening in the juju environment and are the basis of how charms work, while <em>layers</em> compose oft-repeated bits of functionality into a charm and are the basis of making it easier to conceptualize and compartmentalize different actions that a charm may make.</p>
|
||
<p>Sort of. For the most part. Ish.</p>
|
||
<p>Layers also introduce a bit of complexity in that they offer hook-like functionality through a state mechanism. For instance, an apache layer may have a state <code>apache.available</code> that is set when Apache is up and running and ready to serve your page. That layer may call <code>set_state('apache.available')</code>, which will mean that your charm will get notified through a state change. If you need to do something when Apache is made available, you can set up a function to do so based on a decorator: <code>@when('apache.available')</code>.</p>
|
||
<p>You can think of it like so:</p>
|
||
<ul>
|
||
<li><em>Hooks</em> are fired when something changes in Juju</li>
|
||
<li><em>Layers</em> compose repeatable functionality into libraries and set state, and</li>
|
||
<li><em>State changes</em> happen when something happens within the charm itself as one of the hooks is called.</li>
|
||
</ul>
|
||
<p>There’s a lot going on here, and I’ve already thrown a lot of words at it, with a few more posts to go. I learn best by seeing how things are implemented, though, so let’s get onto the charm and see how this all fits together.</p>
|
||
<hr />
|
||
<h3 id="wsgi-app-as-a-layer"><code>wsgi-app</code> as a layer</h3>
|
||
<p>With the steps outlined above, we created a <code>wsgi-app</code> charm, right?</p>
|
||
<p>Well, not actually. We created a <code>wsgi-app</code> <em>layer</em>, which can be built into a charm. What we need to do is start working on what the layer will do, so that when we run <code>charm build</code> in a bit, we’ll wind up with a complete charm that serves up a WSGI application.</p>
|
||
<p>Here’s what we need <code>wsgi-app</code> to do:</p>
|
||
<ul>
|
||
<li>Install some python stuff - we’ll need <code>pip</code>, for instance, to grab our frameworks and dependencies</li>
|
||
<li>Fetch our source repository and set some configuration values such as our application secret</li>
|
||
<li>Expose relation endpoints for:<ul>
|
||
<li>a WSGI server such as <code>gunicorn</code> or <code>uwsgi</code></li>
|
||
<li>a database such as PostGres or MySQL/MariaDB</li>
|
||
<li>ElasticSearch</li>
|
||
<li>memcached</li>
|
||
<li>Apache for proxying and load balancing</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<p>Remember, though, that we’re going to save relations for a later step, so let’s just focus on the first two steps.</p>
|
||
<p>For installing stuff, our best bet is to use the <code>apt</code> layer. Remember that layers act as libraries; in this case, we’re aiming to install the library that will let us install packages through apt.</p>
|
||
<p>This is a fairly simple thing to do, if perhaps a little magical: open <code>layer.yaml</code>; you’ll see the boilerplate code, which looks like so:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="nt">includes</span><span class="p">:</span> <span class="p p-Indicator">[</span><span class="s">'layer:basic'</span><span class="p p-Indicator">]</span> <span class="c1"># if you have any interfaces, add them here</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>Adding a layer is as simple as adding it to that list. Add <code>layer:apt</code> so that you wind up with the following YAML file:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="nt">includes</span><span class="p">:</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">layer:basic</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">layer:apt</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>Good! That was easy! Of course, we can also tell the apt layer what to install here rather than doing so programmatically (such as <code>pip</code>, perhaps even more down the line), so our <code>layer.yaml</code> will look like the following:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="nt">includes</span><span class="p">:</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">layer:basic</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">layer:apt</span>
|
||
<span class="nt">options</span><span class="p">:</span>
|
||
<span class="nt">apt</span><span class="p">:</span>
|
||
<span class="nt">packages</span><span class="p">:</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">python-pip</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>Now we can start testing things out, though lets stick with just the build step for now. When we run <code>charm build</code>, our layers will be composed together and hopefully we’ll wind up with a built charm in our build dir!</p>
|
||
<div class="codehilite"><pre><span></span><code>makyo@corrin:~/work/charms/layers/wsgi-app$ charm build
|
||
build: Composing into /home/makyo/work/charms
|
||
build: Destination charm directory: /home/makyo/work/charms/trusty/wsgi-app
|
||
fatal: Not a git repository <span class="o">(</span>or any of the parent directories<span class="o">)</span>: .git
|
||
bzr: ERROR: Not a branch: <span class="s2">"/home/makyo/work/charms/layers/wsgi-app/"</span>.
|
||
build: Please add a <span class="sb">`</span>repo<span class="sb">`</span> key to your layer.yaml, with a url from which your layer can be cloned.
|
||
build: Processing layer: layer:basic
|
||
build: Processing layer: layer:apt
|
||
build: Processing layer: wsgi-app
|
||
</code></pre></div>
|
||
|
||
|
||
<p>Well that looks…promising! There’s a lot of green, at least. There’s a few warnings we can address, though. I hadn’t initialized the charm as a git repo yet, because it was created through <code>charm create</code>, so let’s do that now:</p>
|
||
<div class="codehilite"><pre><span></span><code>makyo@corrin:~/work/charms/layers/wsgi-app$ git init .
|
||
Initialized empty Git repository in /home/makyo/work/charms/layers/wsgi-app/.git/
|
||
makyo@corrin:~/work/charms/layers/wsgi-app$ git remote add origin git@github.com:makyo/wsgi-app.git
|
||
makyo@corrin:~/work/charms/layers/wsgi-app$ git pull origin master
|
||
remote: Counting objects: <span class="m">5</span>, <span class="k">done</span>.
|
||
remote: Compressing objects: <span class="m">100</span>% <span class="o">(</span><span class="m">4</span>/4<span class="o">)</span>, <span class="k">done</span>.
|
||
remote: Total <span class="m">5</span> <span class="o">(</span>delta <span class="m">0</span><span class="o">)</span>, reused <span class="m">0</span> <span class="o">(</span>delta <span class="m">0</span><span class="o">)</span>, pack-reused <span class="m">0</span>
|
||
Unpacking objects: <span class="m">100</span>% <span class="o">(</span><span class="m">5</span>/5<span class="o">)</span>, <span class="k">done</span>.
|
||
From github.com:makyo/wsgi-app
|
||
* branch master -> FETCH_HEAD
|
||
* <span class="o">[</span>new branch<span class="o">]</span> master -> origin/master
|
||
makyo@corrin:~/work/charms/layers/wsgi-app$ mv README.ex README.md
|
||
</code></pre></div>
|
||
|
||
|
||
<p>And update our <code>layers.yaml</code> to add the repo key as suggested:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="nt">includes</span><span class="p">:</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">layer:basic</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">layer:apt</span>
|
||
<span class="nt">repo</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">https://github.com/makyo/wsgi-app.git</span>
|
||
<span class="nt">options</span><span class="p">:</span>
|
||
<span class="nt">apt</span><span class="p">:</span>
|
||
<span class="nt">packages</span><span class="p">:</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">python-pip</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>Now, when we run <code>charm build</code>, we should get a cleaner result:</p>
|
||
<div class="codehilite"><pre><span></span><code>makyo@corrin:~/work/charms/layers/wsgi-app$ charm build
|
||
build: Composing into /home/makyo/work/charms
|
||
build: Destination charm directory: /home/makyo/work/charms/trusty/wsgi-app
|
||
build: Processing layer: layer:basic
|
||
build: Processing layer: layer:apt
|
||
build: Processing layer: wsgi-app
|
||
</code></pre></div>
|
||
|
||
|
||
<p>Perfect! We’re on a roll.</p>
|
||
<p>Our next step will be to clean up some of the code created by bootstrap. For starters, we can make <code>metadata.yaml</code> agree with reality as best we can for now - we’ll leave the relations section as is until we get to that point - and to specify which series we want the charm to support (trusty and xenial, in our case):</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="nt">name</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">wsgi-app</span>
|
||
<span class="nt">summary</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">charm for running any WSGI application</span>
|
||
<span class="nt">maintainer</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">Madison Scott-Clary <Madison.Scott-Clary@canonical.com></span>
|
||
<span class="nt">description</span><span class="p">:</span> <span class="p p-Indicator">|</span>
|
||
<span class="no">WSGI applications such as Django or Flask applications are web applications</span>
|
||
<span class="no">written in python. This charm allows those applications to talk to a</span>
|
||
<span class="no">database, a web server, a search engine, and a cache.</span>
|
||
<span class="nt">tags</span><span class="p">:</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">misc</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">cms</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">app-servers</span>
|
||
<span class="nt">series</span><span class="p">:</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">trusty</span>
|
||
<span class="p p-Indicator">-</span> <span class="l l-Scalar l-Scalar-Plain">xenial</span>
|
||
<span class="nt">subordinate</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">false</span>
|
||
<span class="nt">provides</span><span class="p">:</span>
|
||
<span class="nt">provides-relation</span><span class="p">:</span>
|
||
<span class="nt">interface</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">interface-name</span>
|
||
<span class="nt">requires</span><span class="p">:</span>
|
||
<span class="nt">requires-relation</span><span class="p">:</span>
|
||
<span class="nt">interface</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">interface-name</span>
|
||
<span class="nt">peers</span><span class="p">:</span>
|
||
<span class="nt">peer-relation</span><span class="p">:</span>
|
||
<span class="nt">interface</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">interface-name</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>We’ll also need to update <code>config.yaml</code> for some configuration settings that <code>layer:apt</code> requires, and to get rid of the placeholders. Our resulting file should look like this:</p>
|
||
<div class="codehilite"><pre><span></span><code><span class="nt">options</span><span class="p">:</span>
|
||
<span class="nt">install_sources</span><span class="p">:</span>
|
||
<span class="nt">type</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">string</span>
|
||
<span class="nt">default</span><span class="p">:</span> <span class="s">''</span>
|
||
<span class="nt">description</span><span class="p">:</span> <span class="p p-Indicator">|</span>
|
||
<span class="no">Any additional sources (such as PPAs) from which to install packages</span>
|
||
<span class="nt">install_keys</span><span class="p">:</span>
|
||
<span class="nt">type</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">string</span>
|
||
<span class="nt">default</span><span class="p">:</span> <span class="s">''</span>
|
||
<span class="nt">description</span><span class="p">:</span> <span class="p p-Indicator">|</span>
|
||
<span class="no">Any additional GPG keys required for sources added by install_sources</span>
|
||
<span class="nt">extra_packages</span><span class="p">:</span>
|
||
<span class="nt">type</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">string</span>
|
||
<span class="nt">default</span><span class="p">:</span> <span class="s">''</span>
|
||
<span class="nt">description</span><span class="p">:</span> <span class="p p-Indicator">|</span>
|
||
<span class="no">Any additional packages to install on the charm's machine</span>
|
||
</code></pre></div>
|
||
|
||
|
||
<p>Again, while we might come up with more configuration values in the future, this will do for now. Running <code>charm build</code> again gives us another successful output, though it’s worth noting that, since we changed the charm from a single series to a multi-series charm, it is now built into <code>$JUJU_REPOSITORY/builds</code>.</p>
|
||
<hr />
|
||
<p>It’s getting late and that was a lot of information to dump, so I’ll pause here for now. We still have a ways to go - I’ve got at least three future posts lined up for this project - but we’re getting closer with each step. We’ve started work on our <code>wsgi-app</code> layer, which, when built, produces a functional skeleton of the charm we eventually want.</p>
|
||
<p>Here are some resources for the time being:</p>
|
||
<ul>
|
||
<li><a href="https://github.com/makyo/wsgi-app/tree/710b7efe21440e49b78cb99f2f4d7b83feff938a">Source code for the <code>wsgi-app</code> layer</a> as it was at the point reached at the end of this article.</li>
|
||
<li><a href="https://jujucharms.com/docs/stable/developer-layers">Documentation on charm layers</a></li>
|
||
<li><a href="http://interfaces.juju.solutions">List of charm layers and interfaces</a></li>
|
||
<li><a href="https://jujucharms.com/docs/stable/reference-charm-hooks">Documentation on charm hooks</a></li>
|
||
</ul>
|
||
<hr />
|
||
<div class="footnote">
|
||
<hr />
|
||
<ol>
|
||
<li id="fn:disclaimer">
|
||
<p>As always, views are my own, not my employer’s. <a class="footnote-backref" href="#fnref:disclaimer" title="Jump back to footnote 1 in the text">↩</a></p>
|
||
</li>
|
||
<li id="fn:furries-tech">
|
||
<p>Seriously. After students (54%), nearly 10% of furries are employed in the tech industry, making it the most common occupation within the subculture. (The Furry Poll, conducted March-December 2015, <em>n=11831</em>) <a class="footnote-backref" href="#fnref:furries-tech" title="Jump back to footnote 2 in the text">↩</a></p>
|
||
</li>
|
||
<li id="fn:rr-diagrams">
|
||
<p>Credit where it’s due, railroad diagrams created with the help of <a href="http://bottlecaps.de/rr/ui">this tool</a> by Gunther Rademacher. <a class="footnote-backref" href="#fnref:rr-diagrams" title="Jump back to footnote 3 in the text">↩</a></p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</article>
|
||
<footer>
|
||
<p>Page generated on 2020-06-24</p>
|
||
</footer>
|
||
</main>
|
||
<script type="text/javascript">
|
||
document.querySelectorAll('.tag').forEach(tag => {
|
||
let text = tag.innerText;
|
||
tag.innerText = '';
|
||
tag.innerHTML = `<a href="/tags.html#${text}">${text}</a>`;
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|