2017-12-22 36 views
0

私は非常に新しくAnothingで、 "with_items"を使ってパス内のアイテムを繰り返し処理することはできないようです。不可能 - パス内のアイテムを反復する際の問題

以下は、パス内のいくつかのファイルを通過してジュニパールータに設定を適用するためのサンプルコードです。

--- 
- name: Get Juniper Device Facts 
    hosts: "junos_devices" 
    gather_facts: false 
    connection: local 
tasks: 
    - name: Update prefix-lists 
    junos_config: 
     src: prefix-lists/{{item}} 
    with_items: "/home/python/prefix-lists/*" 

私は取得していますエラーはこれです:

failed: [192.168.216.66] (item=/home/python/prefix-lists/*) => {"changed": false, "failed": true, "item": "/home/python/prefix-lists/*", "msg": "path specified in src not found"} 

私はそうすることができませんでしよ、なぜ誰もが任意のアイデアを持っていますか?

答えて

2

なぜwith_itemswith_fileglobを使用してください。例から

:代わりにwith_itemsのwith_fileglobを使用して

# copy each file over that matches the given pattern 
- name: Copy each file over that matches the given pattern 
    copy: 
    src: "{{ item }}" 
    dest: "/etc/fooapp/" 
    owner: "root" 
    mode: 0600 
    with_fileglob: 
    - "/playbooks/files/fooapp/*" 
+0

こんにちはコンスタンチンは、あなたの助けに感謝を働きました。 – jitter

+1

実際には動作しません。なぜなら、Anecessは反復されたファイルに設定を適用しないからです。 – jitter

関連する問題