I've been attempting to {{confine}} some facts using structured facts, as described in [the documentation here|https://puppet.com/docs/facter/3.11/custom_facts.html#confining-facts]. However, neither the first method described in the docs seems documentation using Facter.value does not seem to actually work with the current version of facter :
{code} ==> oscheck_codeblock.rb <== Facter.add(:oscheck_codeblock) do confine :os do |os| os['id'] == 'Debian' end
setcode do 'fact value' end end
== > oscheck_factervalue.rb <== Facter.add(:oscheck_factervalue) do confine Facter.value(:os)[' distro'][' id'] => 'Debian'
setcode do 'fact value' end end {code}
Running facter with FACTERLIB pointed at the location of the above two files file gives:
{code} 2018-08-17 13: 21 28 : 09 22 . 126211 140537 INFO puppetlabs.facter - executed with command line: --debug oscheck_codeblock oscheck_factervalue. 2018-08-17 13: 21 28 : 09 22 . 126619 140979 DEBUG leatherman.ruby:504 - ruby was found at "/usr/bin/ruby". 2018-08-17 13: 21 28 : 09 22 . 126762 141139 DEBUG leatherman.execution:93 - executing command: /usr/bin/ruby -e print(['libdir', 'archlibdir', 'sitearchlibdir', 'bindir'].find do |name|dir = RbConfig::CONFIG[name];next unless dir;file = File.join(dir, RbConfig::CONFIG['LIBRUBY_SO']);break file if File.exist? file;false end) 2018-08-17 13: 21 28 : 09 22 . 242077 295315 DEBUG | - /usr/lib/x86_64-linux-gnu/libruby-2.3.so.2.3.0 2018-08-17 13: 21 28 : 09 22 . 242280 295528 DEBUG leatherman.execution:559 - process exited with status code 0. 2018-08-17 13: 21 28 : 09 22 . 246717 299951 INFO leatherman.ruby:137 - ruby loaded from "/usr/lib/x86_64-linux-gnu/libruby-2.3.so.2.3.0". 2018-08-17 13: 21 28 : 09 22 . 247314 300503 DEBUG leatherman.dynamic_library:77 - symbol rb_data_object_alloc not found in library /usr/lib/x86_64-linux-gnu/libruby-2.3.so.2.3.0, trying alias rb_data_object_wrap. 2018-08-17 13: 21 28 : 09 22 . 357056 418246 INFO leatherman.ruby:186 - using ruby version 2.3.3 2018-08-17 13: 21 28 : 09 22 . 357220 418408 INFO puppetlabs.facter - requested queries: oscheck_codeblock oscheck_factervalue. 2018-08-17 13: 21 28 : 09 22 . 357303 418488 DEBUG puppetlabs.facter - fact "facterversion" has resolved to "3.11.3". 2018-08-17 13: 21 28 : 09 22 . 357678 418857 DEBUG leatherman.file_util:65 - Error reading file: No such file or directory 2018-08-17 13: 21 28 : 09 22 . 358390 419635 DEBUG puppetlabs.facter - loading all custom facts. 2018-08-17 13: 21 28 : 09 22 . 358435 419683 DEBUG puppetlabs.facter - loading custom fact directories from config file 2018-08-17 13: 21 28 : 09 22 . 358494 419733 DEBUG puppetlabs.facter - searching for custom facts in /home/chrisb. 2018-08-17 13: 21 28 : 09 22 . 358649 419890 INFO puppetlabs.facter - loading custom facts from /home/chrisb/ oscheck_codeblock.rb. 2018-08-17 13:21:09.358964 INFO puppetlabs.facter - loading custom facts from /home/chrisb/ oscheck_factervalue.rb. 2018-08-17 13: 21 28 : 09 22 . 359177 420223 DEBUG puppetlabs.facter - searching for custom fact "os". 2018-08-17 13: 21 28 : 09 22 . 359250 420281 DEBUG puppetlabs.facter - searching for os.rb in /home/chrisb. 2018-08-17 13: 21 28 : 09 22 . 359343 420403 DEBUG puppetlabs.facter - resolving operating system facts. 2018-08-17 13: 21 28 : 09 22 . 359397 420506 DEBUG puppetlabs.facter - resolving kernel facts. 2018-08-17 13: 21 28 : 09 22 . 359472 420623 DEBUG puppetlabs.facter - fact "kernel" has resolved to "Linux". 2018-08-17 13: 21 28 : 09 22 . 359522 420711 DEBUG puppetlabs.facter - fact "kernelrelease" has resolved to "2.6.32-042stab123.9". 2018-08-17 13: 21 28 : 09 22 . 359644 420906 DEBUG puppetlabs.facter - fact "kernelmajversion" has resolved to "2.6". 2018-08-17 13: 21 28 : 09 22 . 359698 421009 DEBUG puppetlabs.facter - fact "kernelversion" has resolved to "2.6.32". 2018-08-17 13: 21 28 : 09 22 . 359783 421155 DEBUG leatherman.execution:93 - executing command: /usr/bin/lsb_release -a 2018-08-17 13: 21 28 : 09 22 . 443491 525733 DEBUG !!! - No LSB modules are available. 2018-08-17 13: 21 28 : 09 22 . 443611 525855 DEBUG | - Distributor ID: Debian 2018-08-17 13: 21 28 : 09 22 . 443689 525932 DEBUG | - Description: Debian GNU/Linux 9.5 (stretch) 2018-08-17 13: 21 28 : 09 22 . 443743 525987 DEBUG | - Release: 9.5 2018-08-17 13: 21 28 : 09 22 . 443795 526038 DEBUG | - Codename: stretch 2018-08-17 13: 21 28 : 09 22 . 452773 536786 DEBUG leatherman.execution:559 - process exited with status code 0. 2018-08-17 13: 21 28 : 09 22 . 455774 539651 DEBUG puppetlabs.facter - fact "osfamily" has resolved to "Debian". 2018-08-17 13: 21 28 : 09 22 . 455897 539761 DEBUG puppetlabs.facter - fact "operatingsystemmajrelease" has resolved to "9". 2018-08-17 13: 21 28 : 09 22 . 455983 539843 DEBUG puppetlabs.facter - fact "operatingsystemrelease" has resolved to "9.5". 2018-08-17 13: 21 28 : 09 22 . 456065 539919 DEBUG puppetlabs.facter - fact "hardwaremodel" has resolved to "x86_64". 2018-08-17 13: 21 28 : 09 22 . 456157 539994 DEBUG puppetlabs.facter - fact "architecture" has resolved to "amd64". 2018-08-17 13: 21 28 : 09 22 . 456237 540069 DEBUG puppetlabs.facter - fact "lsbdistid" has resolved to "Debian". 2018-08-17 13: 21 28 : 09 22 . 456320 540154 DEBUG puppetlabs.facter - fact "lsbdistcodename" has resolved to "stretch". 2018-08-17 13: 21 28 : 09 22 . 456404 540230 DEBUG puppetlabs.facter - fact "lsbdistdescription" has resolved to "Debian GNU/Linux 9.5 (stretch)". 2018-08-17 13: 21 28 : 09 22 . 456488 540310 DEBUG puppetlabs.facter - fact "lsbmajdistrelease" has resolved to "9". 2018-08-17 13: 21 28 : 09 22 . 456571 540387 DEBUG puppetlabs.facter - fact "lsbminordistrelease" has resolved to "5". 2018-08-17 13: 21 28 : 09 22 . 457114 540465 DEBUG puppetlabs.facter - fact "lsbdistrelease" has resolved to "9.5". 2018-08-17 13: 21 28 : 09 22 . 457338 540541 DEBUG puppetlabs.facter - fact "operatingsystem" has resolved to "Debian". 2018-08-17 13: 21 28 : 09 22 . 457598 540634 DEBUG puppetlabs.facter - fact "selinux" has resolved to false. 2018-08-17 13: 21 28 : 09 22 . 457773 540732 DEBUG puppetlabs.facter - fact "os" has resolved to { architecture => "amd64", distro => { codename => "stretch", description => "Debian GNU/Linux 9.5 (stretch)", id => "Debian", release => { full => "9.5", major => "9", minor => "5" } }, family => "Debian", hardware => "x86_64", name => "Debian", release => { full => "9.5", major => "9", minor => "5" }, selinux => { enabled => false } }. 2018-08-17 13: 21 28 : 09 22 . 458213 ERROR puppetlabs.facter - error while resolving custom facts in /home/chrisb/oscheck_factervalue.rb: expected a String or Symbol for confine key 2018-08-17 13:21:09.458484 541146 DEBUG puppetlabs.facter - custom fact " oscheck_codeblock debian " resolved to null and will was not be added found . 2018-08-17 13: 21 28 : 09 22 . 458618 541242 DEBUG puppetlabs.facter - fact "oscheck_factervalue" resolved to null and will not be added. 2018-08-17 13: 21 28 : 09 22 . 458806 541403 DEBUG puppetlabs.facter - skipping external facts for "/home/chrisb/.puppetlabs/opt/facter/facts.d": No such file or directory 2018-08-17 13: 21 28 : 09 22 . 458901 541484 DEBUG puppetlabs.facter - skipping external facts for "/home/chrisb/.facter/facts.d": No such file or directory 2018-08-17 13: 21 28 : 09 22 . 458967 541537 DEBUG puppetlabs.facter - no external facts were found. 2018-08-17 13: 21 28 : 09 22 . 459110 541659 DEBUG puppetlabs.facter - fact " oscheck_codeblock" does not exist. 2018-08-17 13:21:09.459201 DEBUG puppetlabs.facter - fact " oscheck_factervalue" does not exist. oscheck_codeblock => oscheck_factervalue => {code} |
|
|