2016-07-23 4 views
0

変数を使用し、メッセージをmsgとして取得すると、フェッチモジュールはファイルを転送しません。「リモートファイルは存在しません。しかし、ファイルはソースディレクトリに存在します。これに間違いがあればお勧めします。変数を使用するとフェッチが転送されません

ansible 2.1.0.0

--- 
    - hosts: host_A 
    become_user: yes 
    gather_facts: no 
    tasks: 
    - name: list files 
     shell: ls -1 /root/stuff/install.1_comiskey-v01 
     register: dumpfiles 
    -debug: var=dumpfiles 

    - name: fetch files 
     fetch: src={{item}} dest=/tmp/fetched/ flat=yes 
     with_items: ('{{dumpfiles.stdout_lines}}') 
     register: test 
    - debug: var=test 

出力:

 TASK [fetch files]                    
    ************************************************************* 
    ok: [10.1.31.82] => (item=('[u'/root/stuff/install.1_comiskey-v01',u'/root/stuff/install.1_comiskey-v02']')) 

    TASK [debug] ******************************************************************* 
    ok: [10.1.31.82] => { 
    "test": { 
    "changed": false, 
    "msg": "All items completed", 
    "results": [ 
      { 
       "_ansible_item_result": true, 
       "_ansible_no_log": false, 
       "changed": false, 
       "file": "('[u'/root/stuff/install.1_comiskey-v01', u'/root/stuff/install.1_comiskey-v02']')", 
       "invocation": { 
        "module_args": { 
         "dest": "/tmp/fetched/", 
         "flat": "yes", 
         "src": "('[u'/root/stuff/install.1_comiskey-v01', u'/root/stuff/install.1_comiskey-v02']')" 
         }, 
        "module_name": "fetch" 
        }, 
       "item": "('[u'/root/stuff/install.1_comiskey-v01', u'/root/stuff/install.1_comiskey-v02']')", 
       "msg": "the remote file does not exist, not transferring, ignored" 
      } 
     ] 
     } 
     } 

答えて

1

with_itemsから括弧を削除します。デバッグ出力でitem変数が正しくないことに注意してください。

+0

ありがとうございました。 – samir

関連する問題