Jira (PUP-8499) puppet lookup cli, using --facts and --node simultaneously breaks

52 views
Skip to first unread message

Just (JIRA)

unread,
Feb 28, 2018, 12:26:04 PM2/28/18
to puppe...@googlegroups.com
Just created an issue
 
Puppet / Bug PUP-8499
puppet lookup cli, using --facts and --node simultaneously breaks
Issue Type: Bug Bug
Affects Versions: PUP 5.4.0, PUP 5.3.5
Assignee: Unassigned
Created: 2018/02/28 9:25 AM
Priority: Normal Normal
Reporter: Just

Puppet Version: 5.4.0
Puppet Server Version: n/a
OS Name/Version: Ubuntu 16.04

When running `puppet lookup` with both the `–node` and `–facts` arguments, it exits with an error:

```Error: Could not run: undefined method `add_extra_values' for nil:NilClass```

Desired Behavior:

It should return the correct value from hiera data, or at least not error even if no value is returned.

Actual Behavior:

 

```

/opt/puppetlabs/bin/puppet lookup site_domain --environment boo --facts test_facts.yaml --node myhost.r00.zone1.foo.bar.com --node_terminus=plain --external_nodes=none --trace

Error: Could not run: undefined method `add_extra_values' for nil:NilClass
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/node.rb:167:in `add_extra_facts'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:367:in `generate_scope'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:327:in `main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:383:in `run_command'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:665:in `exit_on_fail'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:73:in `execute'
/opt/puppetlabs/puppet/bin/puppet:5:in `<main>'

```

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.5.1#75006-sha1:7df2574)
Atlassian logo

Just (JIRA)

unread,
Feb 28, 2018, 12:27:04 PM2/28/18
to puppe...@googlegroups.com
Just updated an issue
Change By: Just
*Puppet Version: 5.4.0*
*Puppet Server Version: n/a*
*OS Name/Version: Ubuntu 16.04*


When running `puppet lookup` with both the `–node` and `–facts` arguments, it exits with an error:

``` {{ Error: Could not run: undefined method `add_extra_values' for nil:NilClass ``` }}


*Desired Behavior:*


It should return the correct value from hiera data, or at least not error even if no value is returned.

*Actual Behavior:*


 

```

/opt/puppetlabs/bin/puppet lookup site_domain --environment boo --facts test_facts.yaml --node myhost.r00.zone1.foo.bar.com --node_terminus=plain --external_nodes=none --trace

Error: Could not run: undefined method `add_extra_values' for nil:NilClass
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/node.rb:167:in `add_extra_facts'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:367:in `generate_scope'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:327:in `main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:383:in `run_command'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:665:in `exit_on_fail'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:73:in `execute'
/opt/puppetlabs/puppet/bin/puppet:5:in `<main>'

```

Just (JIRA)

unread,
Feb 28, 2018, 12:28:23 PM2/28/18
to puppe...@googlegroups.com

Just (JIRA)

unread,
Feb 28, 2018, 12:29:03 PM2/28/18
to puppe...@googlegroups.com
Just updated an issue
*Puppet Version: 5.4.0*
*Puppet Server Version: n/a*
*OS Name/Version: Ubuntu 16.04*

When running "puppet lookup" with both the "–node" and "–facts" arguments, it exits with an error:

