Difference between revisions of "Facterhandson"
From Gridkaschool
Line 3: | Line 3: | ||
## you want to create /etc/facter/facts.d/owner |
## you want to create /etc/facter/facts.d/owner |
||
## use a puppet file resource, or try using $modulepath/facts.d/owner |
## use a puppet file resource, or try using $modulepath/facts.d/owner |
||
+ | # Add a file "/etc/role" with choice of value of "web", "data", or "compute" |
||
+ | ## use a puppet file resource to create the file |
||
+ | # Write a custom fact or code external fact to produce "role" fact |
||
+ | ## One way of doing the custom fact, which should live in $modulepath/lib/facter/role.rb: |
||
+ | <source language="ruby"> |
||
+ | require 'facter' |
||
+ | Facter.add("role") do |
||
+ | setcode do |
||
+ | %x{cat /etc/role}.chomp |
||
+ | end |
||
+ | end |
||
+ | </source> |
Revision as of 10:11, 4 September 2014
- Create an external fact with key "owner" with value of your name, or your team
- tips:
- you want to create /etc/facter/facts.d/owner
- use a puppet file resource, or try using $modulepath/facts.d/owner
- Add a file "/etc/role" with choice of value of "web", "data", or "compute"
- use a puppet file resource to create the file
- Write a custom fact or code external fact to produce "role" fact
- One way of doing the custom fact, which should live in $modulepath/lib/facter/role.rb:
require 'facter'
Facter.add("role") do
setcode do
%x{cat /etc/role}.chomp
end
end