Is this the right way of doing it?

55 views
Skip to first unread message

Sergiu Cornea

unread,
Jun 11, 2015, 10:22:40 AM6/11/15
to puppet...@googlegroups.com
Good afternoon guys,

I have been assigned with the task of creating something like this: https://github.com/duritong/puppet-webhosting/tree/master/manifests  which I successfully implemented however, in order to add an extra variable you will have to add it in all your module manifests, say for example you want to add a debug variable you will need it to add it in each manifest file. My question is if this the right way to approach this? Or there is a better solution? 

define webhosting::php::spip(
$ensure = present,
$configuration = {},
$uid = 'absent',
$uid_name = 'absent',
$gid = 'uid',
$gid_name = 'absent',
$user_provider = 'local',
$password = 'absent',
$password_crypted = true,
$domainalias = 'www',
$server_admin = 'absent',
$logmode = 'default',
$owner = root,
$group = 'sftponly',
$run_mode = 'normal',
$run_uid = 'absent',
$run_uid_name = 'absent',
$run_gid = 'absent',
$run_gid_name = 'absent',
$watch_adjust_webfiles = 'absent',
$user_scripts = 'absent',
$user_scripts_options = {},
$wwwmail = false,
$allow_override = 'FileInfo',
$do_includes = false,
$options = 'absent',
$additional_options = 'absent',
$default_charset = 'absent',
$ssl_mode = false,
$php_settings = {},
$php_options = {},
$vhost_mode = 'template',
$template_partial = 'absent',
$vhost_source = 'absent',
$vhost_destination = 'absent',
$htpasswd_file = 'absent',
$nagios_check = 'ensure',
$nagios_check_domain = 'absent',
$nagios_check_url = '/',
$nagios_check_code = '200',
$nagios_use = 'generic-service',
$mod_security = true,
){

Thank you for you help!

Regards,
Cip

This message and its attachments are private and confidential. If you have received this message in error, please notify the sender and remove it and its attachments from your system.

The University of Westminster is a charity and a company limited by guarantee. Registration number: 977818 England. Registered Office: 309 Regent Street, London W1B 2UW.

Message has been deleted

Sergiu Cornea

unread,
Jun 12, 2015, 4:14:00 AM6/12/15
to puppet...@googlegroups.com
No help? :(

jcbollinger

unread,
Jun 12, 2015, 10:58:36 AM6/12/15
to puppet...@googlegroups.com


On Friday, June 12, 2015 at 3:14:00 AM UTC-5, Sergiu Cornea wrote:
No help? :(


I'm afraid I don't understand the question.  In particular, you assert that "in order to add an extra variable you will have to add it in all your module manifests," but that certainly is not true in an absolute sense.  Nothing in Puppet prevents you from adding a class variable or even a class parameter (note: not quite the same thing) to just one class in your module.  It must therefore be that you have some functional or structural requirement that leads you to your conclusion, but that is opaque to me.


John

Tom Limoncelli

unread,
Jun 30, 2015, 10:01:48 AM6/30/15
to puppet...@googlegroups.com
If you add a parameter to a define, it is important to provide a default that lets current code work without being modified.  If there is no default, than any current user of the define will get an error.  This is how one makes changes but retains backwards compatibility.

I'm not sure I understand the question, so apologies in advance if this is not the answer you are looking for.

Is the concern that every time you call this define you will have to repeat many, many parameters with the same values, with only a few being different?  If that is the case, you can define some resource defaults.

Webhosting::Php::Spip(
  ensure                 => $variable1,
  configuration          => $variable2,
  uid                    => $variable3,
}

Now any time you call webhosting::php::sip(), you don't have to give the ensure, configuration, or uid, parameters you want them to be $variable1, $variable2, and $variable3 respectively.
(Note: These defaults have scope; they are not global.  More details are in https://docs.puppetlabs.com/puppet/latest/reference/lang_defaults.html#area-of-effect)  You can still override these new defaults by providing the parameters.

Hope that helps,
Tom

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/a956fb4a-8f72-4e3b-9cd4-f8453de958b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Email: t...@whatexit.org    Work: tlimo...@StackOverflow.com
Skype: YesThatTom
Blog:  http://EverythingSysadmin.com

Sergiu Cornea

unread,
Jun 30, 2015, 10:19:37 AM6/30/15
to puppet...@googlegroups.com
Thank you guys,

Well Tom yes that was what I was referring to. 

The thing is like you've mentioned I just don't want keep repeating all the variables on each manifest. Because as you could see from that code I have provided you have a page called lets say Webhosting::Php::Spip and if I create a new one to install lets say nginx I will have to copy all the variables from Webhosting::Php::Spip plus add the additional ones.

So I believe the answer you have given me it is what I was looking for.

Thank you and I will give it a try.

Regards,
Cip
Reply all
Reply to author
Forward
0 new messages