Ask Your Question
0

facter get precise values

asked 2016-05-20 03:33:34 -0500

snuff1987 gravatar image

updated 2016-05-21 01:24:15 -0500

Hi, I would like to ask the community how to retrieve more precise facts from facter.. For instance if I run facter memory the response is :

swap => {
    available => "1.75 GiB",
    available_bytes => 1879044096,
    capacity => "0%",
    total => "1.75 GiB",
    total_bytes => 1879044096,
    used => "0 bytes",
    used_bytes => 0

But what if I want to return only swap available?

Is there a approach how to do this? Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-05-21 01:37:42 -0500

It's not possible to do this using only the facter command line tool, although workarounds are available using grep or the jq tools, see here.

From within Puppet, if the commandline tool gives this output:

# facter --json processors
{
  "processors": {
    "count": 8,
    "speed": "2.3 GHz"
  }
}

We can address the facts hash like this:

# puppet apply -e 'notice("Fact value of processors['count'] is ${facts['processors']['count']}")'
Notice: Scope(Class[main]): Fact value of processors[count] is 8
Notice: Compiled catalog for alexs-macbook-pro.local in environment production in 0.05 seconds
Notice: Applied catalog in 0.03 seconds
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-05-20 03:33:34 -0500

Seen: 44 times

Last updated: May 21 '16