2017-08-25 57 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等...

相關問題