Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-4847

Custom facts not loaded when using puppet resource command

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.2.1
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      2
    • Sprint:
      Client 2015-07-22
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      When Puppet 4+ was run with Facter 3.0, Puppet's libdir would be added to Ruby's $LOAD_PATH but not picked up by Facter when using puppet resource. Puppet 4.2.1 fixes that so Facter will search the libdir location for custom facts.

      Description

      I'm seeing an issue where when running puppet resource, it does not load custom facts (puppet apply works ok).

      This is a masterless installation (i.e. no certs setup), so I don't believe this to be a pluginsync issue.

      root@hkmjr2cbdmkpxh2:~# /opt/puppetlabs/bin/puppet module install puppetlabs-firewall
      Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
      Notice: Downloading from https://forgeapi.puppetlabs.com ...
      Notice: Installing -- do not interrupt ...
      /etc/puppetlabs/code/environments/production/modules
      └── puppetlabs-firewall (v1.6.0)
      root@hkmjr2cbdmkpxh2:/opt/puppetlabs/bin# ls /etc/puppetlabs/code/environments/production/modules/firewall/lib/facter/iptables_version.rb
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/facter/iptables_version.rb
      root@hkmjr2cbdmkpxh2:/opt/puppetlabs/bin# cat test.pp
      notify {"$::iptables_version":}
      root@hkmjr2cbdmkpxh2:/opt/puppetlabs/bin# strace -efile -f ./puppet apply test.pp 2>&1 | grep iptables_version
      [pid  1817] stat("/etc/puppetlabs/code/environments/production/modules/firewall/lib/facter/iptables_version.rb", {st_mode=S_IFREG|0644, st_size=234, ...}) = 0
      [pid  1817] open("/etc/puppetlabs/code/environments/production/modules/firewall/lib/facter/iptables_version.rb", O_RDONLY|O_CLOEXEC) = 8
      [pid  1817] open("/etc/puppetlabs/code/environments/production/modules/firewall/lib/facter/iptables_version.rb", O_RDONLY|O_CLOEXEC) = 8
      [pid  1817] lstat("/etc/puppetlabs/code/environments/production/modules/firewall/lib/facter/iptables_version.rb", {st_mode=S_IFREG|0644, st_size=234, ...}) = 0
      [pid  1817] stat("/etc/puppetlabs/code/environments/production/modules/firewall/lib/facter/iptables_version.rb", {st_mode=S_IFREG|0644, st_size=234, ...}) = 0
      root@hkmjr2cbdmkpxh2:/opt/puppetlabs/bin# strace -efile -f ./puppet resource firewall 2>&1 | grep iptables_version
      root@hkmjr2cbdmkpxh2:/opt/puppetlabs/bin# ./puppet resource firewall
      Error: Could not autoload puppet/provider/firewall/iptables: undefined method `value' for nil:NilClass
      Error: Could not autoload puppet/type/firewall: Could not autoload puppet/provider/firewall/iptables: undefined method `value' for nil:NilClass
      Error: Could not run: Could not autoload puppet/type/firewall: Could not autoload puppet/provider/firewall/iptables: undefined method `value' for nil:NilClass
      root@hkmjr2cbdmkpxh2:/opt/puppetlabs/bin# ./puppet resource firewall --trace --debug
      Debug: Runtime environment: puppet_version=4.2.0, ruby_version=2.1.6, run_mode=user, default_encoding=UTF-8
      Debug: Facter: searching for custom fact "iptables_version".
      Debug: Facter: fact "facterversion" has resolved to "3.0.1".
      Debug: Facter: skipping external facts for "/opt/puppetlabs/facter/facts.d": No such file or directory
      Debug: Facter: skipping external facts for "/etc/facter/facts.d": No such file or directory
      Debug: Facter: skipping external facts for "/etc/puppetlabs/facter/facts.d": No such file or directory
      Debug: Facter: no external facts were found.
      Debug: Facter: loading all custom facts.
      Debug: Facter: custom fact "iptables_version" was not found.
      Error: Could not autoload puppet/provider/firewall/iptables: undefined method `value' for nil:NilClass
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/puppet/provider/firewall/iptables.rb:44:in `block in <top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/classgen.rb:136:in `class_eval'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/classgen.rb:136:in `genthing'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/classgen.rb:36:in `genclass'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1778:in `provide'
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/puppet/provider/firewall/iptables.rb:4:in `<top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load_file'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:74:in `block in loadall'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:72:in `each'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:72:in `loadall'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:203:in `loadall'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:116:in `newtype'
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/puppet/type/firewall.rb:12:in `<top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load_file'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:189:in `load'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:157:in `type'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:194:in `parse_args'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:136:in `main'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:352:in `run_command'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `block in run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:438:in `exit_on_fail'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:124:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:72:in `execute'
      /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
      Error: Could not autoload puppet/type/firewall: Could not autoload puppet/provider/firewall/iptables: undefined method `value' for nil:NilClass
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/puppet/provider/firewall/iptables.rb:44:in `block in <top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/classgen.rb:136:in `class_eval'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/classgen.rb:136:in `genthing'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/classgen.rb:36:in `genclass'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1778:in `provide'
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/puppet/provider/firewall/iptables.rb:4:in `<top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load_file'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:74:in `block in loadall'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:72:in `each'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:72:in `loadall'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:203:in `loadall'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:116:in `newtype'
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/puppet/type/firewall.rb:12:in `<top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load_file'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:189:in `load'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:157:in `type'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:194:in `parse_args'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:136:in `main'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:352:in `run_command'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `block in run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:438:in `exit_on_fail'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:124:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:72:in `execute'
      /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
      Error: Could not run: Could not autoload puppet/type/firewall: Could not autoload puppet/provider/firewall/iptables: undefined method `value' for nil:NilClass
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/puppet/provider/firewall/iptables.rb:44:in `block in <top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/classgen.rb:136:in `class_eval'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/classgen.rb:136:in `genthing'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/classgen.rb:36:in `genclass'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1778:in `provide'
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/puppet/provider/firewall/iptables.rb:4:in `<top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load_file'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:74:in `block in loadall'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:72:in `each'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:72:in `loadall'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:203:in `loadall'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:116:in `newtype'
      /etc/puppetlabs/code/environments/production/modules/firewall/lib/puppet/type/firewall.rb:12:in `<top (required)>'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:59:in `load_file'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:189:in `load'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/metatype/manager.rb:157:in `type'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:194:in `parse_args'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/resource.rb:136:in `main'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:352:in `run_command'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `block in run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:438:in `exit_on_fail'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:344:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:124:in `run'
      /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:72:in `execute'
      /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
      

      root@hkmjr2cbdmkpxh2:/opt/puppetlabs/bin# ./puppet --version
      4.2.0
      root@hkmjr2cbdmkpxh2:/opt/puppetlabs/bin# ./facter --version
      3.0.1 (commit 9b1ef723a1494a01e0eccfe93a75fd43316690c2)
      

      This is caused by new Facter behavior, but the new Facter behavior makes a lot more sense, so fixing in Puppet by re-initializing Facter after $LOAD_PATH manipulation.

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  jonathan.tripathy Jonny (JT) Tripathy
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 0 minutes
                    0m
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 30 minutes
                    30m