Hi,

This thread is to raise awareness around some of the implementation level
decisions that were taken when refactoring Puppet modules and splitting
them into their own respective GitHub repos.

* - Decouple Hiera from Puppet modules*
In last Puppet-Modules release Hiera lookups were done in <product
module>/manifests/init.pp which made it mandatory for users to use Hiera.
As part of the refactoring Hiera is made optional and configuration
parameters are defined as class parameters which can be passed by site.pp


* - Use Hiera only as a data store*
There were some discussions about creating hooks in Puppet manifest to
which Puppet resources can be plugged in via Hiera data. However, going
forward we have come to a conclusion that Hiera should only be used as a
data store and nothing more. Any customizations to Puppet manifest can be
done directly in init.pp.

* - Break Puppet configurations into stages*
We have identified following stages which can be considered completely
independent from each other;
system - set operating system configs, install packages etc.
clean - remove any existing installation
install - extract the pack and set user permissions
configure - populate templates, copy config files, import certs
service - start the service

Here is a snippet of wso2as/manifests/init.pp

contain wso2base
contain wso2base::system
contain wso2base::clean
contain wso2base::install
contain wso2base::configure
contain wso2base::service

Class['::wso2base'] -> Class['::wso2base::system']
-> Class['::wso2base::clean'] -> Class['::wso2base::install']
-> Class['::wso2base::configure'] ~> Class['::wso2base::service']

As you can see Puppet class containment [1] is used to ensure the
dependency ordering. This is useful when users combine WSO2 Puppet modules
with other modules (for eg: when creating roles and profiles).

* - Remove inter module class inheritance*
As per official Puppet docs class inheritance is to be avoided whenever
possible [2]. Considering this we have removed all such relationships
except for params.pp which contains default values.

* - Move default values to params.pp and remove wso2base/params.pp*
After giving much thought, we decided to keep default values in
<puppet-module>/manifests/params.pp and only in that place. Having common
default values in <wso2base>/manifests/params.pp would minimize duplication
but would be less readable for end users. Therefore we have come to a
conclusion that wso2base module should only be used as a common
resources/classes pool. It should not contain any data.

*Try it out!*

1. Git clone https://github.com/wso2/puppet-common
2. Run puppet-common/setup.sh -p as
3. Goto puppet-common/vagrant
4. Run vagrant up


[1]
https://docs.puppet.com/puppet/latest/reference/lang_containment.html#containing-classes
[2] https://docs.puppet.com/guides/style_guide.html#class-inheritance

Thanks.

-- 
Akila Ravihansa Perera
WSO2 Inc.;  http://wso2.com/

Blog: http://ravihansa3000.blogspot.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to