Ask Your Question
0

Is there any good way how to execute just part of the module?

asked 2014-04-03 05:26:38 -0500

jaksky gravatar image

updated 2014-04-03 06:29:05 -0500

Hello,

is there some good way how to execute just part of the module (some class)? I have a technological module which installs given technology. My init.pp contains the sequence how that is installed + bunch of variables needed for installation. Package is self contained.

Now I got into situation when I would need to create just configuration files - I would like to avoid duplicating code for configuration as it is essential to keep it in sync. Second - Do I need to include module if I just want to access variables defined in init.pp of that mdule?

Thx

edit retag flag offensive close merge delete

Comments

Do you mean that you have only the init.pp file. You could create sub-classes that would benefit from all the variables of the base class. The famous example is ...(more)

doc75 gravatar imagedoc75 ( 2014-04-03 06:51:55 -0500 )edit

No. I have an init.pp file and sub-classes dedicated for special purposes e.g. repository definitions, directories, installation, configuration etc. And sequence/ordering is defined in init.pp plus ...(more)

jaksky gravatar imagejaksky ( 2014-04-03 07:13:01 -0500 )edit

every time that I make a new module I make a separete class to parameters and variables if I need to just access them.

Renan Vicente gravatar imageRenan Vicente ( 2014-04-03 07:30:07 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-04-03 07:40:04 -0500

ffrank gravatar image

All resources are tagged with the name of the class they are defined in (among other things).

class tools::config {
  ...
}

To evaluate only resources from this class, use

puppet agent --test --tags tools::config
edit flag offensive delete link more

Comments

I moved my parameters to dedicated class: class pig::module_config { # DO NOT MODIFY $pig_user = 'pig' $pig_conf_dir = '/etc/pig/conf' $pig_log_dir = '/var/log/pig' $pig_pid_dir = '/var/run/pig' } from init.pp where those get replace with include pig::module_config. But the rest of code cannot access it now

jaksky gravatar imagejaksky ( 2014-04-30 09:27:08 -0500 )edit

Not sure what's going on there, but I feel that moving variables to a different class is unrelated. Please open a new question if that doesn't work for you. For the issue at hand, take care to seperate the *resources* that you want to sync independently into their dedicated class.

ffrank gravatar imageffrank ( 2014-04-30 15:17:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-04-03 05:26:38 -0500

Seen: 85 times

Last updated: Apr 03 '14