我想创建一个包含变量的文件夹结构:
---
- name: Create project root
file:
state: directory
path: "{{ root_path }}{{ project_name }}"
- name: Create additional folders
file:
state: directory
path: "{{ root_path }}{{ project_name }}/{{ item }}"
with_items:
- production
- logs
- media
root_path
是默认变量,project_name
由额外变量提供。第一个任务工作正常但下一个抛出"ERROR! 'item' is undefined"
。我尝试从字符串中移动item
,但它会引发语法错误。