March 2017
Beginner to intermediate
925 pages
18h 11m
English
While Facter's built-in facts are useful, it's actually quite easy to add your own facts. For example, if you have machines in different data centers or hosting providers, you could add a custom fact for this so that Puppet can determine whether any local settings need to be applied (for example, local DNS servers or network routes).
Here's an example of a simple custom fact:
modules/facts/lib/facter and then create the file modules/facts/lib/facter/hello.rb with the following contents:Facter.add(:hello) do
setcode do
"Hello, world"
end
endsite.pp file as follows:node 'cookbook' {
notify { $::hello: }
}[root@cookbook ~]# puppet agent -t Notice: /File[/var/lib/puppet/lib/facter/hello.rb]/ensure: ...
Read now
Unlock full access