How to add machine specifications to a bundle

Bundles may optionally include a machine specification, which allows you to set up specific machines and then to place application units on those machines however you wish. This is done by including a machines field at the root of the bundle file and then defining machines based on an integer. These machines are objects with three possible fields: series, constraints, and annotations. Finally, these machines are referred to in a charm’s definition by using the placement key to. For example:

mysql:
  charm: "cs:mysql-57"
  num_units: 1
  to: 0
  annotations:
    "gui-x": "139"
    "gui-y": "168"
machines:
  "0":
    series: trusty
    constraints: arch=amd64 cores=1 mem=1740 root-disk=8192

This will install the MySQL application on machine ‘0’, which has been assigned a specific series and a collection of constraints.

You may also specify multiple machines for placing multiple units of an application. For example:

mysql:
  charm: "cs:mysql-57"
  num_units: 2
  to: 0, 1
  annotations:
    "gui-x": "139"
    "gui-y": "168"
machines:
  "0":
    series: trusty
    constraints: arch=amd64 cores=1 mem=1740 root-disk=8192
  "1":
    series: trusty
    constraints: arch=amd64 cores=4 mem=4096 root-disk=8192

This will install one unit of the MySQL application on machine ‘0’ and the other on machine ‘1’.


Last updated 11 months ago.