Jira (PUP-10793) puppet 7 treats nonexistent fact differently compared to puppet 6?

22 views
Skip to first unread message

Tim Meusel (Jira)

unread,
Nov 24, 2020, 11:18:03 AM11/24/20
to puppe...@googlegroups.com
Tim Meusel created an issue
 
Puppet / Bug PUP-10793
puppet 7 treats nonexistent fact differently compared to puppet 6?
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2020/11/24 8:17 AM
Priority: Normal Normal
Reporter: Tim Meusel

Puppet Version: 7.0.0
Puppet Server Version: 6.14.1
OS Name/Version: Ubuntu 16.04

Hi!

  • Sorry for the ugly issue title
  • this might be better as a facter issue, but I'm not sure

I've the following fact:

Facter.add('sach_passalgo') do
  confine :osfamily => 'RedHat'
  confine { Facter::Core::Execution.which('authconfig') }
 
  setcode do
    authconfig_out = `authconfig --test`
    hash_algo = 'unknown'
    authconfig_out.each_line do |line|
      hash_algo = line.split(' ')[4] if line.include? 'password hashing'
    end
    hash_algo
  end
end

I assume that this fact never exists on a Ubuntu/Debian system, because the fact is confined to osfamily RedHat. I expect `undef` as return value if I try to access this fact on a Debian node. This seems to be correct for Puppet 6:

notify { "test${facts['sach_passalgo']}":}
 
$var = $facts['sach_passalgo'] ? {
  undef => 'works',
  default => $facts['sach_passalgo'],
}
 
notify { "test1{$var}":}

this produces on puppet 6.14.0:

root@* ~ # puppet apply test.pp 
Notice: Compiled catalog for * in environment production in 0.02 seconds
Notice: test
Notice: /Stage[main]/Main/Notify[test]/message: defined 'message' as 'test'
Notice: works
Notice: /Stage[main]/Main/Notify[test1works]/message: defined 'message' as 'test1works'
Notice: Applied catalog in 0.27 seconds
root@* ~ # 

now with puppet 7:

root@* ~ # puppet apply test.pp 
Notice: Compiled catalog for * in environment production in 0.04 seconds
Notice: test
Notice: /Stage[main]/Main/Notify[test]/message: defined 'message' as 'test'
Notice: test1
Notice: /Stage[main]/Main/Notify[test1]/message: defined 'message' as 'test1'
Notice: Applied catalog in 0.21 seconds
root@* ~ # 

now I update the test code like this:

notify { "test${facts['sach_passalgo']}":}
 
$var = $facts['sach_passalgo'] ? {
  '' => 'empty string',
  undef => 'undef',
  default => $facts['sach_passalgo'],
}
 
notify { $var:}

which produces the following output on puppet 7:

root@* ~ # puppet apply test.pp 
Notice: Compiled catalog for * in environment production in 0.05 seconds
Notice: test
Notice: /Stage[main]/Main/Notify[test]/message: defined 'message' as 'test'
Notice: empty string
Notice: /Stage[main]/Main/Notify[empty string]/message: defined 'message' as 'empty string'
Notice: Applied catalog in 0.28 seconds
root@* ~ # 

A fact that was undef on Puppet 6 turned into empty string in Puppet 7?

Actual Behavior:
expect that the fact is still undef

let me know if you need more debugging/testing or any information.

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

Tim Meusel (Jira)

unread,
Nov 24, 2020, 1:44:03 PM11/24/20
to puppe...@googlegroups.com
Tim Meusel commented on Bug PUP-10793
 
Re: puppet 7 treats nonexistent fact differently compared to puppet 6?

I did some testing with the puppet 7 gem on Arch linux and undef facts are treated as undef:

bastelfreak@bastelfreak-ws /tmp/puppet7 $ bundle exec puppet apply test.pp 
Warning: Found multiple default providers for package: gem, pip, pip3, pip2; using gem
Notice: Compiled catalog for bastelfreak-ws.fritz.box in environment production in 0.01 seconds
Notice: undef
Notice: /Stage[main]/Main/Notify[undef]/message: defined 'message' as 'undef'
Notice: Applied catalog in 0.08 seconds
bastelfreak@bastelfreak-ws /tmp/puppet7 $ vim test.pp
bastelfreak@bastelfreak-ws /tmp/puppet7 $ bundle exec puppet --version
7.0.0
bastelfreak@bastelfreak-ws /tmp/puppet7 $ cat test.pp 
$var = $facts['foo'] ? {
  '' => 'empty string',
  undef => 'undef',
  default => $facts['foo'],
}
 