{ { code:java}
Error: Could not run: undefined method `add_extra_values' for nil:NilClass {code } }

*Desired Behavior:*

It should return the correct value from hiera data, or at least not error even if no value is returned.

*Actual Behavior:*

 

 
{code:java}
/opt/puppetlabs/bin/puppet lookup site_domain --environment boo --facts test_facts.yaml --node myhost.r00.zone1.foo.bar.com --node_terminus=plain --external_nodes=none --traceError: Could not run: undefined method `add_extra_values' for nil:NilClass

{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/node.rb:167:in `add_extra_facts'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:367:in `generate_scope'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:327:in `main'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:383:in `run_command'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `block in run'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:665:in `exit_on_fail'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `run'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:73:in `execute'}}
{{ /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'}}{code}
 

 

Just (JIRA)

unread,
Feb 28, 2018, 12:29:03 PM2/28/18
to puppe...@googlegroups.com
Just updated an issue
*Puppet Version: 5.4.0*
*Puppet Server Version: n/a*
*OS Name/Version: Ubuntu 16.04*

When running
" puppet lookup " with both the " –node " and " –facts "
arguments, it exits with an error:

{{Error: Could not run: undefined method `add_extra_values' for nil:NilClass}}


*Desired Behavior:*

It should return the correct value from hiera data, or at least not error even if no value is returned.

*Actual Behavior:*

 

 
{ { code:java}
/opt/puppetlabs/bin/puppet lookup site_domain --environment boo --facts test_facts.yaml --node myhost.r00.zone1.foo.bar.com --node_terminus=plain --external_nodes=none -- trace}}{{Error traceError : Could not run: undefined method `add_extra_values' for nil:NilClass }}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/node.rb:167:in `add_extra_facts'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:367:in `generate_scope'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:327:in `main'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:383:in `run_command'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `block in run'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:665:in `exit_on_fail'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `run'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:73:in `execute'}}
{{ /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'}}
{code}
 

 

Just (JIRA)

unread,
Feb 28, 2018, 12:36:02 PM2/28/18
to puppe...@googlegroups.com
Just updated an issue
Change By: Just
Attachment: lookup_add_extra_values_with_node.patch

Just (JIRA)

unread,
Feb 28, 2018, 12:37:03 PM2/28/18
to puppe...@googlegroups.com
Just commented on Bug PUP-8499
 
Re: puppet lookup cli, using --facts and --node simultaneously breaks

After looking at the code, I found the problem seemed to be here, in puppet/application/lookup.rb :

 

def generate_scope
 if options[:node]
   node = options[:node]
 else
   node = Puppet[:node_name_value]
   # If we want to lookup the node we are currently on
   # we must returning these settings to their default values
   Puppet.settings[:facts_terminus] = 'facter'
 end

 

 

For some reason, not setting

Puppet.settings[:facts_terminus] = 'facter'

breaks the

node.add_extra_facts

I don't know whey, I'm not really too familiar with the code.

If you change the code to do 

Puppet.settings[:facts_terminus] = 'facter'

..whether you specify the node option or not, it doesn't break.

So I don't know if this is a real solution, but the attached patch fixes the error and returns data correctly as far as I can tell.

lookup_add_extra_values_with_node.patch

Just (JIRA)

unread,
Feb 28, 2018, 1:04:02 PM2/28/18
to puppe...@googlegroups.com
Just updated an issue
Change By: Just
*Puppet Version: 5.4.0*
*Puppet Server Version: n/a*
*OS Name/Version: Ubuntu 16.04*

When running "puppet lookup" with both the "–node" and "–facts" arguments, it exits with an error:
{code:java}
Error: Could not run: undefined method `add_extra_values' for nil:NilClass{code}

*Desired Behavior:*

It should return the correct value from hiera data, or at least not error even if no value is returned.

*Actual Behavior:*

 

 
{code:java}/opt/puppetlabs/bin/puppet lookup site_domain --environment boo --facts test_facts.yaml --node myhost.r00.zone1.foo.bar.com --node_terminus=plain --external_nodes=none -- traceError trace
Error
: Could not run: undefined method `add_extra_values' for nil:NilClass

{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/node.rb:167:in `add_extra_facts'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:367:in `generate_scope'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:327:in `main'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:383:in `run_command'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `block in run'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:665:in `exit_on_fail'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `run'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run'}}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:73:in `execute'}}
{{ /opt/puppetlabs/puppet/bin/puppet:5:in `<main>'}}{code}
 

 

Just (JIRA)

unread,
Feb 28, 2018, 1:05:03 PM2/28/18
to puppe...@googlegroups.com
Just updated an issue
*Puppet Version: 5.4.0*
*Puppet Server Version: n/a*
*OS Name/Version: Ubuntu 16.04*

When running "puppet lookup" with both the "–node" and "–facts" arguments, it exits with an error:
{code:java}Error: Could not run: undefined method `add_extra_values' for nil:NilClass{code}
*Desired Behavior:*

It should return the correct value from hiera data, or at least not error even if no value is returned.

*Actual Behavior:*

 

 
{code:java}/opt/puppetlabs/bin/puppet lookup site_domain --environment boo --facts test_facts.yaml --node myhost.r00.zone1.foo.bar.com --node_terminus=plain --external_nodes=none --trace
Error: Could not run: undefined method `add_extra_values' for nil:NilClass
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/node.rb:167:in `add_extra_facts' }}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:367:in `generate_scope' }}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:327:in `main' }}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:383:in `run_command' }}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `block in run' }}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:665:in `exit_on_fail' }}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `run' }}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:137:in `run' }}
{{ /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:73:in `execute' }}
{{ /opt/puppetlabs/puppet/bin/puppet:5:in `<main>' }}
{code}
 

 

Craig Gomes (JIRA)

unread,
Mar 5, 2018, 5:29:03 PM3/5/18
to puppe...@googlegroups.com
Craig Gomes updated an issue
Change By: Craig Gomes
Sub-team: Coremunity Language
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Craig Gomes (JIRA)

unread,
Mar 5, 2018, 5:30:02 PM3/5/18
to puppe...@googlegroups.com

Henrik Lindberg (JIRA)

unread,
Mar 9, 2018, 9:35:02 PM3/9/18
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Mar 16, 2018, 5:01:03 PM3/16/18
to puppe...@googlegroups.com

Hung Huynh (JIRA)

unread,
Nov 26, 2018, 2:11:02 AM11/26/18
to puppe...@googlegroups.com
Hung Huynh commented on Bug PUP-8499
 
Re: puppet lookup cli, using --facts and --node simultaneously breaks

Hello,

 

I am having the same problem but it seems your patch is jut change the indentation.

Puppet.settings[:facts_terminus] = 'facter'

doesn't have any change?

 

Thank you!

Just (JIRA)

unread,
Nov 26, 2018, 3:13:01 AM11/26/18
to puppe...@googlegroups.com
Just commented on Bug PUP-8499

Not really.  It's been a while since I've looked at this, but the patch moves that bit of code out of the preceding conditional statement.

 

 

Hung Huynh (JIRA)

unread,
Nov 26, 2018, 11:56:03 PM11/26/18
to puppe...@googlegroups.com
Hung Huynh commented on Bug PUP-8499

So it doesn't work for Puppet 6. I tried to remove 2 space characters but it didn't work. If you have time, please try to help me for

https://github.com/puppetlabs/puppet/blob/master/lib/puppet/application/lookup.rb

 

Thank you!

Hung Huynh (JIRA)

unread,
May 21, 2019, 12:32:03 AM5/21/19
to puppe...@googlegroups.com
Hung Huynh commented on Bug PUP-8499

I still have this issue with Puppet-agent 6.4.2-1stretch

puppet lookup system::accounts --node host1 --environment production --explain --facts facts.json --debug --trace

Error: Could not run: undefined method `add_extra_values' for nil:NilClass
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/node.rb:167:in `add_extra_facts'

/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:362:in `generate_scope'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/lookup.rb:312:in `main'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:390:in `run_command'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:382:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:671:in `exit_on_fail'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:382:in `run' /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:139:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:77:in `execute'
/opt/puppetlabs/puppet/bin/puppet:5:in `<main>'

Add Comment Add Comment
 

Thomas Hallgren (JIRA)

unread,
May 21, 2019, 2:55:02 AM5/21/19
to puppe...@googlegroups.com
Thomas Hallgren assigned an issue to Unassigned
 
Change By: Thomas Hallgren
Assignee: Thomas Hallgren

Henrik Lindberg (JIRA)

unread,
May 22, 2019, 1:18:02 PM5/22/19
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-8499
 
Re: puppet lookup cli, using --facts and --node simultaneously breaks

The earlier proposed patch would make a lookup of the node facts use facter (which runs locally) to get facts for the node as opposed to looking them up in PDB.

Could it be that the node has never checked in and deposited any facts on the server?

Just (JIRA)

unread,
May 22, 2019, 1:30:05 PM5/22/19
to puppe...@googlegroups.com
Just commented on Bug PUP-8499

We don't use puppet-db at all.  Perhaps there is a mis-understanding on my part for how the lookup utility works.

 

The deprecated hiera utility just parsed the hiera as far as I know.  Does the lookup require puppet-db if you use the "–node" options?  I suppose I had presumed that it was supplying the certname or something.

Henrik Lindberg (JIRA)

unread,
May 23, 2019, 7:18:03 AM5/23/19
to puppe...@googlegroups.com

If you use the --node feature it requires a terminus to be configured such that it can find the node's data (i.e. the facts). Normally that is the pdb terminus.
If you change that terminus to be facter, you would always get facts for the host on which you are running puppet lookup, not the node that was given with --node.

The --node was added as a convenience to lookup the facts for the node since in most cases the data is available from the terminus that is used when compiling (i.e. where facts received from agents are stored as part of the request to compile a catalog).

The deprecated hiera application/cli-tool often produced the wrong answer because of a somewhat simplistic handling of facts, and access to variables set in puppet manifests, and has many other issues.

Without modifying the code, you can probably give the node terminus to use on the command line.

Just (JIRA)

unread,
May 23, 2019, 9:52:03 AM5/23/19
to puppe...@googlegroups.com
Just commented on Bug PUP-8499

Henrik Lindberg  Thank you - that explains a few things.  That wasn't clear at all from the docs I read at the time.

Perhaps we should just close this as invalid/won't fix then?

 

Josh Cooper (Jira)

unread,
Jun 6, 2020, 9:41:03 PM6/6/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Epic Link: PUP-6870
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Jul 16, 2020, 4:59:04 PM7/16/20
to puppe...@googlegroups.com

Tim Meusel (Jira)

unread,
Aug 16, 2021, 4:53:02 AM8/16/21
to puppe...@googlegroups.com
Tim Meusel commented on Bug PUP-8499
 
Re: puppet lookup cli, using --facts and --node simultaneously breaks

Hi people,
I just run into this as well on Puppet 6.23.0.

This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Nov 11, 2021, 12:26:02 AM11/11/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-8499

This issue has been addressed as part of on-going work on puppet lookup, see PUP-10435, PUP-7362, PUP-11204, and is no longer reproducible, so I'm going to close this.

$ bundle exec puppet lookup site_domain --environment production --facts test_facts.json --node $(hostname -f) --node_terminus=plain --external_nodes=none --trace
$

Reply all
Reply to author
Forward
0 new messages