Facts are not Coming in JSON Format when Query is done via APIs

Hi All,

I am using puppet Server version 4.7.0 and I see that facts are coming in
this format.

 "networking::interfaces::Ethernet::dhcp": "10.65.250.10",
  "networking::interfaces::Ethernet::ip": "10.65.250.14",
  "ipaddress": "10.65.250.14",
  "networking::ip": "10.65.250.14",
  "ipaddress_Ethernet": "10.65.250.14",
  "memory::system::used": "1.08 GiB",
  "timestamp": "11/05/2016 07:46:56",
  "memory::system::used_bytes": "1157337088",

While I have another Server with Version 4.5.3 and I see that facts come
there in JSON format.

"networking": "{"dhcp"=>"10.65.168.11",
"domain"=>"sdcorp.global.sandisk.com",
"fqdn"=>"Puppetest12345.sdcorp.global.sandisk.com",
"hostname"=>"Puppetest12345", "interfaces"=>{"Local Area Connection
2"=>{"bindings"=>[{"address"=>"10.65.168.150",
"netmask"=>"255.255.248.0", "network"=>"10.65.168.0"}],
"bindings6"=>[{"address"=>"fe80::b45c:17f7:b3c1:fdd2%13",
"netmask"=>"ffff:ffff:ffff:ffff::", "network"=>"fe80::%13"}],
"dhcp"=>"10.65.168.11", "ip"=>"10.65.168.150",
"ip6"=>"fe80::b45c:17f7:b3c1:fdd2%13", "mac"=>"30:5A:3A:4B:06:52",
"mtu"=>1500, "netmask"=>"255.255.248.0",
"netmask6"=>"ffff:ffff:ffff:ffff::", "network"=>"10.65.168.0",
"network6"=>"fe80::%13"}}, "ip"=>"10.65.168.150",
"ip6"=>"fe80::b45c:17f7:b3c1:fdd2%13", "mac"=>"30:5A:3A:4B:06:52",
"mtu"=>1500, "netmask"=>"255.255.248.0",
"netmask6"=>"ffff:ffff:ffff:ffff::", "network"=>"10.65.168.0",
"network6"=>"fe80::%13", "primary"=>"Local Area Connection 2"}",

Can some please explain what that above (first one) format is and is there
any puppet configuration I can set to get O/p in JSON format?

Alternately if that is not possible please let me know how can I convert
this format to JSON.

Any help is appreciated.

Thanks & Regards,
-Vishal

Adding to this, we are using Foreman 1.13 and we are missing some
configuration settings which is not giving the facts values output in JSON
format in Foreman API.
Anybody please help on getting the facts values in JSON format.

Regards,
Amrit

··· On Friday, November 11, 2016 at 7:51:07 PM UTC+5:30, Vishal Sarin wrote: > > Hi All, > > I am using puppet Server version 4.7.0 and I see that facts are coming in > this format. > > "networking::interfaces::Ethernet::dhcp": "10.65.250.10", > "networking::interfaces::Ethernet::ip": "10.65.250.14", > "ipaddress": "10.65.250.14", > "networking::ip": "10.65.250.14", > "ipaddress_Ethernet": "10.65.250.14", > "memory::system::used": "1.08 GiB", > "timestamp": "11/05/2016 07:46:56", > "memory::system::used_bytes": "1157337088", > > While I have another Server with Version 4.5.3 and I see that facts come > there in JSON format. > > > "networking": "{\"dhcp\"=>\"10.65.168.11\", \"domain\"=>\" > sdcorp.global.sandisk.com\", \"fqdn\"=>\" > Puppetest12345.sdcorp.global.sandisk.com\", > \"hostname\"=>\"Puppetest12345\", \"interfaces\"=>{\"Local Area Connection > 2\"=>{\"bindings\"=>[{\"address\"=>\"10.65.168.150\", > \"netmask\"=>\"255.255.248.0\", \"network\"=>\"10.65.168.0\"}], > \"bindings6\"=>[{\"address\"=>\"fe80::b45c:17f7:b3c1:fdd2%13\", > \"netmask\"=>\"ffff:ffff:ffff:ffff::\", \"network\"=>\"fe80::%13\"}], > \"dhcp\"=>\"10.65.168.11\", \"ip\"=>\"10.65.168.150\", > \"ip6\"=>\"fe80::b45c:17f7:b3c1:fdd2%13\", \"mac\"=>\"30:5A:3A:4B:06:52\", > \"mtu\"=>1500, \"netmask\"=>\"255.255.248.0\", > \"netmask6\"=>\"ffff:ffff:ffff:ffff::\", \"network\"=>\"10.65.168.0\", > \"network6\"=>\"fe80::%13\"}}, \"ip\"=>\"10.65.168.150\", > \"ip6\"=>\"fe80::b45c:17f7:b3c1:fdd2%13\", \"mac\"=>\"30:5A:3A:4B:06:52\", > \"mtu\"=>1500, \"netmask\"=>\"255.255.248.0\", > \"netmask6\"=>\"ffff:ffff:ffff:ffff::\", \"network\"=>\"10.65.168.0\", > \"network6\"=>\"fe80::%13\", \"primary\"=>\"Local Area Connection 2\"}", > > Can some please explain what that above (first one) format is and is there > any puppet configuration I can set to get O/p in JSON format? > > Alternately if that is not possible please let me know how can I convert > this format to JSON. > > Any help is appreciated. > > Thanks & Regards, > -Vishal >

Are these different agents? What version exactly are the agents?

