如何在Ansible play中从MySQL查询中提取值
在Ansible play中,我在MySQL数据库上运行了一个成功的SQL查询,返回:如何在Ansible play中从MySQL查询中提取值,mysql,arrays,json,ansible,Mysql,Arrays,Json,Ansible,在Ansible play中,我在MySQL数据库上运行了一个成功的SQL查询,返回: "result": [ { "account_profile": "sbx" }, { "account_profile": "dev" } ] 该结果保存到名为query\u output的变量中。我知道我可以在Ansible via中显示结果数组 - debug: var: q
"result": [
{
"account_profile": "sbx"
},
{
"account_profile": "dev"
}
]
该结果保存到名为query\u output的变量中。我知道我可以在Ansible via中显示结果数组
- debug:
var: query_output.result
但就我个人而言,我不知道如何提取2个account_profile值
我的最终目标是将它们提取到一个事实中,这是一个数组。比如:
"aws_account_profiles": [ "sbx", "dev" ]
我知道我错过了一些非常明显的东西
建议?您想要的是:
{{query_output.result | map(attribute=“account_profile”)| list}
我很高兴它很简单。请将答案标记为已接受,以便其他人知道它对您有帮助