从循环中跳过项目

Mar*_*ous 3 ansible

我希望 ansible 循环首先仅跳过列表中的第一项 > item - a

任务看起来像:

- name: create project sub-directory
  win_file:
    path: '{{ projects_dir }}\{{ project_name }}\{{ item }}'
  state: directory
  loop: '{{ sub_directories }}'
Run Code Online (Sandbox Code Playgroud)

vars 文件看起来像:

sub_directories:
 - a
 - b
 - c
 - d
Run Code Online (Sandbox Code Playgroud)

我希望循环跳过 item - a,以便它仅创建 b、c 和 d 子目录。

Vla*_*tka 6

使用索引。查看列表

loop: "{{ sub_directories[1:] }}"
Run Code Online (Sandbox Code Playgroud)