下面是使用GET调用我的剧本的输出。我想调试此输出中的id以用于其他任务。由于某些原因,我无法得到它。
},
"json": {
"clients": [
{
"aliases": [
"servername",
"servername.domain"
],
"hostname": "servername.domain",
"links": [
{
"href": "https://backupserver:port/nwrestapi/v3/global/clients/10.0.0.11.0.0.0.0.74.15.25.587.58.369.12.87.98",
"rel": "item"
}
],
"resourceId": {
"id": "10.0.0.11.0.0.0.0.74.15.25.587.58.369.12.87.98",
"sequence": 8
谷歌搜索后,我使用了很多方法来过滤掉id,但无法正常工作 出。
id_found是一个var,我在我的playbook中存储Get调用的输出 (注册:id_found)
使用debug:
msg="{{ lookup('id','id_found.json')|from_json }}"
使用sef_fact
- set_fact:
host_id: "{{ (id_found | first).id }}"
host_id: "{{ id_found.json.[0].id }}"
任何人都可以帮助我如何实现这一目标?感谢