Jira (FACT-2989) Facter 4.0.52 does not return fqdn fact

42 views
Skip to first unread message

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 11:25:03 AM3/17/21
to puppe...@googlegroups.com
Hugo Haakseth created an issue
 
Facter / Bug FACT-2989
Facter 4.0.52 does not return fqdn fact
Issue Type: Bug Bug
Affects Versions: FACT 4.0.52
Assignee: Unassigned
Components: Facter 4
Created: 2021/03/17 8:24 AM
Priority: Normal Normal
Reporter: Hugo Haakseth

Puppet Version: 6.21.1
OS Name/Version: RHEL 6.9

I have en issue where rspec tests for a custom type just started to fail yesterday at 00:01.

An error occurred while loading ./spec/unit/puppet/provider/am_agent_j2ee/ruby_spec.rb.
Failure/Error: defaultto "amAgent_#{Facter.value('fqdn').gsub('.', '_')}_80.log"
Puppet::Error:
  Could not autoload puppet/type/am_agent_j2ee: undefined method `gsub' for nil:NilClass 

Running my Rspec tests with facter 4.0.51 is ok.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 5:42:03 PM3/17/21
to puppe...@googlegroups.com
Hugo Haakseth updated an issue
Change By: Hugo Haakseth
*Puppet Version: 6.21.1*
*OS Name/Version: RHEL
6 7 .9*


I have en issue where rspec tests for a custom type just started to fail yesterday at 00:01.


{noformat}
An error occurred while loading ./spec/unit/puppet/provider/am_agent_j2ee/ruby_spec.rb.
Failure/Error: defaultto "amAgent_#{Facter.value('fqdn').gsub('.', '_')}_80.log"
Puppet::Error:
  Could not autoload puppet/type/am_agent_j2ee: undefined method `gsub' for nil:NilClass {noformat}

Running my Rspec tests with facter 4.0.51 is ok.

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 5:44:04 PM3/17/21
to puppe...@googlegroups.com
Hugo Haakseth updated an issue
*Puppet Version: 6.21.1*
*OS Name/Version:
RHEL CentOS 7.9*


I have en issue where rspec tests for a custom type just started to fail yesterday at 00:01.
{noformat}An error occurred while loading ./spec/unit/puppet/provider/am_agent_j2ee/ruby_spec.rb.
Failure/Error: defaultto "amAgent_#{Facter.value('fqdn').gsub('.', '_')}_80.log"
Puppet::Error:
  Could not autoload puppet/type/am_agent_j2ee: undefined method `gsub' for nil:NilClass {noformat}
Running my Rspec tests with facter 4.0.51 is ok.

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 6:06:04 PM3/17/21
to puppe...@googlegroups.com
Hugo Haakseth commented on Bug FACT-2989
 
Re: Facter 4.0.52 does not return fqdn fact

The module in question is written using PDK 1.10.0.0, and my Gemfile is generated by pdk.
I don't use 'pdk test unit' because of its lack of visibility and missing acceptance testing support.

To run the failing tests I run

PUPPET_GEM_VERSION='~>6.0' bundle install
bundle exec rake spec
 
And this doesn't fail
PUPPET_GEM_VERSION='~>6.0' FACTER_GEM_VERSION='4.0.51' bundle install
bundle exec rake spec

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 6:23:03 PM3/17/21
to puppe...@googlegroups.com

What I find a bit strange is that all the puppet6 docs says that puppet6 uses facter 3.x, but the puppet-6.21.1 gem has a facter dependency 'facter (< 5, > 2.0.1)'

I have tried to bundle install with FACTER_GEM_VERSION='~>3.0' but this also failes, and the only facter3 version available on rubygems.org seems to be 3.12.2.cfacter.20181217 which does not install..

 

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 6:35:03 PM3/17/21
to puppe...@googlegroups.com
Hugo Haakseth updated an issue
Change By: Hugo Haakseth
*Puppet Version: 6.21.1*
*OS Name/Version: CentOS 7.9*


I have en issue where rspec tests for a custom type just started to fail yesterday at 00:01.
{noformat}An error occurred while loading ./spec/unit/puppet/provider/am_agent_j2ee/ruby_spec.rb.
Failure/Error: defaultto "amAgent_#{Facter.value('fqdn').gsub('.', '_')}_80.log"
Puppet::Error:
  Could not autoload puppet/type/am_agent_j2ee: undefined method `gsub' for nil:NilClass {noformat}
