Hi Nir,

You want to collect information on nodes and you want to use this information 
in a catalog.
This is what facter is used for. 

<module>/lib/facter/upgradable_packages.rb
Facter.add(:upgradable_packages) do
  setcode do
    Facter::Core::Execution.execute("/usr/bin/apt --simulate upgrade | grep 
'^Inst' | awk -F ' ' '{print $2}'")
  end
end

Within your puppet code you can then refer to the fact:

notify { $upgradable_packages: }

Hth,
Martin

> On 4. Dec 2022, at 16:43, Nir Fishler <[email protected]> wrote:
> 
> Hello,
> 
> I'd like to store an output of a bash command into a variable, and then print 
> it to stdout using notify in Puppet.
> 
> Main goal: get a list of upgrade-able packages and notify the user about it.
> 
> I have tried the below but it doesn't seem to work:
> 
> $pkgs_list = $("/usr/bin/apt --simulate upgrade | grep '^Inst' | awk -F ' ' 
> '{print $2}'")
> 
> notify { "STDOUT: ${pkgs_list}": }
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/9793f643-c386-4400-9fba-fd42f3e1269dn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/puppet-users/9793f643-c386-4400-9fba-fd42f3e1269dn%40googlegroups.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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/2E282B6E-6BBF-4BA1-99A0-03105F55C43A%40gmail.com.

Reply via email to