notify { $var:}
bastelfreak@bastelfreak-ws /tmp/puppet7 $

Tim Meusel (Jira)

unread,
Nov 24, 2020, 1:53:03 PM11/24/20
to puppe...@googlegroups.com
Tim Meusel commented on Bug PUP-10793

additional information:
facter is 4.0.46 on both boxes

the ubuntu setup:

root@* ~ # facter --version
4.0.46
root@* ~ # which facter
/opt/puppetlabs/bin/facter
root@* ~ # 

and the gem install:

bastelfreak@bastelfreak-ws /tmp/puppet7 $ bundle exec gem which facter
/tmp/puppet7/.vendor/ruby/2.7.0/gems/facter-4.0.46/lib/facter.rb
bastelfreak@bastelfreak-ws /tmp/puppet7 $ 

Tim Meusel (Jira)

unread,
Nov 24, 2020, 2:05:04 PM11/24/20
to puppe...@googlegroups.com
Tim Meusel commented on Bug PUP-10793

it's working properly on CentOS 7 with Puppet 7 rpms:

root@* ~ # cat test.pp
$var = $facts['THISDOESNOTEXISTHOPEFULLY'] ? {
  '' => 'empty string',
  undef => 'undef',
  default => $facts['foo'],
}
 
notify { $var:}
root@* ~ #
Notice: Compiled catalog for *s in environment production in 0.03 seconds
Notice: undef
Notice: /Stage[main]/Main/Notify[undef]/message: defined 'message' as 'undef'
Notice: Applied catalog in 0.33 seconds
root@* ~ #

the same works on ubuntu 16 as well:

root@* ~ # puppet apply test2.pp 
Notice: Compiled catalog for * in environment production in 0.04 seconds
Notice: undef
Notice: /Stage[main]/Main/Notify[undef]/message: defined 'message' as 'undef'
Notice: Applied catalog in 0.21 seconds
root@* ~ # cat test2.pp 
$var = $facts['THISDOESNOTEXISTHOPEFULLY'] ? {
  '' => 'empty string',
  undef => 'undef',
  default => $facts['foo'],
}
 
notify { $var:}
root@* ~ # puppet --version
7.0.0
root@* ~ # 

so I guess something is wrong with the fact sach_passalgo I posted in the initial description.

Oana Tanasoiu (Jira)

unread,
Nov 26, 2020, 6:53:05 AM11/26/20
to puppe...@googlegroups.com

Hi Tim Meusel ,

 

I managed to reproduce the issue:

 

Notice: Compiled catalog for closest-buffoon.delivery.puppetlabs.net in environment production in 0.02 seconds
Notice: test
Notice: /Stage[main]/Main/Notify[test]/message: defined 'message' as 'test'
Notice: empty string
Notice: /Stage[main]/Main/Notify[empty string]/message: defined 'message' as 'empty string'
Notice: Applied catalog in 0.01 seconds

Facter 4 was reporting custom facts that return nil value and puppet reports them as empty strings (due to puppet json formatting).

 

 

We made a fix for this  problem and the output is now as expected:

root@closest-buffoon:~# /opt/puppetlabs/bin/puppet apply test.pp
Notice: Compiled catalog for closest-buffoon.delivery.puppetlabs.net in environment production in 0.02 seconds
Notice: test
Notice: /Stage[main]/Main/Notify[test]/message: defined 'message' as 'test'
Notice: undef
Notice: /Stage[main]/Main/Notify[undef]/message: defined 'message' as 'undef'
Notice: Applied catalog in 0.01 seconds

Bogdan Irimie (Jira)

unread,
Nov 27, 2020, 10:06:03 AM11/27/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Nov 27, 2020, 10:08:03 AM11/27/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Nov 27, 2020, 10:23:03 AM11/27/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Nov 27, 2020, 10:25:05 AM11/27/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Nov 27, 2020, 10:26:04 AM11/27/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sub-team: ghost
Team: Night's Watch

Tim Meusel (Jira)

unread,
Nov 30, 2020, 11:37:04 AM11/30/20
to puppe...@googlegroups.com
Tim Meusel commented on Bug PUP-10793
 
Re: puppet 7 treats nonexistent fact differently compared to puppet 6?

hey Bogdan Irimie, thanks for the fix. I verified that it fixes this bug.

Josh Cooper (Jira)

unread,
Nov 30, 2020, 12:26:04 PM11/30/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10793

Bogdan Irimie Could you move this to the FACT project and update the PR's commit summary to reference the new ticket?

Reply all
Reply to author
Forward
0 new messages