Hi,

I have done with $Subject.

With the new puppet module structure, a cartridge puppet module can,

   1. override default agent extensions
   2. remove default agent extensions
   3. add new agent extensions

So a cartridge instance will have only those agent behaviors that it should
have. Also, changes in one cartridge module's extensions will not affect
other cartridge modules.

I have created a JIRA to this.
https://issues.apache.org/jira/browse/STRATOS-763

I have sent the pull request.
https://github.com/apache/stratos/pull/22

Thanks.


On Wed, Aug 20, 2014 at 11:44 AM, Chamila De Alwis <[email protected]>
wrote:

> Furthermore Prasanna and I are in the process of writing chef scripts for
> a few the cartridges. We will for the time being go with the current
> structure of keeping the templates on the agent module, as the proposed
> changes would not be implemented within our deadlines. But it should be
> noted down to carry over the changes to Chef after Puppet for consistency
> IMO.
>
>
> Regards,
> Chamila de Alwis
> Software Engineer | WSO2 | +94772207163
> Blog: code.chamiladealwis.com
>
>
>
>
> On Tue, Aug 19, 2014 at 10:13 PM, Chamila De Alwis <[email protected]>
> wrote:
>
>> Great!
>>
>> This seems to be the best way of improving the module structure with
>> regard to agent module. +1
>>
>>
>> Regards,
>> Chamila de Alwis
>> Software Engineer | WSO2 | +94772207163
>> Blog: code.chamiladealwis.com
>>
>>
>>
>>
>> On Tue, Aug 19, 2014 at 8:01 PM, Rajkumar Rajaratnam <[email protected]>
>> wrote:
>>
>>> Hi Chamila,
>>>
>>> To load custom templates (from a cartridge module),
>>>
>>> *content => template("${module}/agent/${name}.erb")*
>>>
>>> We will be creating a directory (agent) inside a cartridge module's
>>> templates directory (puppet/modules/ruby/templates/agent) and keep all
>>> custom agent extension there. We need to separate out agent extension
>>> templates from a module's own templates.
>>>
>>> To load default templates (from agent module),
>>>
>>> *content => template("agent/${name}.erb")*
>>>
>>> So we can make it as a parameter like below;
>>>
>>> define agent::push_templates ($target, $template_dir) {
>>>   file { "${target}/${name}":
>>>     ensure  => present,
>>>     owner   => $agent::owner,
>>>     group   => $agent::group,
>>>     mode    => '0755',
>>>     content => template($template_dir)
>>>   }
>>> }
>>>
>>> In agent's init.pp, we can pass $template_dir accordingly for default
>>> and custom extensions. Note that we need to call agent::push_templates
>>> twice in init.pp to apply default extensions and custom extensions.
>>>
>>> Thanks.
>>>
>>>
>>> On Tue, Aug 19, 2014 at 7:12 PM, Rajkumar Rajaratnam <[email protected]
>>> > wrote:
>>>
>>>> Yes.
>>>>
>>>> Plus, we will modify agent's init.pp and add custom templates (if any)
>>>> in each cartridge module.
>>>>
>>>>
>>>> On Tue, Aug 19, 2014 at 7:02 PM, Chamila De Alwis <[email protected]>
>>>> wrote:
>>>>
>>>>> So in the agent's push_templates defined type we'll replace *content
>>>>> => template("agent/${name}.erb")* with *content =>
>>>>> template("${module}/${name}.erb")*?
>>>>>
>>>>>
>>>>> Regards,
>>>>> Chamila de Alwis
>>>>> Software Engineer | WSO2 | +94772207163
>>>>> Blog: code.chamiladealwis.com
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Tue, Aug 19, 2014 at 4:54 PM, Rajkumar Rajaratnam <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Currently we are having an agent puppet module, which includes all
>>>>>> agent extensions (puppet/modules/agent/templates/extensions/*).
>>>>>>
>>>>>> All the cartridges need these extensions, but with different
>>>>>> behaviors (implementation of these extensions could be different from
>>>>>> cartridge to cartridge). For example, if it is a php cartridge, we need 
>>>>>> to
>>>>>> do certain stuffs when the instance is started. If it is a mysql 
>>>>>> cartridge,
>>>>>> we want to do something else. With current puppet module structure, we 
>>>>>> have
>>>>>> to hard-code cartridge types in extensions to achieve specific behavior
>>>>>> based on cartridge.
>>>>>>
>>>>>> For example, in instance-started extension;
>>>>>>
>>>>>> <%- if @type == 'mysql' -%>
>>>>>> <%= scope.function_template(['agent/extensions/addons/_mysql.erb'])
>>>>>> -%>
>>>>>> <%- end -%>
>>>>>>
>>>>>> <%- if @type == 'ruby' -%>
>>>>>> <%= scope.function_template(['agent/extensions/addons/_ruby.erb']) -%>
>>>>>> <%- end -%>
>>>>>>
>>>>>> IMO, this is not a proper way.
>>>>>>
>>>>>> I guess the proper way is to have some default extensions in agent
>>>>>> module and allow cartridges to override and/or add more extensions 
>>>>>> specific
>>>>>> to them. This way, we don't have to hard-code anything in agent 
>>>>>> extensions.
>>>>>> Modules which need custom extension behavior can override default
>>>>>> extensions and/or add more extensions. If they don't override an 
>>>>>> extension,
>>>>>> default extension will be copied to the instance.
>>>>>>
>>>>>> I am thinking of implementing it as below;
>>>>>>
>>>>>> We introduce two optional parameters to agent class.
>>>>>>       $templates : templates which needs to be overridden
>>>>>>       $module : which module to look up for these templates
>>>>>>
>>>>>> node /ruby/ inherits base {
>>>>>>   require java
>>>>>>   class {'agent':
>>>>>>            module => 'ruby',
>>>>>>            templates =>
>>>>>> ['bin/stratos.sh','extenstions/instance-started.sh'],
>>>>>>   }
>>>>>>   class {'ruby':}
>>>>>>   Class['stratos_base'] -> Class['java'] -> Class['ruby'] ~>
>>>>>> Class['agent']
>>>>>> }
>>>>>>
>>>>>> We keep these templates in the relevant module (ruby in this case)
>>>>>> with appropriate directory structure (ruby/templates/agent/extensions and
>>>>>> ruby/templates/agent/bin) and pass these to the agent class, which will
>>>>>> copy right extensions (default + custom) to the instance.
>>>>>>
>>>>>> WDYT about this approach?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> --
>>>>>> Rajkumar Rajaratnam
>>>>>> Software Engineer | WSO2, Inc.
>>>>>> Mobile +94777568639 | +94783498120
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Rajkumar Rajaratnam
>>>> Software Engineer | WSO2, Inc.
>>>>  Mobile +94777568639 | +94783498120
>>>>
>>>
>>>
>>>
>>> --
>>> Rajkumar Rajaratnam
>>> Software Engineer | WSO2, Inc.
>>>  Mobile +94777568639 | +94783498120
>>>
>>
>>
>


-- 
Rajkumar Rajaratnam
Software Engineer | WSO2, Inc.
Mobile +94777568639 | +94783498120

Reply via email to