2016-03-21 14 views
2

私はこのcURL呼び出しを無意味なプレイブックに翻訳しようとしています。PUTリクエストでデータを書き込み、不可能なURIモジュール

  • cURLの呼び出し:

    curl -X PUT -d "value={aa}" "http://172.31.64.174:2379/v2/keys/coreos.com/network/config" 
    
  • Ansibleの脚本:

    - uri: 
        url: "http://172.31.64.174:2379/v2/keys/coreos.com/network/config" 
        method: PUT 
        body: "value={aa}" 
    

私はこの1つを試してみましたが、サーバーはPUTの請願書を受け取るが、値は変更されません。すべてのヘルプははるかに高く評価されて

* Trying 172.31.64.174... 
* Connected to 172.31.64.174 (172.31.64.174) port 2379 (#0) 
> PUT /v2/keys/coreos.com/network/config HTTP/1.1 
> Host: 172.31.64.174:2379 
> User-Agent: curl/7.47.1 
> Accept: */* 
> Content-Length: 10 
> Content-Type: application/x-www-form-urlencoded 
> 
* upload completely sent off: 10 out of 10 bytes 
< HTTP/1.1 200 OK 
< Content-Type: application/json 
< X-Etcd-Cluster-Id: 1dd872ea8ead78 
< X-Etcd-Index: 325563 
< X-Raft-Index: 1356544 
< X-Raft-Term: 2694 
< Date: Mon, 21 Mar 2016 08:48:33 GMT 
< Content-Length: 228 
< 
{"action":"set","node":{"key":"/coreos.com/network/config","value":"{aa}","modifiedIndex":325563,"createdIndex":325563},"prevNode"{"key":"/coreos.com/network/config","value":"{a}","modifiedIndex":324785,"createdIndex":324785}} 
* Connection #0 to host 172.31.64.174 left intact 

これは、cURLの手順からの詳細な出力があります。

事前

答えて

1

のおかげでは最後に、私はそれがステータスコード、ヘッダーのコンテンツタイプと、これらの行を追加して、戻りコンテンツを設定することにより、作業ました:

status_code: 200 
return_content: yes 
HEADER_Content-Type: "application/x-www-form-urlencoded" 

だから、最終的には、のようになります。

- uri: 
    url: "{{ etcd_server }}/v2/keys/coreos.com/network/config" 
    method: PUT 
    body: "value={aa}" 
    status_code: 200 
    return_content: yes 
    HEADER_Content-Type: "application/x-www-form-urlencoded" 
関連する問題