[PUP-6400] lookup cli has no way to set arbitrary scope values Created: 2016/06/10  Updated: 2019/04/04

Status: Needs Information
Project: Puppet
Component/s: None
Affects Version/s: PUP 4.5.1
Fix Version/s: None

Type: Bug Priority: Normal
Reporter: R.I.Pienaar Assignee: Eric Sorenson
Resolution: Unresolved Votes: 0
Labels: needs_decision
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Sub-team: Language
Team: Froyo


When constructing hierarchies it's best to use $trusted wherever possible and there are legit use cases for using random in scope vars.

The old CLI let you specify arbitrary scope which would be used to satisfy testing these on the CLI, with new lookup this is pretty hard/impossible.

It lets you supply facts from a file which then is only accessible as facts.foo for example, no way to do trusted or random vars.

I might have missed a obvious way to achieve this so this ticket could be a non issue but could not find it.

Comment by Henrik Lindberg [ 2016/06/10 ]

You should be able to feed in $trusted stuff by having the fact 'trusted' set to the correct (expected) values. (I am unsure if we tested that though, it may work because we do get $trusted as a node parameter in some cases, and IIRC, that is how we deal with the facts given on the CLI). Love to hear if that works or not.

For arbitrary variables; since that is supported at runtime, the CLI should support those too. (Not having support for that is an oversight). The easiest is to add yet another flag that accepts a reference to a file with variables, or we need to redesign the options to accept a combination of facts and variables in one and the same file. Not sure what is best (also considering backwards compatibility).

Comment by Eric Sorenson [ 2016/07/15 ]

R.I.Pienaar do henrik's suggestions address your concerns? sounds like there is a way to achieve this - pls put the ticket back to me iff not.

Comment by R.I.Pienaar [ 2016/07/16 ]

Eric Sorenson no can't say I got this to work tbh

irb(main):002:0> JSON.parse(File.read("facts.json"))
=> {"trusted"=>{"certname"=>"foo.com"}}

  - "%{trusted.certname}"

# puppet lookup --facts facts.json --debug some::data
Debug: hiera(): Looking up lookup_options in YAML backend
Debug: hiera(): Looking for data source dev3.devco.net
Debug: hiera(): Looking up some::data in YAML backend
Debug: hiera(): Looking for data source dev3.devco.net

Doesn't seem to be using these facts. But apart from that Henrik Lindberg also identified what looks like some feature work that's needed in his reply

Generated at Wed Apr 01 13:49:36 PDT 2020 using Jira 8.5.2#805002-sha1:a66f9354b9e12ac788984e5d84669c903a370049.