0
目前,我用curl
一個HTTP PUT發送到我的API:轉換捲曲API PUT到Ansbile劇本
curl -k -s -u icinga:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/hosts/dbserver.example.com' -d '{ "templates": [ "generic-host" ], "attrs": { "zone": "vienna", "address": "xxx.xx.xx.x", "check_command": "hostalive", "vars.os" : "Linux", "vars.agent" : "ssh" } }' | python -m json.tool
這就像一個魅力。
我在嘗試將此api調用轉換爲合理的操作手冊。我知道URI提供了URI模塊,所以我試圖使用它,但是可能有些東西配置不正確。
---
- name: Add new host
uri:
url: icinga2.example.com:5665/v1/objects/hosts/client.example.com
method: PUT
user: admin
password: xxxxxxx
body: { templates: [ "generic-host" ], attrs: { "zone": "vienna",
"address": "172.x.x.xx", "check_command": "hostalive", "vars.os" : "Linux", "vars.agent" : "ssh" } }
headers: "application/json"
register: icinga_log
when: inventory_hostname in groups ['vienna']
with_items: "{{ groups['icinga-monitoring'] }}"
,您應突出與CTRL + K –
代碼會發生什麼事,當你嘗試的例子你有嗎? –