··· On 11/11/16 14:21, Vishal Sarin wrote: > Hi All, > > I am using puppet Server version 4.7.0 and I see that facts are coming > in this format. > > "networking::interfaces::Ethernet::dhcp": "10.65.250.10", > "networking::interfaces::Ethernet::ip": "10.65.250.14", > "ipaddress": "10.65.250.14", > "networking::ip": "10.65.250.14", > "ipaddress_Ethernet": "10.65.250.14", > "memory::system::used": "1.08 GiB", > "timestamp": "11/05/2016 07:46:56", > "memory::system::used_bytes": "1157337088", > > While I have another Server with Version 4.5.3 and I see that facts come > there in JSON format.


Dominic Cleal
dominic@cleal.org

Hi Dminic,

Yes they are from two different CentOS based Puppet Masters (Server)

In One we have Puppet Version 4.7.0 and on Other we have 4.5.3

On 4.7.0 its not coming in JSON while in 4.5.3 its coming in JSON.

Thanks,
-Vishal

··· On Monday, 14 November 2016 13:54:58 UTC+5:30, Dominic Cleal wrote: > > On 11/11/16 14:21, Vishal Sarin wrote: > > Hi All, > > > > I am using puppet Server version 4.7.0 and I see that facts are coming > > in this format. > > > > "networking::interfaces::Ethernet::dhcp": "10.65.250.10", > > "networking::interfaces::Ethernet::ip": "10.65.250.14", > > "ipaddress": "10.65.250.14", > > "networking::ip": "10.65.250.14", > > "ipaddress_Ethernet": "10.65.250.14", > > "memory::system::used": "1.08 GiB", > > "timestamp": "11/05/2016 07:46:56", > > "memory::system::used_bytes": "1157337088", > > > > While I have another Server with Version 4.5.3 and I see that facts come > > there in JSON format. > > Are these different agents? What version exactly are the agents? > > -- > Dominic Cleal > dom...@cleal.org >

The facts look like they're from a Windows machine, not from CentOS.

Are those only the Puppet server versions? What are the agent versions
on the hosts sending the facts?

··· On 14/11/16 12:43, Vishal Sarin wrote: > Hi Dminic, > > Yes they are from two different CentOS based Puppet Masters (Server) > > In One we have Puppet Version 4.7.0 and on Other we have 4.5.3


Dominic Cleal
dominic@cleal.org

Hi Dominic, The agents are windows based.

One has 1.7.0 and other one has 1.5.3

For 1.5.3 its working but for 1.7.0 they don't

I didn't get your question in first time.

Thanks
-Vishal

··· On Monday, 14 November 2016 19:52:27 UTC+5:30, Dominic Cleal wrote: > > On 14/11/16 12:43, Vishal Sarin wrote: > > Hi Dminic, > > > > Yes they are from two different CentOS based Puppet Masters (Server) > > > > In One we have Puppet Version 4.7.0 and on Other we have 4.5.3 > > The facts look like they're from a Windows machine, not from CentOS. > > Are those only the Puppet server versions? What are the _agent_ versions > on the hosts sending the facts? > > -- > Dominic Cleal > dom...@cleal.org >

> Hi Dominic, The agents are windows based.
>
> One has 1.7.0 and other one has 1.5.3
>
> For 1.5.3 its working but for 1.7.0 they don't

I'm unsure from your description that you're defining "working" correctly.

This is not correct for recent versions of Puppet:

"networking": "{"dhcp"=>"10.65.168.11" […]

Note also that this is not JSON. It's a stringified hash, but it's a
Puppet 3 style of sending hashes and shouldn't be expected on Puppet 4
(if that's the version of your agents).

If the agent is 1.5.3 then it ought to be using Puppet 4.5.2, which
shouldn't be sending this format.

> I am using puppet Server version 4.7.0 and I see that facts are coming in this format.
>
> "networking::interfaces::Ethernet::dhcp": "10.65.250.10",

This looks correct, each fact being sent individually. Facts will be
stored separately in Foreman instead of in one blob.

I can only suggest you need to upgrade the agent to ensure the host with
the older version sends it in the same way.

··· On 14/11/16 14:32, Vishal Sarin wrote:


Dominic Cleal
dominic@cleal.org

I will try with matching Puppet agent, will update the thread.

Thanks
-Vishal

··· On Monday, 14 November 2016 20:10:28 UTC+5:30, Dominic Cleal wrote: > > On 14/11/16 14:32, Vishal Sarin wrote: > > Hi Dominic, The agents are windows based. > > > > One has 1.7.0 and other one has 1.5.3 > > > > For 1.5.3 its working but for 1.7.0 they don't > > I'm unsure from your description that you're defining "working" correctly. > > This is not correct for recent versions of Puppet: > > "networking": "{\"dhcp\"=>\"10.65.168.11\" [..] > > Note also that this is not JSON. It's a stringified hash, but it's a > Puppet 3 style of sending hashes and shouldn't be expected on Puppet 4 > (if that's the version of your agents). > > If the agent is 1.5.3 then it ought to be using Puppet 4.5.2, which > shouldn't be sending this format. > > > I am using puppet Server version 4.7.0 and I see that facts are coming > in this format. > > > > "networking::interfaces::Ethernet::dhcp": "10.65.250.10", > > This looks correct, each fact being sent individually. Facts will be > stored separately in Foreman instead of in one blob. > > I can only suggest you need to upgrade the agent to ensure the host with > the older version sends it in the same way. > > -- > Dominic Cleal > dom...@cleal.org >