Date and time seems to match the release of facter 4.0.52.
Running my Rspec tests with facter 4.0.51 is ok.

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 6:42:04 PM3/17/21
to puppe...@googlegroups.com
Hugo Haakseth updated an issue
*Puppet Version: 6.21.1*
*OS Name/Version: CentOS 7.9*

I have en issue where rspec tests for a custom type just started to fail yesterday at 00:01.
{noformat}An error occurred while loading ./spec/unit/puppet/provider/am_agent_j2ee/ruby_spec.rb.
Failure/Error: defaultto "amAgent_#{Facter.value('fqdn').gsub('.', '_')}_80.log"
Puppet::Error:
  Could not autoload puppet/type/am_agent_j2ee: undefined method `gsub' for nil:NilClass {noformat}
and
{noformat}
[vagrant@localhost vagrant]$ bundle exec facter fqdn

[vagrant@localhost vagrant]$ bundle exec facter | grep fqdn
[vagrant@localhost vagrant]$
{noformat}
 

Date and time seems to match the release of facter 4.0.52.
Running my Rspec tests with facter 4.0.51 is ok.

Josh Cooper (Jira)

unread,
Mar 17, 2021, 6:57:04 PM3/17/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug FACT-2989
 
Re: Facter 4.0.52 does not return fqdn fact

Hi Hugo Haakseth copying my comment from the other ticket. Can you provide a way to reproduce and the output of bundle exec gem list and bundle exec gem env? I'm guessing there's some interaction between rspec-puppet and puppet that is changed due to the ffi change.

Also one thing, passing an interpolated string to defaultto means the value will be looked up as soon as the provider ruby code is loaded. You may instead want to pass a block to defaulttto so that the resolution is deferred until the resource is applied (and likely after rspec-puppet has stubbed the value). So try changing the provider to:

defaultto { "amAgent_#{Facter.value('fqdn').gsub('.', '_')}_80.log" }

See https://github.com/puppetlabs/puppet-specifications/blob/master/language/resource_types.md#defaultto for more info about the difference

When testing against puppet6, you're actually using the facter 2.x gem. None of the facter 3 gems are really useable.

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 8:13:03 PM3/17/21
to puppe...@googlegroups.com

[vagrant@localhost vagrant]$ bundle exec gem env
RubyGems Environment:

  • RUBYGEMS VERSION: 2.7.6
  • RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-linux]
  • INSTALLATION DIRECTORY: /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
  • USER INSTALLATION DIRECTORY: /home/vagrant/.gem/ruby/2.5.0
  • RUBY EXECUTABLE: /home/vagrant/.rbenv/versions/2.5.3/bin/ruby
  • EXECUTABLE DIRECTORY: /home/vagrant/.rbenv/versions/2.5.3/bin
  • SPEC CACHE DIRECTORY: /home/vagrant/.gem/specs
  • SYSTEM CONFIGURATION DIRECTORY: /home/vagrant/.rbenv/versions/2.5.3/etc
  • RUBYGEMS PLATFORMS:
  • ruby
  • x86_64-linux
  • GEM PATHS:
  • /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
  • /home/vagrant/.gem/ruby/2.5.0
  • GEM CONFIGURATION:
  • :update_sources => true
  • :verbose => true
  • :backtrace => false
  • :bulk_threshold => 1000
  • REMOTE SOURCES:
  • https://rubygems.org/
  • SHELL PATH:
  • /home/vagrant/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bin
  • /home/vagrant/.rbenv/versions/2.5.3/bin
  • /home/vagrant/.rbenv/libexec
  • /home/vagrant/.rbenv/plugins/ruby-build/bin
  • /home/vagrant/.rbenv/shims
  • /home/vagrant/.rbenv/bin
  • /usr/local/bin
  • /usr/bin
  • /usr/local/sbin
  • /usr/sbin
  • /home/vagrant/.local/bin
  • /home/vagrant/bin

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 8:14:04 PM3/17/21
to puppe...@googlegroups.com

[vagrant@localhost vagrant]$ bundle exec gem list

      • LOCAL GEMS ***

addressable (2.7.0)
ansi (1.5.0)
ast (2.4.2)
awesome_print (1.9.2)
bcrypt_pbkdf (1.1.0)
beaker (4.26.0)
beaker-abs (0.8.1)
beaker-answers (0.28.0)
beaker-docker (0.8.4)
beaker-hostgenerator (1.2.10)
beaker-module_install_helper (0.1.7)
beaker-pe (2.11.11)
beaker-puppet (1.21.0)
beaker-puppet_install_helper (0.9.8)
beaker-rspec (6.3.0)
beaker-vmpooler (1.3.3)
bundler (1.17.3)
byebug (11.1.3)
codecov (0.5.1)
coderay (1.1.3)
colorize (0.8.1)
commander (4.5.2)
concurrent-ruby (1.1.8)
deep_merge (1.2.1)
dependency_checker (0.2.0)
diff-lcs (1.4.4)
docile (1.3.5)
docker-api (2.1.0)
domain_name (0.5.20190701)
ed25519 (1.2.4)
excon (0.79.0)
facter (4.0.52)
facterdb (1.6.0)
faraday (0.17.4)
faraday_middleware (0.14.0)
fast_gettext (1.1.2)
gettext (3.2.9)
gettext-setup (0.34)
hiera (3.7.0)
highline (2.0.3)
hirb (0.7.3)
hocon (1.3.1)
http-accept (1.7.0)
http-cookie (1.0.3)
httpclient (2.8.3)
in-parallel (0.1.17)
inifile (3.0.0)
jgrep (1.5.4)
json (default: 2.1.0)
json-schema (2.8.1)
locale (2.1.3)
metaclass (0.0.4)
metadata-json-lint (3.0.0)
method_source (0.8.2)
mime-types (3.3.1)
mime-types-data (3.2021.0225)
mini_portile2 (2.5.0)
minitar (0.9)
minitest (5.14.4)
mocha (1.1.0)
multi_json (1.15.0)
multipart-post (2.1.1)
net-scp (1.2.1)
net-ssh (6.1.0)
net-telnet (0.1.1)
netrc (0.11.0)
nokogiri (1.11.2 x86_64-linux)
oga (3.3)
open_uri_redirections (0.2.1)
parallel (1.20.1)
parallel_tests (3.5.2)
parser (3.0.0.0)
pathspec (0.2.1)
pluginator (1.5.0)
pry (0.10.4)
pry-byebug (3.8.0)
public_suffix (4.0.6)
puppet (6.21.1)
puppet-blacksmith (6.1.0)
puppet-debugger (1.2.0)
puppet-lint (2.4.2)
puppet-module-posix-default-r2.5 (1.1.0)
puppet-module-posix-dev-r2.5 (1.1.0)
puppet-modulebuilder (0.2.1)
puppet-resource_api (1.8.13)
puppet-strings (2.6.0)
puppet-syntax (3.1.0)
puppet_forge (2.3.4)
puppetlabs_spec_helper (3.0.0)
racc (1.5.2)
rainbow (2.2.2)
rake (12.3.3)
rb-readline (0.5.5)
regexp_parser (2.1.1)
require_all (1.3.3)
rest-client (2.1.0)
rexml (3.2.4)
rgen (0.8.2)
rspec (3.10.0)
rspec-core (3.10.1)
rspec-expectations (3.10.1)
rspec-its (1.3.0)
rspec-mocks (3.10.2)
rspec-puppet (2.8.0)
rspec-puppet-facts (2.0.1)
rspec-support (3.10.2)
rspec_junit_formatter (0.4.1)
rsync (1.0.9)
rubocop (1.6.1)
rubocop-ast (1.4.1)
rubocop-performance (1.9.1)
rubocop-rspec (2.0.1)
ruby-ll (2.1.2)
ruby-progressbar (1.11.0)
semantic_puppet (1.0.3)
serverspec (2.41.5)
sfl (2.3)
simplecov (0.18.5)
simplecov-console (0.4.2)
simplecov-html (0.12.3)
slop (3.6.0)
spdx-licenses (1.3.0)
specinfra (2.82.2)
stringify-hash (0.0.2)
strings (0.1.8)
strings-ansi (0.2.0)
table_print (1.5.7)
text (1.3.1)
thor (1.1.0)
tty-pager (0.13.0)
tty-screen (0.8.1)
unf (0.1.4)
unf_ext (0.0.7.7)
unicode-display_width (1.7.0)
unicode_utils (1.4.0)
vmfloaty (1.1.1)
yard (0.9.26)

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 8:41:03 PM3/17/21
to puppe...@googlegroups.com

Hi Josh Cooper 

Thanks for the tip about pass a block to defaulttto.
Makes sens and I'm going to change that in a few places...
{{I changed it in the }}am_agent_j2ee type and then ran

bundle exec rspec -fd spec/unit/puppet/provider/am_agent_j2ee/ruby_spec.rb 

Which passed all tests.

The only problem is that I have spec tests for the type too... and running this test still failes.

[vagrant@localhost vagrant]$ bundle exec rspec -fd spec/unit/puppet/type/am_agent_j2ee_spec.rbAn error occurred while loading ./spec/unit/puppet/type/am_agent_j2ee_spec.rb.
Failure/Error: defaultto { "amAgent_#{Facter.value('fqdn').gsub('.', '_')}_80.log" }NoMethodError:
  undefined method `gsub' for nil:NilClass
