Can we call a ruby function inside puppet plan (Inside same module)

18 views
Skip to first unread message

Raghu Ram Baisani

unread,
Aug 27, 2020, 5:51:49 AM8/27/20
to Puppet Users
Hi All,

If we have a function inside 
/etc/puppetlabs/code/environment/production/modules/<module>/lib/puppet/functions/<module>/<func.rb>

Is it possible to call the func.rb in a plan residing inside 
/etc/puppetlabs/code/environment/production/modules/<module>/  plans/<plan.pp>?

In the mentioned case above both .pp file and .rb file are in same module.
If it is possible then how can we accommodate that.

Thanks
Raghuram 

KevinR

unread,
Aug 27, 2020, 7:32:56 AM8/27/20
to Puppet Users
Hi Raghuram,

yes you can! Simply call the function in the plan, just like you would if calling the function from a standard Puppet manifest.
For example, say you have a function module1::myfunction() in /etc/puppetlabs/code/environment/production/modules/module1/lib/puppet/functions/module1/myfunction.rb.
Calling that function in your plan looks like this:

plan module1::myplan(
  String $some_param
){
  $result = module1::myfunction($some_param)
}

Kind regards,
KevinR
Reply all
Reply to author
Forward
0 new messages