I have a puppet module that deploys a JAR file and writes some property files (using ERB templates). We recently added a βmodeβ to the application, which means that the application can work in different modes depending on the values ββentered in the manifest. My hierarchy is as follows:
Customization
* configuration
** files
* installation
The setting value calls the configuration class and installation class. The installation class deploys the corresponding RPM file according to the mode (s)
The configuration class checks the modes and for each mode calls a class of files with specific parameters of the mode and directory, the reason for this structure is that the value of the properties depends on the actual mode.
The technical problem is that if I have several modes in the manifest (this is my goal), I need to call the file class twice:
if grep($modesArray, $online_str) == [$online_str] { class { 'topology::files' : dir => $code_dir, mode => $online_str } } $offline_str = "offline" $offline_suffix = "_$offline_str" if grep($modesArray, $offline_str) == [$offline_str] { $dir = "$code_dir$offline_suffix" class { 'topology::files' : dir => $dir, mode => $offline_str }
However, in a puppet, you cannot declare the same class twice.
I am trying to figure out how I can call a class twice, or perhaps a method that I can get in my parameters from my ERB files, but I can not figure it out
The documentation says this is possible, but it doesn't say how (I checked here https://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html#declaring-classes ).
So, to summarize, is there a way:
- Calling the same class more than once with different parameters
- (Another way) Create multiple files based on the same ERB file (each time with different parameters)
ruby puppet
Sigal shaharabani
source share