【发布时间】:2020-07-26 03:04:33
【问题描述】:
我正在编写 ansible playbook 以使用 snow_record_find 模块获取 SNOW 记录。文档 (https://docs.ansible.com/ansible/latest/modules/snow_record_find_module.html) 的示例非常有限。
除此之外,我也无法准确理解 api 文档 (https://pysnow.readthedocs.io/en/latest/api/query_builder.html)。
我试过这个玩法:
- name: Find records in sc_item_option list
snow_record_find:
username: username
password: password
instance: instance
table: sc_item_option
query:
sys_id:
IN:
- "5203930cdb230010a5d39235ca9619f6"
- "605d12bedbe70010a5d39235ca9619dd"
- "81115fc8db230010a5d39235ca96193d"
register: allVarsRecord
并得到这个错误:
Expected value of type `str` or `list`, not <class 'dict'>", "query": {"sys_id": {"IN": ["5203930cdb230010a5d39235ca9619f6", "605d12bedbe70010a5d39235ca9619dd", "81115fc8db230010a5d39235ca96193d"]}}
我也将我的剧本修改为这样:
- name: Find records in sc_item_option list
snow_record_find:
username: username
password: password
instance: instance
table: sc_item_option
query:
IN:
sys_id:
- "5203930cdb230010a5d39235ca9619f6"
- "605d12bedbe70010a5d39235ca9619dd"
- "81115fc8db230010a5d39235ca96193d"
register: allVarsRecord
- debug:
msg: "{{allVarsRecord}}"
然后得到这个错误:
Expected value of type `str` or `list`, not <class 'dict'>", "query": {"IN": {"sys_id": ["5203930cdb230010a5d39235ca9619f6", "605d12bedbe70010a5d39235ca9619dd", "81115fc8db230010a5d39235ca96193d"]}}
如何解决此错误并使其正常工作?任何建议都可以,因为我已经筋疲力尽地考虑这个了..
提前致谢。
【问题讨论】: