2017-04-14 53 views
1
創建數組的一個子集

我的數據文件看起來像在ansible

--- 
data: 
    - item 1 
    - item 2 
    - item 3 
    - item 4 

我想包括項目1的一個taskbook和項目2 diferent taskbook - 4.如何創建一個數組只[ '項目2', '項目3', '第4項']

--- 
- hosts: localhost 
tasks: 
    - include: taskbooks1.yml param={{data[0]}} 

    - include: taskbooks2.yml param={{item}} 
    with_indexed_items: "{{ data }}" # I want to pass another list without item 1 

回答

1
- include: taskbooks2.yml param={{item}} 
    with_items: "{{data[1:]}}"