OASIS Topology and Orchestration Specification for Cloud Applications (TOSCA) TC

 View Only

USE CASE: generating puppet manifest

  • 1.  USE CASE: generating puppet manifest

    Posted 07-01-2015 09:13
    The use case is the following: Create an Apache web server with more than 1 Virtual Host. The goal is to use puppet to do the installation of the software (no use in reinventing what works well)   Proposed task is having 2 node_templates where I place all the properties needed in an array called puppet_data Than start with a template placed in the CSAR file and with freemarker substitute the puppet_data in the template.   This way I have 1 template for each node, a generic and reusable node_type for puppet.   My need is to better understand how to mode the "generation of a file" and the "generation of a string that will be an output of one node and the input for the other"   The flow will be: I generate the chunk from the 2 virtual_host nodes than use that  strings as input to generate the "myManifest.pp" for apache. To sum up in YAML:       apache:       type: tosca.nodes.puppet.WebServer.Apache       properties:         puppet_config:           modules:           - puppetlabs_apache         puppet_data:           - { name: port, data: 80}       artifacts:         apache_manifest_template:           type: tosca.artifacts.File           file: apachePuppetTemplate.ftl     apache_vh1:       type: tosca.nodes.puppet.WebServer.VirtualHost.Apache       attributes:         puppet_generated_manifest:       properties:         puppet_data:         - { name: servername, data: www.mysite.com}         - { name: docroot, data: /var/www/www.mysite.com}         - { name: servername, data: "['Indexes','FollowSymLinks','MultiViews']" }         - { name: proxy_pass, data: "[ { 'path' => '/', 'url' => 'ajp://ServiceTomcatDC:8009/' }, ]" }       artifacts:         host_certificate:           type: tosca.artifacts.File           file: www.mysite.com.crt         ca_certificate:           type: tosca.artifacts.File           file: CA.crt         private_key:           type: tosca.artifacts.File           file: my.key         apache_vh_manifest_template:           type: tosca.artifacts.File           file: apacheVHPuppetTemplate.ftl     apache_vh2:       type: tosca.nodes.puppet.WebServer.VirtualHost.Apache       attributes:         puppet_generated_manifest:       properties:         puppet_data:         - { name: servername, data: www.mysite2.com}         - { name: docroot, data: /var/www/www.mysite2.com}         - { name: servername, data: "['Indexes','FollowSymLinks','MultiViews']" }       artifacts:         host_certificate:           type: tosca.artifacts.File           file: www.mysite2.com.crt         ca_certificate:           type: tosca.artifacts.File           file: CA.crt         private_key:           type: tosca.artifacts.File           file: my2.key         apache_vh_manifest_template:           type: tosca.artifacts.File           file: apacheVHPuppetTemplate.ftl In the end the result from the generation process will be a puppet file like the one below where the virtual_host part has been generted by the 2 virtualhost nodes. The problem is that the puppet file needs to be 1 so I need intermediate string to use as input for the final generation. node 'ClearoApacheDC.csi.local' { class { 'apache':       ... omitted for brevity     } apache::vhost { 'www.mysite.com':       options => ['Indexes','FollowSymLinks','MultiViews'],       proxy_pass => [ { 'path' => '/', 'url' => 'ajp://ServiceTomcatDC:8009/' }, ],        } apache::vhost { 'www.mysite2.it':       ... omitted for brevity        }   I think that adding to the standard the option to "generate" file or basic types as output or as artifact result could be useful to implementors Any hints?   Luca     Either we define a new artifact_type that consider that is also possible to have