【发布时间】:2015-05-28 14:10:40
【问题描述】:
我想通过 Ansible 向 API 端点发出 POST 请求,其中发布数据中的某些项目是动态的,这是我尝试但失败的方法:
我的 body_content.json:
{
apiKey: '{{ KEY_FROM_VARS }}',
data1: 'foo',
data2: 'bar'
}
这是我的 Ansible 任务:
# Create an item via API
- uri: url="http://www.myapi.com/create"
method=POST return_content=yes HEADER_Content-Type="application/json"
body="{{ lookup('file','create_body.json') | to_json }}"
很遗憾这不起作用:
failed: [localhost] => {"failed": true}
msg: this module requires key=value arguments
....
FATAL: all hosts have already failed -- aborting
我的 ansible 版本是 1.9.1
【问题讨论】: