# different default values in params based on a parameter?

For some reason I cannot see the obvious answers staring back at me, so i am going to toss it out here..

quick back story- In my org, we only own the "get the platform configured" part of system configuration and not anything to do with the actual install of the application on the system. With that, we have different requirements based on the application type that will be running on the system. This includes the application role account, its uid/gid, proc limits ect in order to prepare the platform so they can deploy their application..

I have a functioning module to do this, where we (using foreman) set the role_user variable to something like tomcat, pentaho etc... However in adding in some functionality, I am trying to make the clean up the module / rewrite it a bit...

My issue is what is the best way to do this..

Is there a way to use the params.pp file based on a parameters value to give different defaults (where role_user is defined in the init.pp and possibly overridden by foreman)?

ie

   class app_type::params {
$source_base = "puppet:///modules/${module_name}/"

case $role_user { 'appadm' : {$role_user_group = 'appadm'
$role_user_uid_default = '1302'$role_user_gid_default = '1302'
$role_user_home_default = '/home/appadm'$role_user_comment_default = 'Application Administrator Role'
$role_user_shell_default = '/bin/bash'$file_limits_default = '4096'
$proc_limits_default = 'undef' } 'tomcat' : {$role_user_uid_default = '1301'

# Edit

Since you can't use hostgroup fact, you need to rethink your module: it will not work the way you designed it now, due to the fact that params class will be parsed before entering in the init class. So any variable that will be passed to the main class will not be available to params class.

Short story: if you want to send a parameter to your main class from which you want to decide what parameters to use, you need to move all your logic from params to the main class.

Or not inherit the params class in main class and just include it there. This way you lose all the overwrites and defaults that came with the pattern of using the params class.

more

that is true, however without going into it we aren't yet really using hostgroups right now due to a previous issue on our part in doing so. I know that we should be using them and will be again eventually.

( 2015-10-26 09:26:22 -0500 )edit

That is what I was afraid of (and how it is currently setup).. We currently use a lot of USE_DEFAULTS as the values for parameters, so adding more parameters to the manifest is going to make it longer than i'd like... but it is what it is.... thanks for the input and ideas!

( 2015-10-28 09:31:44 -0500 )edit