Re: [Puppet Users] Create a variable out of a bash command and notify it

2022-12-18 Thread 'Dirk Heinrichs' via Puppet Users
Am Sonntag, dem 18.12.2022 um 05:10 -0800 schrieb Nir Fishler:

/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/execution/

This is the wrong place. Ruby based facts should be put into "lib/facter/" 
inside a module, see https://puppet.com/docs/puppet/7/custom_facts.html.

HTH...

Dirk

--

Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Email: dhein...@opentext.com
Website: 
www.recommind.de
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, 
Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error) please 
notify the sender immediately and destroy this e-mail. Any unauthorized 
copying, disclosure or distribution of the material in this e-mail is strictly 
forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten 
haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. 
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht 
gestattet.

-- 
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/5f19d7bdf006f057658e00f2d5e35392ad304e2c.camel%40opentext.com.


Re: [Puppet Users] Create a variable out of a bash command and notify it

2022-12-18 Thread Nir Fishler
@Martin,

I have tried your approach; I put the facter file underneath:
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/custom_facts/core/execution/

*file:*
username.rb

*content:*
*# username.rb*

*Facter.add(:username) do*
*  setcode do*
*Facter::Core::Execution.execute("/usr/bin/hostname |/usr/bin/awk -F'-' 
{'print $1'}")*
*  end*
*end*

But I keep getting an error:
Error: Evaluation Error: Empty string title at 0. Title strings must have a 
length greater than zero. (line: 1, column: 8) on node 
puppet-master.domain.com

what am I missing here?
On Monday, December 5, 2022 at 10:02:09 AM UTC+2 Nir Fishler wrote:

> Thanks a lot guys for your prompt reply!
>
> Gonna try it out later on.
>
> On Monday, December 5, 2022 at 9:47:52 AM UTC+2 dhei...@opentext.com 
> wrote:
>
>> Am Sonntag, dem 04.12.2022 um 07:43 -0800 schrieb Nir Fishler:
>>
>> Main goal: get a list of upgrade-able packages and notify the user about 
>> it.
>>
>>
>> The puppetlabs-apt module from the Puppet Forge has various facts for 
>> this.
>>
>> HTH...
>>
>> Dirk
>>
>> -- 
>>
>> *Dirk Heinrichs*
>> Senior Systems Engineer, Delivery Pipeline
>> OpenText ™ Discovery | Recommind
>> *Phone*: +49 2226 15966 18 <+49%202226%201596618>
>> *Email*: dhei...@opentext.com
>> *Website*: www.recommind.de
>> Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
>> Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, 
>> Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
>> This e-mail may contain confidential and/or privileged information. If 
>> you are not the intended recipient (or have received this e-mail in error) 
>> please notify the sender immediately and destroy this e-mail. Any 
>> unauthorized copying, disclosure or distribution of the material in this 
>> e-mail is strictly forbidden
>> Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte 
>> Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail 
>> irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und 
>> vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte 
>> Weitergabe dieser Mail sind nicht gestattet.
>>
>

-- 
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/703212ce-9dd7-426a-bb8d-20a0058fc3f1n%40googlegroups.com.


Re: [Puppet Users] Create a variable out of a bash command and notify it

2022-12-05 Thread Nir Fishler
Thanks a lot guys for your prompt reply!

Gonna try it out later on.

On Monday, December 5, 2022 at 9:47:52 AM UTC+2 dhei...@opentext.com wrote:

> Am Sonntag, dem 04.12.2022 um 07:43 -0800 schrieb Nir Fishler:
>
> Main goal: get a list of upgrade-able packages and notify the user about 
> it.
>
>
> The puppetlabs-apt module from the Puppet Forge has various facts for this.
>
> HTH...
>
> Dirk
>
> -- 
>
> *Dirk Heinrichs*
> Senior Systems Engineer, Delivery Pipeline
> OpenText ™ Discovery | Recommind
> *Phone*: +49 2226 15966 18 <+49%202226%201596618>
> *Email*: dhei...@opentext.com
> *Website*: www.recommind.de
> Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
> Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, 
> Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
> This e-mail may contain confidential and/or privileged information. If you 
> are not the intended recipient (or have received this e-mail in error) 
> please notify the sender immediately and destroy this e-mail. Any 
> unauthorized copying, disclosure or distribution of the material in this 
> e-mail is strictly forbidden
> Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte 
> Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail 
> irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und 
> vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte 
> Weitergabe dieser Mail sind nicht gestattet.
>

-- 
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/af3e512b-5b91-4c2b-99bf-d9a2206c85b0n%40googlegroups.com.


Re: [Puppet Users] Create a variable out of a bash command and notify it

2022-12-04 Thread 'Dirk Heinrichs' via Puppet Users
Am Sonntag, dem 04.12.2022 um 07:43 -0800 schrieb Nir Fishler:

Main goal: get a list of upgrade-able packages and notify the user about it.

The puppetlabs-apt module from the Puppet Forge has various facts for this.

HTH...

Dirk

--

Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Phone: +49 2226 15966 18
Email: dhein...@opentext.com
Website: 
www.recommind.de
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, 
Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error) please 
notify the sender immediately and destroy this e-mail. Any unauthorized 
copying, disclosure or distribution of the material in this e-mail is strictly 
forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten 
haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. 
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht 
gestattet.

-- 
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/a09f1640686953fd607a6d380375554ad45c230f.camel%40opentext.com.


Re: [Puppet Users] Create a variable out of a bash command and notify it

2022-12-04 Thread Martin Alfke
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. 

/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  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 puppet-users+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/9793f643-c386-4400-9fba-fd42f3e1269dn%40googlegroups.com
>  
> .

-- 
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/2E282B6E-6BBF-4BA1-99A0-03105F55C43A%40gmail.com.


[Puppet Users] Create a variable out of a bash command and notify it

2022-12-04 Thread Nir Fishler
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/9793f643-c386-4400-9fba-fd42f3e1269dn%40googlegroups.com.