Re: [Puppet Users] Set default param value based on another param

2018-10-11 Thread comport3
Hi Eirik, I think I understand what you want to do - set some sensible defaults, and just get the most specific or unique parameters from Hiera. This article by RIP helped me a lot to understand how to do that: https://www.devco.net/archives/2015/12/16/iterating-in-puppet.php ' wildcard and

Re: [Puppet Users] Set default param value based on another param

2018-10-10 Thread Eirik Øverby
On 8 Oct 2018, at 17:05, Henrik Lindberg wrote: > > On 2018-10-08 08:44, Eirik Øverby wrote: >> Hi, >> Sorry for hijacking this thread, but it caught my interest. >> My scenario is that I'd like to re-use the title of an nginx server instance >> in, say, the log file for that server instance.

Re: [Puppet Users] Set default param value based on another param

2018-10-08 Thread Henrik Lindberg
On 2018-10-08 08:44, Eirik Øverby wrote: Hi, Sorry for hijacking this thread, but it caught my interest. My scenario is that I'd like to re-use the title of an nginx server instance in, say, the log file for that server instance. However, since I don't want to touch the nginx module itself,

Re: [Puppet Users] Set default param value based on another param

2018-10-08 Thread Eirik Øverby
Hi, Sorry for hijacking this thread, but it caught my interest. My scenario is that I'd like to re-use the title of an nginx server instance in, say, the log file for that server instance. However, since I don't want to touch the nginx module itself, it seems I have to wrap its server class

Re: [Puppet Users] Set default param value based on another param

2018-10-07 Thread 'Dan White' via Puppet Users
I like Henrik’s solution better than mine. I have been dealing with old versions of Puppet for too long. > On Oct 7, 2018, at 9:47 PM, Jody Des Roches wrote: > > Thank you Dan and Henrik for taking the time to help. > Henrik, your solution is what I am using in concert with common.yaml to add

Re: [Puppet Users] Set default param value based on another param

2018-10-07 Thread Jody Des Roches
Thank you Dan and Henrik for taking the time to help. Henrik, your solution is what I am using in concert with common.yaml to add a default to the base_dir value. Mahalo! -Jody On Sun, Oct 7, 2018 at 5:35 AM Henrik Lindberg wrote: > If you are on a reasonably modern Puppet version you should

Re: [Puppet Users] Set default param value based on another param

2018-10-07 Thread Henrik Lindberg
If you are on a reasonably modern Puppet version you should do it like this: class myclass( String $base_dir, Optional[String] $conf_dir = "${base_dir}/conf" ) { } I tested it as well: class myclass( String $base_dir, Optional[String] $conf_dir = "${base_dir}/conf" ) {

Re: [Puppet Users] Set default param value based on another param

2018-10-06 Thread 'Dan White' via Puppet Users
You need to do like this: class myClass ( String $base_dir, Optional[String] $conf_dir, ) { if $myClass::conf_dir == undef { $myClass::actual_conf_dir = "$myClass::base_dir/conf” } else { $myClass::actual_conf_dir = $myClass::conf_dir } … and then use

[Puppet Users] Set default param value based on another param

2018-10-05 Thread Jody Des Roches
I'd like to set default values for parameters that will be passed to epp templates. However, the default value is based on another parameter. I understand that variables are immutable but this is a parameter that shouldn't be touched unless it wasn't set. Here is an example construct with a