open foam #0

Supports: bionic
Add to new model


OpenFOAM is free, open source software for CFD from the OpenFOAM Foundation.

Apt layer

The Apt layer for Juju enables layered charms to more easily deal with deb packages and apt sources in a simple and efficient manner. It provides consistent configuration for operators, allowing them to easily specify custom apt sources and additional debs required for their particular installations.


The charm may provide defaults for these service configuration (config.yaml) options, and the operator may override them as required.

  • extra_packages

A space separated list of additional deb packages to install on each unit.

  • package_status

'install' or 'hold'. When set to hold, packages installed using the Apt layer API will be pinned, so that they will not be automatically upgraded when package updates are performed. 'hold' is particularly useful for allowing a service such as Landscape to automatically apply security updates to most of the system, whilst holding back any potentially service affecting updates.

  • install_sources

A list of apt sources containing the packages that need to be installed. Each source may be either a line that can be added directly to sources.list(5), or in the form ppa:/ for adding Personal Package Archives, or a distribution component to enable. The list is a yaml list, encoded as a string. The nicest way of declaring this in a yaml file looks like the following (in particular, the | character indicates that the value is a multiline string):

yaml install_sources: | - ppa:stub/cassandra - deb 21x main

  • install_keys

A list of GPG signing keys to accept. There needs to be one entry per entry in install_sources. null may be used if no keep is needed, which is the case for PPAs and for the standard Ubuntu archives. Keys should be full ASCII armoured GPG public keys. GPG key ids are also accepted, but in most environments this mechanism is not secure. The install_keys list, like install_sources, must also be a yaml formatted list encoded as a string:

```yaml install_keys: | - null - | -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1

      -----END PGP PUBLIC KEY BLOCK-----



Queue packages for installation, and have handlers waiting for these packages to finish being installed:

import charms.apt

def install():

def install_gnupg():

def grabit():


Several methods are exposed in the charms.apt Python package.

  • add_source(source, key=None)

Add an apt source.

A source may be either a line that can be added directly to sources.list(5), or in the form ppa:/ for adding Personal Package Archives, or a distribution component to enable.

The package signing key should be an ASCII armoured GPG key. While GPG key ids are also supported, the retrieval mechanism is insecure. There is no need to specify the package signing key for PPAs or for the main Ubuntu archives.

It is preferable if charms do not call this directly to hard coded apt sources, but instead have these sources listed as defaults in the install_sources config option. This allows operators to mirror your packages to internal archives and deploy your charm in environments without network access.

Sets the apt.needs_update reactive flag.

  • queue_install(packages, options=None)

Queue one or more deb packages for install. The actual package installation will be performed later by a handler in the apt layer. The apt.installed.{name} flag will be set once the package installed (one flag for each package).

If a package has already been installed it will not be reinstalled.

If a package has already been queued it will not be requeued, and the install options will not be changed.

  • installed()

Returns the set of deb packages installed by this layer.

  • purge(packages)

Purge one or more deb packages from the system


These methods are called automatically by the reactive framework as reactive flag demands. However, you can also invoke them directly if you want the operation done right now.

  • update()

Update the apt cache. Removes the apt.needs_update flag.

  • install_queued()

Installs deb packages queued for installation. On success, removes the apt.queued_installs flag, sets the apt.installed.{packagename} flag for each installed package, and returns True. On failure, sets the unit workload status to blocked and returns False. The package installs remain queued.

Layer Options

Automatic package installation

Packages can be specified at charm-build time in layer.yaml. List the packages in the 'basic' or 'apt' sections.

  - layer:basic
  - layer:apt
      - python3-psycopg2
      - git
      - bzr

Packages required to import your Python reactive handlers should go under 'basic'. These get installed by the base layer very early during charm bootstrap, and only packages available in the main Ubuntu archive can go here. Other packages should go under 'apt'. These will be installed later, after custom apt sources such as PPAs have been added from the install_sources configuration option.

Application version number

The application version number may be automatically set by specifying a package name in layer.yaml.

  - layer:basic
  - layer:apt
      - apache2
    version_package: apache2
    full_version: False

The default for full_version is False, meaning the shorter 'upstream' version number will be used. Setting full_version to True will set the application version to the full Debian version number for the package.


This layer is maintained on Launchpad by Stuart Bishop (

Code is available using git at git+ssh://

Bug reports can be made at

Queries and comments can be made on the Juju mailing list, Juju IRC channels, or at


(string) Space separated list of extra deb packages to install.
(string) List of signing keys for install_sources package sources, per charmhelpers standard format (a yaml list of strings encoded as a string). The keys should be the full ASCII armoured GPG public keys. While GPG key ids are also supported and looked up on a keyserver, operators should be aware that this mechanism is insecure. null can be used if a standard package signing key is used that will already be installed on the machine, and for PPA sources where the package signing key is securely retrieved from Launchpad.
- | -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1 mQENBFeGXxcBCACpBHAlBk67MVnHtLux0eI/gJuo5eTSLzQ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fPyCvz9zqKm1gQsscmrNFij/F9TeNY +oEjRoXwwnyM5YiexMcxhLp2NPjagFU0lNS8gCFy2QARAQABiQEfBBgBCgAJBQJX hl8XAhsMAAoJEGwNrHKLKdgXShUH/1rUNk9MvoZ9HBdvm7/z70J64cnNPjIwPuhO 5FMihCMmnsESjCgzrP6rVDOma4psf7fwEe8m1cltl8gVQ1cZIo2LO/0XnbBeo9b9 hA+RqtKz9IZYqNzbvGxEbkhMf6O/TDSFmJpAueh8D3/Dgcrvya0bflkwoGl7RDKu Iq68v4Ri1s4LAq8RCIsB85NKds2vLIAuMrhbhtwYEVgalPotMMHX/MMrKL5T95Ac /GuySu+Yk7kmfrFq0SIzP1BFGv+l84ke18zMu0ssGHVGY0eaEEpO2aude+HhMJqD +PmSM0ZDHsJu4It2PIIGtgGWfai9ddXOI2+z8W6ugsKr/tq7Sik= =DlyX -----END PGP PUBLIC KEY BLOCK-----
(string) List of extra apt sources, per charm-helpers standard format (a yaml list of strings encoded as a string). Each source may be either a line that can be added directly to sources.list(5), or in the form ppa:<user>/<ppa-name> for adding Personal Package Archives, or a distribution component to enable.
- ""
(string) The status of service-affecting packages will be set to this value in the dpkg database. Valid values are "install" and "hold".