Jira (FACT-1259) Option to flatten facter facts for easier command line search

2 views
Skip to first unread message

Jeremy Adams (JIRA)

unread,
Oct 19, 2015, 3:55:02 PM10/19/15
to puppe...@googlegroups.com
Jeremy Adams created an issue
 
Facter / Story FACT-1259
Option to flatten facter facts for easier command line search
Issue Type: Story Story
Assignee: Unassigned
Created: 2015/10/19 12:54 PM
Priority: Normal Normal
Reporter: Jeremy Adams

If I want to find facts that have a subkey in them somewhere (like "version" or "release" or "address"), I cannot use a utility like grep easily because of structured facts' multiline output format.

So instead of this:

# facter os
{
  architecture => "x86_64",
  family => "RedHat",
  hardware => "x86_64",
  name => "CentOS",
  release => {
    full => "6.6",
    major => "6",
    minor => "6"
  },
  selinux => {
    enabled => false
  }
}

I'd like something like this:

# facter --flat os
os.architecure => "x86_64"
os.family => "RedHat"
os.hardware => "x86_64"
os.name => "CentOS"
os.release.full => "6.6"
os.release.major => "6"
os.release.minor => "6"
os.selinux.enabled => "false"

Less lines of output and I can use grep!

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.11#64026-sha1:78f6ec4)
Atlassian logo

Eric Sorenson (JIRA)

unread,
Oct 19, 2015, 5:06:03 PM10/19/15
to puppe...@googlegroups.com
Eric Sorenson commented on Story FACT-1259
 
Re: Option to flatten facter facts for easier command line search

That seems consistent with the query language, and it'd be nice to be able to preview the flat name of a fact according to the internals. so

FWIW, you can do this today and preserve the awesomeness of the structured data with jq :

[er...@fermium.local ~/Sandbox]% facter --json | jq '.os'
{
  "name": "Darwin",
  "family": "Darwin",
  "release": {
    "major": "14",
    "minor": "5",
    "full": "14.5.0"
  }
}

Jeremy Adams (JIRA)

unread,
Oct 19, 2015, 5:12:03 PM10/19/15
to puppe...@googlegroups.com
Jeremy Adams commented on Story FACT-1259

I'm a big fan of jq, but it's much harder to find all of the facts that contain the subkey "major", for example.

Jeremy Adams (JIRA)

unread,
Oct 19, 2015, 5:13:04 PM10/19/15
to puppe...@googlegroups.com
Jeremy Adams updated an issue
 
Change By: Jeremy Adams
If I want to find facts that have a subkey in them somewhere (like "version" or "release" or "address"), I cannot use a utility like grep easily because of structured facts' multiline output format. 

So instead of this:
{code}

# facter os
{
  architecture => "x86_64",
  family => "RedHat",
  hardware => "x86_64",
  name => "CentOS",
  release => {
    full => "6.6",
    major => "6",
    minor => "6"
  },
  selinux => {
    enabled => false
  }
}
{code}


I'd like something like this:

{code}

# facter --flat os
os.architecure => "x86_64"
os.family => "RedHat"
os.hardware => "x86_64"
os.name => "CentOS"
os.release.full => "6.6"
os.release.major => "6"
os.release.minor => "6"
os.selinux.enabled =>
 " false "
{code}


Less lines of output and I can use grep!

J.D. Welch (JIRA)

unread,
Oct 19, 2015, 7:31:02 PM10/19/15
to puppe...@googlegroups.com
J.D. Welch commented on Story FACT-1259
 
Re: Option to flatten facter facts for easier command line search

I'm totally into the idea. I think ideally we'd want the lookup input to use whatever syntax PQL does (paging Kenneth Barber). In general, it would be interesting to explore different formats for returning data. I could see "fact":"value", fact::value, fact=value all being potentially useful. In this case, I guess the question is use case: Is the intent for the most human-readable output for interactive use, or does the result need to get piped into some other tool?

Jeremy Adams (JIRA)

unread,
Oct 20, 2015, 5:57:04 PM10/20/15
to puppe...@googlegroups.com
Jeremy Adams commented on Story FACT-1259

