|
Additional test cases: 1. pluginsynced external fact 2. facter cmds in a system absent puppet
1. pluginsynced external fact: tested on centos-7-x86_64
On the Master root directory I (1) created a module: hellofact, containing an external fact, hellofact.rb, which return string "Hello facter!", (2) built it with 'puppet module build hellofact', (3) installed it with install hellofact/pkg/sean-hellofact-0.1.0.tgz, (4) called 'puppet agent -t'. On the agent node I also called 'puppet agent -t'.
On both agent and master, facter behaves the same way when fetching the external fact hellofact. When called with --puppet, the fact is displayed. When called without --puppet, the fact is not displayed.
[root@t08kvwquaxnqa35 ~]# facter -p hellofact
|
Hello facter!
|
[root@t08kvwquaxnqa35 ~]# facter hellofact
|
|
[root@t08kvwquaxnqa35 ~]#
|
2. facter cmds in a system absent puppet Running facter with no puppet.
Tested on fedora-20-x86_64 stable branch 7/22/15 2200 3.0.1 (commit fe9df8a0719361c88fb3726dc535d04b80759871)
In this test, I compiled facter on a Fedora vm and ran it without puppet installed. facter -p generated a the following warning to stderr but did not cause failure (very nice):
2015-07-20 22:30:31.402088 WARN puppetlabs.facter - Could not load puppet; some facts may be unavailable: cannot load such file – puppet
Except for that, the output from invocations with and without the -p option are the same. Tested with --custom-dir, --external-dir
[root@yiyjcvx1os3k4sx bin]# pwd
|
/root/facter/release/bin
|
[root@yiyjcvx1os3k4sx bin]# ls
|
facter facts.d f.out fp.out libfacter_test
|
[root@yiyjcvx1os3k4sx bin]# PATH=.:$PATH
|
[root@yiyjcvx1os3k4sx bin]# facter --version
|
3.0.1 (commit fe9df8a0719361c88fb3726dc535d04b80759871)
|
[root@yiyjcvx1os3k4sx bin]# ### stable branch of facter, leatherman
|
[root@yiyjcvx1os3k4sx bin]#
|
[root@yiyjcvx1os3k4sx bin]# facter os.family
|
[root@yiyjcvx1os3k4sx bin]# facter -p os.family
|
2015-07-20 22:30:31.402088 WARN puppetlabs.facter - Could not load puppet; some facts may be unavailable: cannot load such file -- puppet
|
RedHat
|
[root@yiyjcvx1os3k4sx bin]# cat facts.d/hellofact.rb
|
Facter.add("hellofact") do
|
setcode do
|
Facter::Core::Execution.exec("echo hello factor!\n")
|
end
|
end
|
|
[root@yiyjcvx1os3k4sx bin]# facter --custom-dir facts.d/ hellofact
|
hello factor!
|
[root@yiyjcvx1os3k4sx bin]# facter -p --custom-dir facts.d/ hellofact
|
2015-07-20 22:31:40.677669 WARN puppetlabs.facter - Could not load puppet; some facts may be unavailable: cannot load such file -- puppet
|
hello factor!
|
[root@yiyjcvx1os3k4sx bin]
|
[root@yiyjcvx1os3k4sx bin]# cat facts.d/hf
|
#! /bin/sh
|
echo "key=value"
|
[root@yiyjcvx1os3k4sx bin]# ls -l facts.d/
|
total 8
|
-rw-r--r--. 1 root root 108 Jul 20 22:21 hellofact.rb
|
-rwxr-xr-x. 1 root root 28 Jul 20 22:57 hf
|
[root@yiyjcvx1os3k4sx bin]# facter --external-dir facts.d/ key
|
value
|
[root@yiyjcvx1os3k4sx bin]# facter -p --external-dir facts.d/ key
|
2015-07-20 23:04:47.886185 WARN puppetlabs.facter - Could not load puppet; some facts may be unavailable: cannot load such file -- puppet
|
value
|
[root@yiyjcvx1os3k4sx bin]#
|
|