Uploaded image for project: 'Facter'
  1. Facter
  2. FACT-2881

puppet 7 treats nonexistent fact differently compared to puppet 6?

    XMLWordPrintable

    Details

    • Template:
    • Team:
      Night's Watch
    • Sub-team:
    • Sprint:
      ghost-2.12, ghost-9.12
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      Exclude custom fact with nil value from `to_user_output`, `values` and `to_hash` ruby Facter API's. The custom facts with nil value as still returned by value, fact and [] API's
      Show
      Exclude custom fact with nil value from `to_user_output`, `values` and `to_hash` ruby Facter API's. The custom facts with nil value as still returned by value, fact and [] API's
    • QA Risk Assessment:
      Needs Assessment

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            bogdan.irimie Bogdan Irimie
            Reporter:
            bastelfreak Tim Meusel
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support