Custom Fact Deployment

56 views
Skip to first unread message

Alessandro Ciappei

unread,
Aug 3, 2023, 7:32:06 AM8/3/23
to Puppet Users
Hello All,

maybe it's already has been discussed, I tried to search but I didn't find the right thread.
I'm not expert in Puppet and made simple scripts.

I'm using RHEL Satellite with Puppet 7 ENC (I know that RHEL want to move out from puppet, but until i can integrate it I will use it, after I will see).

I need to crate a custom fact to see some information based on IP Address.
I created a Bash Script that give me an output of the location based on CIDR, but I want use full automation and begin to launch specific class based on fact.

I don't know where I need to start, i read how create a fact but it still confusing because I can't find the directory where put the script or how deploy in all my clients.

Someone can help me, maybe with step by step to understand it.

Thank you in advance who want to help me.
All the best
Alex

Mike Langhorst

unread,
Aug 3, 2023, 5:06:14 PM8/3/23
to Puppet Users
My experiences are with Puppet enterprise, but most of this should port directly over to your needs.

Early on, I created a module of my own $org_custom_facts, so that I could keep all of them together, when they weren't part of some other specific module.

If you want to write a shell script, like you say you already have, it will need to output the fact back to stdout as a key=value format such as location=Dallas.  Put this in your module in a subdirectory of facts.d.

Then just add this module to the environment, with Puppet Enterprise this would be in the Puppetfile thru control repo.  You don't need to include this module to any hosts or host classes, just having it within the environment would make this fact available to use.

Mike

Martin Alfke

unread,
Aug 7, 2023, 8:17:55 AM8/7/23
to puppet...@googlegroups.com
Hi Alessandro,

There are two options on how to deploy external facts:

1. Manual:

Place the executable bash script in /etc/puppetlabs/facter/facts.d

2. Automatic (using a module)

Add the script (with executable flag) to a module in path facts.d/
Pluginsync will then deploy the bash script to all nodes.

Please note that pluginsyc will download the bash scripts to any Puppet agent, regardless of OS.

Hth,
Martin


--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/e17d49d4-a0e3-4441-86f3-133a227d413cn%40googlegroups.com.

Dirk Heinrichs

unread,
Aug 7, 2023, 9:40:44 AM8/7/23
to puppet...@googlegroups.com
Am Montag, dem 07.08.2023 um 10:17 +0200 schrieb Martin Alfke:

Please note that pluginsyc will download the bash scripts to any Puppet agent, regardless of OS.

..., so if you also have to manage Windows nodes, it's better to write the facts in Ruby and put them into "<any module>/lib/facter/", with extension ".rb".

HTH...

Dirk
-- 
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
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.

acia...@icloud.com

unread,
Aug 9, 2023, 5:27:34 PM8/9/23
to puppet...@googlegroups.com

Thank you everyone.

I will try the Martin suggestion, and I will let you know if it’s works

 

All the best

Alex

 

--
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/pnDaSW0uOXI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/EBCA31FE-29C8-4563-BCED-311F6CD67F19%40gmail.com.

Matthew Dennison

unread,
Aug 11, 2023, 1:57:29 PM8/11/23
to puppet...@googlegroups.com
We kind of use both:
Manual facts
* Activate required modules
* Define the group set of facts to be loaded via the automatic facts module

Automatic (using module)
* Define facts by group sets

Manual facts are set when we onboard a server and rarely touched again.  Automatic on the other hand are updated regularly and we average about 500 facts per group set.

Regards
Matt

Ben Parry

unread,
Aug 28, 2023, 7:41:32 PM8/28/23
to Puppet Users

If you write your bash script in Ruby (maybe ask chatgpt to do it) and put it in your class in the folder lib/facter your next puppet run will automatically update the facts and it will be available.

Best you read this page;
Reply all
Reply to author
Forward
0 new messages