2016-12-07 3 views
0

この出力でパス変数をターゲットにしたいと思っています。アシスタント - アイテムをターゲットする方法

ok: [myMachine1] => { 
    "foundFiles": { 
     ... 
     "results": [ 
      { 
       ... 
       "files": [ 
        { 
         ... 
         "path": "/my/first/path", 
         ... 
        } 
       ], 

      }, 
      { 
       ... 
       "files": [ 
        { 
         ... 
         "path": "/my/second/path", 
         ... 
        } 

      } 
     ] 
    } 
} 

「パス」変数を​​ターゲットに設定するにはどうすればよいですか。 私がしようとしている:

- debug: 
    msg: "{{ item.files.path }}" 
    with_items: 
    - foundFiles.results 

しかし、唯一の"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'unicode object' has no attribute 'key'

感謝の第一人者年代を取得。

答えて

1

まず:裸の変数は第二Ansible 2.2
以降でサポートされていません。filesあなたがfilesリスト内の下に複数のエントリを持っている場合、あなたはmapにそれを検討すべきであるあなたの例では

- debug: msg="{{ item.files[0].path }}" 
    with_items: "{{ foundFiles.results }}" 

リストです。

関連する問題