Application components

Application components provide the individual pieces of the multi-node application. They are most often defined types (for reusability), but can also consist of classes or even native resources, such as files, in very simple cases. Application components are created by the exportconsume, or require metaparameters that are used in an application declaration. 

Application components are written as general classes or defined types. They follow the same autoload format as all other Puppet code. The manifest for example::app2 would still be located at manifests/example/app2.ppApplication components can explicitly list the values they export and consume in their individual manifests by placing an additional statement at the bottom of the manifests:

class example::app2 (
# $db_host is provided by the consume of the Database
$db_host,
) {
# Any resources, defined types or class calls in a regular manifest would be placed here.
}
# Note that the consume is outside of the class declaration
Example::App2 consumes Database {
db_host => $host,
}
# Note that the produces is outside of both the class declaration, and above consume
Example::App2 produces Http {
host => $::fqdn,
port => '80',
}

In the preceding sample, $db_host is a value that could be passed to any resource in the manifest. Rather than passing it via Hiera or Puppet DSL, we instead consume that value from the host parameter provided by another application. We also export the node's own FQDN and hostname, so that follow-on applications can use those values to point at the web service created by example::app2Database and Http are both service resources, describing information that's shared between applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.185.196