The reason for the idea was that I was trying to find facts that had a "version" subkey to them and couldn't do it easily from the command line using common tools like grep, cut, etc that are line-based. So yes, the idea that both the output of facter itself which produces all of the keys and values, as well as the value of something like facter os or facter.os.release should have an option where a set of single, "self-contained"/"fully qualified" lines is returned. For example:

# facter --flat os.release
os.release.major => "14"
os.release.minor => "5"
os.release.full => "14.5.0"

As an aside, among SysAdmins multi-line log files are seen as an anti-pattern largely because they are harder to search with basic tools like grep.
http://juliusdavies.ca/logging.html#grep
http://gojko.net/2006/12/09/logging-anti-patterns/
https://today.java.net/article/2006/04/04/exception-handling-antipatterns#multilineLogMessages
http://www.masterzen.fr/2013/01/13/the-10-commandments-of-logging/ (assumed in here by examples)

Imagine log lines from different services going into a master log like /var/log/messages and the problems interleaving of mult-line logs cause.

Maggie Dreyer (JIRA)

unread,
May 17, 2017, 1:42:04 PM5/17/17
to puppe...@googlegroups.com
Maggie Dreyer updated an issue
 
Change By: Maggie Dreyer
Labels: triaged
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Maggie Dreyer (JIRA)

unread,
May 17, 2017, 1:42:04 PM5/17/17
to puppe...@googlegroups.com

Maggie Dreyer (JIRA)

unread,
May 17, 2017, 1:42:05 PM5/17/17
to puppe...@googlegroups.com
Maggie Dreyer commented on Story FACT-1259
 
Re: Option to flatten facter facts for easier command line search

Tyler Pace thoughts on this? We've seen a couple tickets around the Facter CLI; do you think it would be useful to spend some time revisiting the UX for this?

Rick Monro (JIRA)

unread,
May 18, 2017, 6:06:02 AM5/18/17
to puppe...@googlegroups.com
Rick Monro commented on Story FACT-1259

Maggie Dreyer I'm moving on to this as Eric Sorenson mentions; I've had no exposure to Facter thus far, so will need some background and context - however, happy to contribute as and where I can. Let me know if you want to grab some time offline and we can talk through it.

Moses Mendoza (JIRA)

unread,
May 18, 2017, 1:46:56 PM5/18/17
to puppe...@googlegroups.com

Tyler Pace (JIRA)

unread,
May 30, 2017, 6:37:02 PM5/30/17
to puppe...@googlegroups.com
Tyler Pace assigned an issue to Rick Monro
Change By: Tyler Pace
Assignee: Tyler Pace Rick Monro

Branan Riley (JIRA)

unread,
Mar 21, 2018, 6:02:04 PM3/21/18
to puppe...@googlegroups.com
Branan Riley updated an issue
Change By: Branan Riley
Labels: triaged ux
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Branan Riley (JIRA)

unread,
Mar 21, 2018, 6:03:03 PM3/21/18
to puppe...@googlegroups.com
Branan Riley commented on Story FACT-1259
 
Re: Option to flatten facter facts for easier command line search

Larissa Lane Much like my comment on FACT-932, I'd be interested in us figuring out a plan for CLI usability improvements in Facter

Rick Monro (JIRA)

unread,
May 18, 2018, 6:22:03 AM5/18/18
to puppe...@googlegroups.com
Rick Monro assigned an issue to Unassigned
 
Change By: Rick Monro
Assignee: Rick Monro

Branan Riley (JIRA)

unread,
May 21, 2018, 4:10:05 PM5/21/18
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Apr 21, 2022, 2:34:02 PM4/21/22
to puppe...@googlegroups.com
Josh Cooper commented on Story FACT-1259
 
Re: Option to flatten facter facts for easier command line search

This is possible today using facter-pipe-to-json or using:

% bundle exec puppet facts show --render-as flat | head
os.release.full=20.04
os.release.major=20.04
os.distro.release.full=20.04
os.distro.release.major=20.04
os.distro.description=Ubuntu 20.04.4 LTS
os.distro.codename=focal
os.distro.id=Ubuntu
os.architecture=amd64
os.selinux.enabled=false
os.name=Ubuntu 

so I'm going to close this.

This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages