我在使用 ansible 发送 JSON 字符串时遇到错误



在这里我想将一个 json 字符串发送到 url . 请检查我的语法,让我知道我的代码中有什么问题。

Ansiblejson.yml

hosts:localhost
sudo:yes
tasks
- name:send jenkins-jobs 
uri
url:"i gave URL here"
method:PUT
return_content:yes
body:-"{{'Name:sai','Node:node number','EventId:123'}}"
status_code:204
body_format:json

这是我得到的错误

The error appears to be have in "c:/ansiblejson.yml" line 4, column 8, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be :
sudo:yes
tasks:
^ here

首先,请修复代码格式。 不要只使用退格键空格,因为 YAML。

Ansible 告诉您您需要知道的所有内容,您在任务部分后忘记了一个分号:

hosts: localhost
sudo: yes
tasks:
- name:send jenkins-jobs 

另外,从 Ansible 2.2 开始,你应该使用 not sudo: yes,而是be:yes,然后你想成为什么用户; root,sudo等...

相关内容

最新更新