Questions tagged [facter]

Facter is an independent, cross-platform Ruby library bundled with Puppet, designed to gather basic node information about the hardware and operating system

Developed by Puppet Labs to help with automated system configuration management. A puppet manifest declares the required state of the machine. Facter retrieves the current state, so that Puppet can work out what changes need to be made, and how.

The Facter gem can be used by any Ruby system, without the rest of Puppet.

117 questions
1
vote
1 answer

What does setcode mean and how to catch errors inside it?

I've written the following fact. The external command sometimes throws an error, which I want to catch. I've found many examples of how to catch an error using begin...end block. Unfortunately none of these concern the setcode do...end block. In…
Adam Ryczkowski
  • 7,592
  • 13
  • 42
  • 68
1
vote
2 answers

Puppet facter slow for some network facts

I'm learning about vagrant and puppet. When I use the vagrant lucid32 (Ubuntu 10.04), puppet seems very slow. I've fixed the fqdn problem (question 7780322) but it's still very slow. I've traced (part of) the problem to facter. Asking for ipaddress…
John
  • 6,701
  • 3
  • 34
  • 56
0
votes
1 answer

node name within custom puppet fact?

How do I access the name of the puppet node (i.e., $trusted['certname'] in a manifest) within the context of a custom fact (i.e., lib/facter/my_custom_fact.rb). I read this question/answer, and that filled me with hope, but alas, I see no reference…
hoffmanc
  • 614
  • 9
  • 16
0
votes
1 answer

Writing structured facts

I've wrote some ruby code which will run on a linux server and return details about the server as a fact. It does this by connecting to amazon and retrieving some json (it runs two separate commands one to retrieve a list of disks - e.g /dev/sda1,…
keeer
  • 783
  • 1
  • 5
  • 11
0
votes
1 answer

Using facts inside a module to push data to file

I'm trying to create a simple module that will use facts from the agent to push the relevant output to file.. I've already managed to do it in one module but for an unknown reason it doesn't work as expected.. this is what I did class testrepo { …
0
votes
1 answer

How to reference hiera variable elsewhere in hiera?

We are using the roles pattern in puppet with hiera, meaning we have these lines in hiera.yaml: - name: "Roles data" path: "roles/%{::server_role}.yaml" We have a custom fact that produces the role name when facter runs, but we would like to move…
Edward Ned Harvey
  • 6,525
  • 5
  • 36
  • 45
0
votes
2 answers

How can I override facter's os facts during local testing on a different operating system?

Environment I am currently using Puppet 6.21.1 on Ruby 2.7.4 with PDK 2.3.0 (mostly for linting and launching the Puppet console as a REPL). The OS is macOS Monetery. If it matters, I'm running Ruby under RVM 1.29.12-next with a module-specific…
Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
0
votes
1 answer

Error: Facter: GCE metadata request failed: Timeout was reached

This is regarding the GCP compute instances. My GCP instances are not able to fetch the GCE metadata from the metadata server & therefore when I am installing Openstack on google cloud (GCP) via packstack over a CentOS image I am getting this…
0
votes
1 answer

How to create puppet external structured facts from script, such as python or bash?

I have seen the documentation, especially External Facts and Custom Facts. I have the following yum_repos.rb: require 'facter' Facter.add('yum_repos') do setcode '/usr/bin/python3 /opt/puppetlabs/puppet/cache/lib/facter/yum_repos.py' end I have…
Edward Ned Harvey
  • 6,525
  • 5
  • 36
  • 45
0
votes
1 answer

In what order will facts found in files under a module/lib/facter/* be loaded on a puppet client?

I have the following file structure: lib └── facter ├── rackspace.rb ├── system_load.rb └── users.rb I want to use a custom fact value found in system_load.rb (let's call this :system_me fact) in another custom fact that I am writing…
cidi30bg
  • 39
  • 8
0
votes
1 answer

Ansible facter - not showing facter in bash script

I created a bash script that has facter commands The results of this facter command is stored in a variable. like this: HOST=$(facter hostname) IP=$(facter networking.ip) When I executed this script from an ansible playbook, I got this…
Viviane
  • 1
  • 1
0
votes
1 answer

Is there a way to mock Facter::Core::Execution.execute output in ruby?

I have a custom fact in ruby that uses Facter::Core::Execution.execute to execute a system command and sets the fact to true or false based on the output of the execute command. Is there a way I could mock the output of the execute command to test…
Yong zhu
  • 103
  • 1
  • 1
  • 6
0
votes
1 answer

Right way to add many facts based on hostname condition

I need to insert multiple facts on many machines(100+) based on its hostname. All the machines get a single app deployed but the app configuration differs and also machines form part of different clusters. I am trying to find the right approach to…
Aseem
  • 33
  • 1
  • 7
0
votes
2 answers

Access data from structured fact in Custom Fact plugin

# file: module/lib/facter/custom_fact.rb Facter.add("test_fact") do setcode do Facter.value(:my_structured_fact::key::key). # This doesn't work end end How can I reference nested levels of structured fact?
Brian Luong
  • 538
  • 3
  • 15
0
votes
3 answers

How to Import-Module in Windows 2008 R2 using Puppet facter?

I'm creating a puppet custom fact using ruby script to output some AD related details. I learned the ServerManager is a prerequisite module as this is not automatically added in the Windows 2008 R2 build yet. I have manually run my powershell…