小编Yeh*_*paz的帖子

JMESPathTypeError 在 Ansible 中使用 json_query 过滤器和 starts_with 时出错

我正在尝试过滤从 Ansible 中的 boto3 到达的结果。

当我在没有“[?starts_with(...)]”的结果上使用 json 查询时,它运行良好,但是在添加 starts_with 语法时:

"state_machines[?starts_with(name,'hello')].state_machine_arn"
Run Code Online (Sandbox Code Playgroud)

为了过滤结果:

{u'boto3': u'1.4.4', u'state_machines': 
[{u'state_machine_arn': u'<state machine arn 1>', u'name': u'hello_world_sfn', u'creation_date': u'2017-05-16 14:26:39.088000+00:00'}, 
{u'state_machine_arn': u'<state machine arn 2>', u'name': u'my_private_sfn', u'creation_date': u'2017-06-08 07:25:49.931000+00:00'}, 
{u'state_machine_arn': u'<state machine arn 3>', u'name': u'alex_sfn', u'creation_date': u'2017-06-14 08:35:07.123000+00:00'}], 
u'changed': True}" }
Run Code Online (Sandbox Code Playgroud)

我希望得到第一个 state_machine_arn 值:“状态机 arn 1”

但相反,我得到了例外:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: JMESPathTypeError: In function contains(), invalid type for value: <lamdba_name>, expected …
Run Code Online (Sandbox Code Playgroud)

ansible boto3 jmespath

6
推荐指数
1
解决办法
4177
查看次数

标签 统计

ansible ×1

boto3 ×1

jmespath ×1