# ./lib/puppet/type/am_agent_j2ee.rb:363:in `block (3 levels) in <top (required)>'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:192:in `new'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:192:in `block (6 levels) in <top (required)>'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:191:in `block (5 levels) in <top (required)>'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:190:in `each'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:190:in `block (4 levels) in <top (required)>'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:178:in `block (3 levels) in <top (required)>'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:5:in `block (2 levels) in <top (required)>'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:4:in `each'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:4:in `block in <top (required)>'
# ./spec/unit/puppet/type/am_agent_j2ee_spec.rb:3:in `<top (required)>'
Run options: exclude {:bolt=>true}Finished in 0.00003 seconds (files took 8.92 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
 

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 9:05:03 PM3/17/21
to puppe...@googlegroups.com

I could attach my Vagrant file and my Gemfile to reproduce.
I think that should be enough to let you do  bundle install and then look at whats happening with bundle exec facter.

Hugo Haakseth (Jira)

unread,
Mar 17, 2021, 9:21:02 PM3/17/21
to puppe...@googlegroups.com
Hugo Haakseth updated an issue
Change By: Hugo Haakseth
Attachment: Vagrantfile
Attachment: Gemfile

Mihai Buzgau (Jira)

unread,
Mar 18, 2021, 5:59:03 AM3/18/21
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Labels: community

Mihai Buzgau (Jira)

unread,
Mar 19, 2021, 3:31:04 AM3/19/21
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Story Points: 2

Mihai Buzgau (Jira)

unread,
Mar 19, 2021, 3:32:04 AM3/19/21
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Sprint: NW - 2021-03-31

Gheorghe Popescu (Jira)

unread,
Mar 19, 2021, 3:37:04 AM3/19/21
to puppe...@googlegroups.com
Gheorghe Popescu commented on Bug FACT-2989
 
Re: Facter 4.0.52 does not return fqdn fact

Hugo Haakseth thanks for the info, managed to reproduce the issue and it was caused by the fact that ffi was required to early.
PR to fix this: https://github.com/puppetlabs/facter/pull/2318

Gheorghe Popescu (Jira)

unread,
Mar 19, 2021, 3:52:03 AM3/19/21
to puppe...@googlegroups.com
Gheorghe Popescu assigned an issue to Gheorghe Popescu
 
Change By: Gheorghe Popescu
Assignee: Gheorghe Popescu

Mihai Buzgau (Jira)

unread,
Mar 19, 2021, 4:31:03 AM3/19/21
to puppe...@googlegroups.com
Mihai Buzgau updated an issue
Change By: Mihai Buzgau
Team: Night's Watch

Gheorghe Popescu (Jira)

unread,
Mar 23, 2021, 3:22:03 AM3/23/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Change By: Gheorghe Popescu
Release Notes: Bug Fix

Gheorghe Popescu (Jira)

unread,
Mar 23, 2021, 3:24:03 AM3/23/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Change By: Gheorghe Popescu
Release Notes Summary: Update the linux/networking resolver to load
FFI if previous tries of getting the host information
failed.

Gheorghe Popescu (Jira)

unread,
Mar 23, 2021, 3:24:03 AM3/23/21
to puppe...@googlegroups.com
Gheorghe Popescu updated an issue
Change By: Gheorghe Popescu
Fix Version/s: FACT 4.0.53

Claire Cadman (Jira)

unread,
Apr 13, 2021, 9:24:04 AM4/13/21
to puppe...@googlegroups.com
Claire Cadman updated an issue
Change By: Claire Cadman
Labels: community doc_reviewed
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages