Hi Raghuram,

The short of it is that you can't make that work in a Task, the Bolt Task
environment is simply not designed for this. You have to use a plan.
You can have the Plan call the function and pass the results as parameters
to your Task though:

plan mymodule::test {
$func_result = mymodule::func1('arg1', 'arg2')
# assuming mymodule::func1() returns a simple string

run_task('mymodule::mytask', 'target.company.com', 'myparam' => $func_result
)
}

-KevinR


On Thu, Feb 4, 2021 at 12:45 PM Raghu Ram Baisani <baisaniraghu...@gmail.com>
wrote:

> Thanks Kevin
>
> I'm kind of aware of plan option.
>
> Can you please detail the option for task with an example so that I can
> know how it works.
>
> Cheers
> Raghuram Baisani
>
> On Thu, Feb 4, 2021 at 5:12 PM KevinR <kevin.reeuw...@puppet.com> wrote:
>
>> Hi Raghuram,
>>
>> this cannot be (easily) achieved from a Task, as the Task execution
>> environment is not Puppet but basically the target's shell.
>> You can do this from a Bolt Plan however:
>>
>>    1. In your Bolt module (where your task lives), create a functions
>>    folder at the root
>>    2. Place your function in that folder, i.e.f /functions/func1.rb
>>    3. Namespace the function according to your module name, for example
>>    mymodule::func1
>>    4. You can now use the module in a Bolt Plan (under /plans) with
>>    mymodule::func1(args)
>>
>> - KevinR
>> On Thursday, February 4, 2021 at 7:53:46 AM UTC+1 baisani...@gmail.com
>> wrote:
>>
>>> Hi
>>>
>>> Suppose if we have a module named temp,
>>>
>>> and we have a puppet function named func1
>>> which resides in temp\lib\puppet\functions\temp\func1.rb
>>>
>>> and I have another ruby task in the same module,
>>>
>>> temp\tasks\task1.rb
>>>
>>> How can I call puppet function func1 on task task1?
>>>
>>> Any kind help is appreciated
>>>
>>> Cheers
>>> Raghuram Baisani
>>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/puppet-users/c6d2d365-3cc8-4513-b4c3-bb0f062d56d5n%40googlegroups.com
>> <https://groups.google.com/d/msgid/puppet-users/c6d2d365-3cc8-4513-b4c3-bb0f062d56d5n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Puppet Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/puppet-users/psFXomJq4tY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAFfXrBxmXFxLMkZUaGr1bOaMbOjLaS4TNwZdzrAQPqpnmvoJDg%40mail.gmail.com
> <https://groups.google.com/d/msgid/puppet-users/CAFfXrBxmXFxLMkZUaGr1bOaMbOjLaS4TNwZdzrAQPqpnmvoJDg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAPqNtk8e%2BZrirF_pT7Lk439-qKto7TxN0Aw8ZFSFxuVvUVcZ_g%40mail.gmail.com.

Reply via email to