Jira (PUP-9115) custom facts don't get compiled

2 views
Skip to first unread message

Uwe Bartels (JIRA)

unread,
Sep 7, 2018, 7:08:03 AM9/7/18
to puppe...@googlegroups.com
Uwe Bartels created an issue
 
Puppet / Bug PUP-9115
custom facts don't get compiled
Issue Type: Bug Bug
Affects Versions: PUP 5.3.5
Assignee: Unassigned
Components: Puppet Server
Created: 2018/09/07 4:07 AM
Priority: Normal Normal
Reporter: Uwe Bartels

Puppet Version: 5.5.6
Puppet Server Version: 5.3.5
OS Name/Version: Ubuntu 16.04 LTS

PuppetDB Version 5.2.4
****

custom fact don't get compiled.

root@test-puppet04:~# puppet agent -t --noop --environment f20180907_fix_deprecated_code --tags netvault
Info: Using configured environment 'f20180907_fix_deprecated_code'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, 'versioncmp' parameter 'b' expects a String value, got Undef (file: /etc/puppetlabs/code/environments/f20180907_fix_deprecated_code/modules/netvault/manifests/client/install.pp, line: 50, column: 6) on node test-puppet04.example.net
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Changes:
Events:
Resources:
Time:
{{ Fact generation: 0.01}}
{{ Node retrieval: 0.13}}
{{ Plugin sync: 0.64}}
{{ Last run: 1536316270}}
{{ Total: 3.25}}
Version:
{{ Config: }}
{{ Puppet: 5.5.6}}
root@test-puppet04:~# facter --puppet --debug|&grep netvault
2018-09-07 12:32:10.358615 INFO puppetlabs.facter - loading custom facts from /opt/puppetlabs/puppet/cache/lib/facter/netvault.rb.
2018-09-07 12:32:12.238808 DEBUG puppetlabs.facter - fact "netvault_architecture" has resolved to "64".
2018-09-07 12:32:12.248292 DEBUG puppetlabs.facter - fact "netvault_version" has resolved to "12001.04".
netvault_architecture => 64
netvault_version => 12001.04
root@test-puppet04:~# egrep -n "versioncmp.*netvault_version" /etc/puppetlabs/code/environments/f20180907_fix_deprecated_code/modules/netvault/manifests/client/install.pp
50: if versioncmp($netvault::client::version, $::netvault_version) > 0 {

 

Describe steps to reproduce: hard to say. this is a clean puppetserver installation with a repviously used puppetdb. the puppetdb was used with a puppetserver of the same version with a very small number of test machines.

 

Desired Behavior:

compilation should take custom facts into account. so versioncmp should not try to use an Undef value.

 

Actual Behavior:

see above.

 

The current code works with puppetserver-3.8. The fact code was changed to produce a version number 12001.04 instead of former 12001.4 to make the puppet code puppet5 ready.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Kenn Hussey (JIRA)

unread,
Sep 7, 2018, 9:02:03 AM9/7/18
to puppe...@googlegroups.com
Kenn Hussey updated an issue
Change By: Kenn Hussey
Affects Version/s: PUP 5.3.5
Affects Version/s: PUP 5.5.6

Uwe Bartels (JIRA)

unread,
Sep 11, 2018, 3:59:04 AM9/11/18
to puppe...@googlegroups.com
Uwe Bartels commented on Bug PUP-9115
 
Re: custom facts don't get compiled

I've got a similar behavior on a different machine.

Again puppet code execution uses different custom fact results than the locally called facter command.

Different from behavior above is that the fact is not Undef it has a valid but wrong value. I changed in the facter code the string unknown to unknow1 and the facter value used by puppet is still the same. I hope that helps.

 

Best Regards,

Uwe

 

custom facter:

 

# ===Fact: nrpe_user
# This fact determines the user, which runs the nrpe-daemon.
# It was defined for the sudo::nrpe class.
Facter.add("nrpe_user") do
  setcode do
    if File.exist?('/etc/nagios/nrpe.cfg')
      File.open('/etc/nagios/nrpe.cfg') do |f|
        line = f.grep(/^\s*nrpe_user/)[0]
        line.match(/^\s*nrpe_user\s*=\s*(.+)\s*$/)[1]
      end
    else
      "unknown"
    end
  end
end

Integration in puppet code:

 

  notify{"\$::nrpe_user = ${::nrpe_user}":}

Puppet run output:

root@puppetboard01:~# puppet agent -t  --environment b20180911_facter_bug 
Info: Using configured environment 'b20180911_facter_bug'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Caching catalog for puppetboard01.exmaple.net
Info: Applying configuration version '1536651937'
Notice: $::nrpe_user = unknown
Notice: /Stage[main]/Nagios::Nrpe/Notify[$::nrpe_user = unknown]/message: defined 'message' as '$::nrpe_user = unknown'
Notice: /Stage[main]/Timezone/File[/etc/localtime]/ensure: ensure changed 'link' to 'file'
Info: /Stage[main]/Timezone/File[/etc/localtime]: Scheduling refresh of Exec[dpkg-reconfigure-tzdata]
Notice: /Stage[main]/Timezone/Exec[dpkg-reconfigure-tzdata]: Triggered 'refresh' from 1 event
Notice: Applied catalog in 9.39 seconds
Changes:
            Total: 2
Events:
          Success: 2
            Total: 2
Resources:
   Corrective change: 1
        Restarted: 1
          Changed: 2
      Out of sync: 2
            Total: 316
Time:
       Filebucket: 0.00
           Anchor: 0.00
   Ssh authorized key: 0.00
            Group: 0.00
         Schedule: 0.00
          Apt key: 0.00
        File line: 0.00
             Host: 0.00
           Notify: 0.00
             User: 0.01
   Fact generation: 0.01
             Cron: 0.01
   Node retrieval: 0.20
          Service: 0.23
   Convert catalog: 0.30
             Exec: 0.32
      Plugin sync: 0.66
           Augeas: 1.84
          Package: 1.89
         Last run: 1536651950
             File: 2.43
   Config retrieval: 5.36
   Transaction evaluation: 9.21
   Catalog application: 9.39
            Total: 15.93
Version:
           Config: 1536651937
           Puppet: 5.5.6
root@puppetboard01:~# facter --puppet --show-legacy|grep nrpe
nrpe_user => nagios
root@puppetboard01:~# grep ^nrpe_user /etc/nagios/nrpe.cfg 
nrpe_user=nagios
root@puppetboard01:~# 

puppet run after changing the facter code

root@puppetboard01:~# puppet agent -t  --environment b20180911_facter_bug 
Info: Using configured environment 'b20180911_facter_bug'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Notice: /File[/opt/puppetlabs/puppet/cache/lib/facter/nrpe_user.rb]/content: 
--- /opt/puppetlabs/puppet/cache/lib/facter/nrpe_user.rb	2018-09-11 09:40:42.094198549 +0200
+++ /tmp/puppet-file20180911-113657-m5khrm	2018-09-11 09:54:50.925856311 +0200
@@ -17,7 +17,7 @@
         line.match(/^\s*nrpe_user\s*=\s*(.+)\s*$/)[1]
       end
     else
-      "unknown"
+      "unknown1"
     end
   end
 endNotice: /File[/opt/puppetlabs/puppet/cache/lib/facter/nrpe_user.rb]/content: content changed '{md5}c4c7362868c3564e46259d54aae1f6ce' to '{md5}dbb6d1bc49a5a17030914b1efc2a3b0b'
Info: Retrieving locales
Info: Caching catalog for puppetboard01.example.net
Info: Applying configuration version '1536652492'
Notice: $::nrpe_user = unknown
Notice: /Stage[main]/Nagios::Nrpe/Notify[$::nrpe_user = unknown]/message: defined 'message' as '$::nrpe_user = unknown'
Notice: /Stage[main]/Timezone/File[/etc/localtime]/ensure: ensure changed 'link' to 'file'
Info: /Stage[main]/Timezone/File[/etc/localtime]: Scheduling refresh of Exec[dpkg-reconfigure-tzdata]
Notice: /Stage[main]/Timezone/Exec[dpkg-reconfigure-tzdata]: Triggered 'refresh' from 1 event
Notice: Applied catalog in 16.76 seconds
Changes:
            Total: 2
Events:
          Success: 2
            Total: 2
Resources:
   Corrective change: 1
        Restarted: 1
          Changed: 2
      Out of sync: 2
            Total: 316
Time:
           Anchor: 0.00
            Group: 0.00
   Ssh authorized key: 0.00
             Host: 0.00
          Apt key: 0.00
         Schedule: 0.00
        File line: 0.00
           Notify: 0.00
             User: 0.01
   Fact generation: 0.01
             Cron: 0.01
   Node retrieval: 0.18
   Convert catalog: 0.30
          Service: 0.30
             Exec: 0.35
      Plugin sync: 0.78
           Augeas: 1.85
          Package: 1.90
         Last run: 1536652524
   Config retrieval: 16.03
   Transaction evaluation: 16.58
   Catalog application: 16.76
       Filebucket: 0.00
             File: 9.69
            Total: 34.07
Version:
           Config: 1536652492
           Puppet: 5.5.6
root@puppetboard01:~#

 

Uwe Bartels (JIRA)

unread,
Sep 12, 2018, 5:57:02 AM9/12/18
to puppe...@googlegroups.com
Uwe Bartels commented on Bug PUP-9115

OK. I found the cause for this problem.

if you configure the agent regarding puppetdb like the master with routes.yaml, puppetdb.conf and the corresponding entries in puppet.conf, then you see this behavior.

For me the overall behavior is still a bug as the error message is completely misleading.

Actuall I see more than one bug.

  1. I do configuration for the puppetserver in the configuration directory of the puppet agent /etc/puppetlabs/puppet not /etc/puppetlabs/puppetserver. Yes I know this my approach without reading documentation carefully. The main cause for this I see in the documentation: https://puppet.com/docs/puppetdb/5.2/puppetdb_connection.html Here you write (headline) "Configuring a Puppet/PuppetDB connection". puppet is the componen meant as puppet agent. Better write something like "Configuring a Puppet Server/PuppetDB connection". Then you write "The Puppet master makes HTTPS connections to PuppetDB to store catalogs...". But the Puppet Agent also makes HTTPS connections to the PuppetDB, so as I need to configure the puppetdb.conf in the puppet agent directory /etc/puppetlabs/puppet I assumed that I need to configure puppetdb on the agent too. So basically I utterly confused that I configure the puppetserver in /etc/puppetlabs/puppet partly.
  2. if the confguration of puppetdb on the agent wrong (I know of the puppdb config for puppet apply) then the agent should complain about the misconfiguration
  3. same for the puppetserver - I configured puppetdb access in the directory /etc/puppetlabs/puppetserver. If this is wrong puppetserver should complain about misconfiguration.

I don't want to start a general discussion here. I know that you are using open source components which need to be integrated like this and you want to keep the puppet open for kind of everything the open source component offers. But this makes the configuration hard or especially the search for errornous configuration.

Jacob Helwig (JIRA)

unread,
Oct 8, 2018, 5:26:04 PM10/8/18
to puppe...@googlegroups.com
Jacob Helwig commented on Bug PUP-9115

I wouldn't expect the following to work in Puppet >= 5.x:

if versioncmp($netvault::client::version, $::netvault_version) > 0 {

Specifically, referring to a fact via "$::netvault_version" shouldn't be relied upon in Puppet 5. Some, but not all facts are created as top-scope variables. All facts are available via the top-scope "$::facts" hash, however, so "$::facts['netvault_version']" would work in Puppet 5.

Eric Thompson (JIRA)

unread,
Oct 11, 2018, 7:43:03 PM10/11/18
to puppe...@googlegroups.com
Eric Thompson updated an issue
 
Change By: Eric Thompson
Component/s: Puppet Server

Uwe Bartels (JIRA)

unread,
Oct 12, 2018, 2:22:03 AM10/12/18
to puppe...@googlegroups.com
Uwe Bartels commented on Bug PUP-9115
 
Re: custom facts don't get compiled

Hi Jacob, believe me or test it. It works. But this is not the point of this ticket.

Jorie Tappa (JIRA)

unread,
Oct 22, 2018, 5:13:05 PM10/22/18
to puppe...@googlegroups.com
Jorie Tappa assigned an issue to Jacob Helwig
 
Change By: Jorie Tappa
Assignee: Jacob Helwig

Jacob Helwig (JIRA)

unread,
Oct 31, 2018, 12:37:03 PM10/31/18
to puppe...@googlegroups.com
Jacob Helwig commented on Bug PUP-9115
 
Re: custom facts don't get compiled

Uwe Bartels could you file a new issue in the "Documentation (DOCUMENT)" project about changing the "Configuring a Puppet/PuppetDB connection" section title?

Josh Cooper (JIRA)

unread,
Dec 12, 2019, 12:34:04 AM12/12/19
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-9115

Uwe Bartels I'm not entirely sure what you're trying to do. Normally the agent never talks to puppetdb directly. So if you'd like to update the documentation as Jacob Helwig mentioned, please do. Otherwise, I don't see anything actionable for this ticket, and I am going to close it as incomplete.

Reply all
Reply to author
Forward
0 new messages