使用熊猫数据帧规范ansible清单JSON时遇到问题
跑步后
ansible-inventory -i dynamic_inventory.yaml --playbook-dir ./ --list > list.json
我明白了
{
"_meta": {
"hostvars": {
"myhostdcdb01": {
"ansible_host": "10.10.252.66",
"portal_cpu": 2,
"portal_domain": "prod.local",
"portal_group": "DBA",
"portal_hostname": "myhostdcdb01",
"portal_ip_address": "10.10.252.66",
"portal_memory": 8
},
"myhostdcdb02": {
"ansible_host": "10.10.252.67",
"portal_cpu": 2,
"portal_domain": "prod.local",
"portal_group": "DBA",
"portal_hostname": "myhostdcdb02",
"portal_ip_address": "10.10.252.67",
"portal_memory": 8
},
"myhostdcdb03": {
"ansible_host": "10.10.252.68",
"portal_cpu": 2,
"portal_domain": "prod.local",
"portal_group": "DBA",
"portal_hostname": "myhostdcdb03",
"portal_ip_address": "10.10.252.68",
"portal_memory": 8
},
"myhostscdb01": {
"ansible_host": "10.10.252.76",
"portal_cpu": 2,
"portal_domain": "prod.local",
"portal_group": "DBA",
"portal_hostname": "myhostscdb01",
"portal_ip_address": "10.10.252.76",
"portal_memory": 8
},
"myhostscdb02": {
"ansible_host": "10.10.252.78",
"portal_cpu": 2,
"portal_domain": "prod.local",
"portal_group": "DBA",
"portal_hostname": "myhostscdb02",
"portal_ip_address": "10.10.252.78",
"portal_memory": 8
},
"myhostscdb03": {
"ansible_host": "10.10.252.80",
"portal_cpu": 2,
"portal_domain": "prod.local",
"portal_group": "DBA",
"portal_hostname": "myhostscdb03",
"portal_ip_address": "10.10.252.80",
"portal_memory": 8
}
}
},
"all": {
"children": [
"ungrouped"
]
},
"ungrouped": {
"hosts": [
"myhostdcdb01",
"myhostdcdb02",
"myhostdcdb03",
"myhostscdb01",
"myhostscdb02",
"myhostscdb03"
]
}
}
现在我不知道如何将其规范化为一种合理的格式,其中每个主机及其详细信息位于单独的一行中,即:
这是我第一次接触熊猫,很容易做到。您可能需要进行更多的调整,并改变读取/存储数据的方式,以满足您的确切需求,但这将使大部分工作变得更加重要
示例作为示例python交互式会话
相关问题 更多 >
编程相关推荐