Skip to content
Valentin Haenel edited this page Apr 25, 2014 · 12 revisions

Motivation

  • Separation of concerns

    1. Service Packages bring their own minimal viable configuration
    2. Application Packages bring their additional dependencies (if needed)
    3. Host Configuration brings fine-tuning (if needed)
  • Reduce host-specific configuration, or: "Dont repeat yourself (or your configuration)"

Modularized Configuration Snippets

All *.yaml files in /etc/yadt.conf.d/ get merged

Structure of Host Configuration

  • dictionary of dictionaries, aka map of maps
services:
    fooservice:
    ...
settings:
    foo: bar

Rules for Merging Snippets

  1. Dictionaries get merged (recursivly).

  2. Lists gets concatenated.

  3. Scalars get overwritten (order of files matters here).

Example

Let's configure a host with a spring webapp. We want the webapp to run in the tomcat container, and tomcat itself will run behind a httpd webserver so that it can bind to port 80. We'll have the following packages installed at least :

  • A tomcat package, which should bring a snippet with
services:
    tomcat:
  • An httpd package, which should bring a snippet with
services:
    httpd:
  • A tomcat-with-httpd package, which should require both the tomcat and the httpd package, install some config to connect them and bring a snippet with
services:
    httpd:
        needs_services: [tomcat]
  • A my-webapp package with the actual webapp. This package only needs to require tomcat-with-httpd and will probably bring some additional config for httpd and/or tomcat. It can also modify the existing service definition, e.g. to declare which is the front service:
services:
    httpd:
        is_frontservice: true

The merged result would look like this:

services:
    httpd:
        is_frontservice: true
        needs_services: [tomcat]
    tomcat:
  • Alternatively, the tomcat service might be located on a different machine. In this case, you can use the following syntax to specify a remote service:
services:
    httpd:
        is_frontservice: true
        needs_services: ["service://webserver/tomcat"]

Please bear in mind that the remote service will be readonly unless the host is also available in the target via the target file or by inclusion via metatargets.