2017-08-25 58 views
-1

在这里,我想发送一个JSON字符串到一个URL。请检查我的语法,并让我知道我的代码中存在什么问题。我发送一个错误,同时发送一个JSON字符串使用ansible

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 

以下是错误的IAM越来越

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 
+0

清理不相关的标签,不要再这样做。 – coderanger

回答

2

首先,请修改代码格式。 由于YAML的原因,请勿仅使用退格仅填空格。

Ansible告诉你,你需要知道的一切,你忘了一个分号的任务后段:

hosts: localhost 
sudo: yes 

tasks: 
     - name:send jenkins-jobs 

此外,从Ansible 2.2,你应该使用不须藤:是,但成为:是,然后你想成为什么用户;根,sudo等...

相关问题