现在我的目录结构如下:
roles
├── python2
│ └── tasks
│ └── main.yml
└── redis
├── handlers
│ └── main.yml
└── tasks
└── main.yml
这有点过于复杂。有没有办法让它变得像?
roles
├── python2
│ └── tasks.yml
└── redis
├── tasks.yml
└── handlers.yml
我查了一份文件,看起来没有这样的选择。
答案 0 :(得分:2)
据我所知,没有办法用角色来做这件事,但听起来你根本不需要角色。你可以改用包含。 http://docs.ansible.com/ansible/playbooks_roles.html
您的文件结构可能如下所示:
main.yml
includes
├── python2
│ └── tasks.yml
└── redis
├── tasks.yml
└── handlers.yml
或
main.yml
python2Tasks.yml
redisTasks.yml
redisHandlers.yml
或
main.yml
tasks
├── python2.yml
└── redis.yml
handlers
└── redis.yml
main.yml看起来像:
- name: python2 play
hosts: python2Hosts
tasks:
- include: includes/python2/tasks.yml
- name: redis play
hosts: redisHosts
tasks:
- include: includes/redis/tasks.yml
handlers:
- include: includes/redis/handlers.yml