我正在尝试在 Ansible 中过滤从 boto3 到达的结果。
当我对没有“[?starts_with(...)]”的结果使用json查询时,它运行良好,但是当添加starts_with语法时:
"state_machines[?starts_with(name,'hello')].state_machine_arn"
为了过滤结果:
{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}" }
我希望得到第一个 state_machine_arn 值:“state machine 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 one of: ['array', 'string'], received: "unknown" fatal: [localhost]: FAILED!
=> {"failed": true, "msg": "Unexpected failure during module execution.", "stdout": ""}
可能是什么问题?