ansible - 无法使用 uri 模块 ansible 在 dynatrace 中创建管理区域
问题描述
我很难使用 rhel 7 上的 ansible playbook 在 dynatrace 中创建管理区域,下面是我的代码,以及预期输出和实际输出
uri:
url: "https://{{ xxxxxxx }}/e/{{ xxxxxxx }}/api/config/v1/managementZones"
method: POST
return_content: yes
validate_certs: no
status_code: 201,400
headers:
Accept: 'application/json'
Authorization: 'Api-Token {{ xxxxxxxx }}'
body_format: json
body: "{{ somejsonoutput }}"
register: managzone
run_once: true
如果上面的代码不可用但它没有按预期工作,我期待上面的代码创建管理区域。
预期输出:
dynatrace_response_source": "Cluster",
"elapsed": 0,
"failed": false,
"frame_options": "xxxxxxx",
"json": {
id: "xxxxx"
name: "xxxxx"
}
}
},
"msg": "HTTP Error 400: Bad Request",
"pragma": "no-cache",
"redirected": false,
"status": 400,
但以下是实际输出
输出
"dynatrace_response_source": "Cluster",
"elapsed": 0,
"failed": false,
"frame_options": "xxxxxxx",
"json": {
"error": {
"code": 400,
"constraintViolations": [
{
"location": null,
"message": "must not be blank",
"parameterLocation": "PAYLOAD_BODY",
"path": "name"
}
],
"message": "Constraints violated."
}
},
"msg": "HTTP Error 400: Bad Request",
"pragma": "no-cache",
"redirected": false,
"status": 400,
解决方案
看起来您缺少有效负载主体(json 格式)中的参数之一,或者您的 json 结构无效。在文档中检查它。
必填项之一是 MZ 的名称,其他参数是可选的。首先尝试创建没有规则的MZ。
推荐阅读
- excel - 防止 Excel“将文本转换为列向导”将文本转换为日期
- amazon-web-services - 无法删除 Amazon EBS 快照
- java - 如何在执行后获得待处理意图的引用
- excel - 使用文件路径声明变量时下标超出范围
- python - 仅使用一列对嵌套列表进行排序
- hybris - 在 hybris 中导入 impex 时,值行没有当前标题
- javascript - 如何使用 mongodb 查询更新给定数组中的特定对象
- camera - NuScenes 数据集:如何将激光雷达点云投影到相机图像平面中?
- hive - 如何在 Jython Evaluator 中获取 StreamSets 记录字段类型
- c++ - 使用 GLM 的 DirectX11 MVP 矩阵