puppetdb将哈希事实存储为我的一些节点的字符串

时间:2015-04-09 03:38:49

标签: puppet

一些应该是哈希的事实在puppetdb中存储为字符串。

例如:

curl -X GET http://localhost:8080/v3/nodes/tcentos/facts/partitions
[ {
  "value" : "sda1uuid1b97126a-beb2-4843-8c7b-4e6e12cbfbb7mount/bootsize1024000filesystemext4sda2size40916992filesystemLVM2_member",
  "name" : "partitions",
  "certname" : "tcentos"
} ]

虽然它应该是这样的:

curl -X GET http://localhost:8080/v3/nodes/tfedora20/facts/partitions
[ {
  "value" : "{\"sda1\"=>{\"uuid\"=>\"8e6cda9b-54b7-4daa-a25c-1864a163f7a8\", \"size\"=>\"1024000\", \"mount\"=>\"/boot\", \"filesystem\"=>\"ext4\"}, \"sda2\"=>{\"size\"=>\"15751168\", \"filesystem\"=>\"LVM2_member\"}}",
  "name" : "partitions",
  "certname" : "tfedora20"
} ]

当我在facter partitions节点上运行tcentos时,返回值为OK。

[root@tcentos ~]# facter partitions
{"sda1"=>{"mount"=>"/boot", "filesystem"=>"ext4", "size"=>"1024000", "uuid"=>"1b97126a-beb2-4843-8c7b-4e6e12cbfbb7"}, "sda2"=>{"filesystem"=>"LVM2_member", "size"=>"40916992"}}

我的Puppet环境:

Puppet Master : 3.7.5
Puppet Agent  : 3.7.5
PuppetDB      : 2.3.0

我所有节点上的puppet agent和facter都是完全相同的版本。有没有人有同样的问题?

-----------------------更新---------------------

我在评论的帮助下得到了@FelixFrank的帮助。这大约是stringify_facts configuration

我们可以在stringify_facts=false(所有代理和主控的主要部分)中设置puppet.conf来禁用将事实值展平为字符串。根据{{​​3}},默认情况下从3.7及更高版本启用结构化事实支持。但我想Open Source Puppet的默认行为是不同的,所以我们必须明确添加这个设置。

curl -X GET http://localhost:8080/v3/nodes/tcentos/facts/partitions
[ {
  "value" : "{\"sda1\":{\"filesystem\":\"ext4\",\"mount\":\"/boot\",\"size\":\"1024000\",\"uuid\":\"1b97126a-beb2-4843-8c7b-4e6e12cbfbb7\"},\"sda2\":{\"filesystem\":\"LVM2_member\",\"size\":\"40916992\"}}",
  "name" : "partitions",
  "certname" : "tcentos"
} ]

虽然结果仍然是字符串而不是实际的JSON数据,但它比键值连接更好,我可以轻松地解析它。

0 个答案:

没有答案