1

In my current juju model I have one machine with a few containers

Machine    State 
14         started 
14/lxd/2   started 
14/lxd/20  started 

I want to deploy a local bundle with 2 local charms. My bundle.yaml looks like this:

services:
  elasticsearch:
    charm: /home/user/charms/trusty/elasticsearch
    num_units: 1
    to: ['lxd:14']
  metricbeat:
    charm: /home/user/charms/trusty/metricbeat
series: trusty
relations:
  - - "elasticsearch:client"
    - "metricbeat:elasticsearch"

Now I want my elasticsearch charm in a LXD container on machine 14 but when i run juju deploy ~/elastic5-bundle I get the following error:

ERROR the provided bundle has the following errors:
placement "lxd:14" refers to a machine not defined in this bundle

But when I add machine 14 in my bundle.yaml, a new machine is created instead of the charm being deployed to machine 14. Any possible solution to deploy a charm in a bundle to an existing machine?

2

You can't deploy charms on existing machines by using juju deploy command. Machines should be defined in the bundle for that to work.

Your bundle should look like this:

machines:
  '14':
    constraints: <any constraint for example tags=machine14 or mem=3048 or arch=amd64>

services:
  elasticsearch:
    charm: /home/user/charms/trusty/elasticsearch
    num_units: 1
    to: ['lxd:14']
  metricbeat:
    charm: /home/user/charms/trusty/metricbeat
series: trusty
relations:
  - - "elasticsearch:client"
    - "metricbeat:elasticsearch"

It is probably possible using juju-deployer. Install juju-deployer by adding this repo:

$ sudo add-apt-repository ppa:tvansteenburgh/ppa

Define the bundle as:

phase1:
  services:
    elasticsearch:
      charm: /home/user/charms/trusty/elasticsearch
      num_units: 1
      to: ['lxd:14']
    metricbeat:
      charm: /home/user/charms/trusty/metricbeat
  series: trusty
  relations:
    - - "elasticsearch:client"
      - "metricbeat:elasticsearch"

Now, deploy by running the following command:

$ juju-deployer -c bundle.yaml phase1
1

In the latest Juju version (2.3) I noticed that there is now a flag that you can use when deploying a bundle. I found the documentation here:

To have a bundle use a model's existing machines, as opposed to creating new machines, the --map-machines=existing option is used. In addition, to specify particular machines for the mapping, comma-separated values of the form 'bundle-id=existing-id' can be passed where the bundle-id and the existing-id refer to top level machine IDs.

For example, consider a bundle whose YAML file is configured with machines 1, 2, 3, and 4, and a model containing machines 1, 2, 3, 4, and 5. The following deployment would use existing machines 1 and 2 for bundle machines 1 and 2 but use existing machine 4 for bundle machine 3 and existing machine 5 for bundle machine 4:

juju deploy some-bundle --map-machines=existing,3=4,4=5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.