在我的大部分角色开始时,都有以下代码块。它尝试加载操作系统和版本特定的变量和任务。我可以不为每个角色重复这段代码吗?
---
- name: Include OS specific variables.
include_vars: "{{ item }}"
with_first_found:
- files:
- "vars/{{ ansible_os_family }}.yml"
skip: True
- name: Include distribution specific variables.
include_vars: "{{ item }}"
with_first_found:
- files:
- "vars/{{ ansible_distribution }}.yml"
skip: True
- name: Include version specific variables.
include_vars: "{{ item }}"
with_first_found:
- files:
- "vars/{{ ansible_distribution }}{{ ansible_distribution_major_version }}.yml"
skip: True
- name: Run OS specific preparation work.
include: "{{ item }}"
with_first_found:
- files:
- "tasks/{{ ansible_os_family }}.yml"
skip: True
- name: Run distribution specific preparation work.
include: "{{ item }}"
with_first_found:
- files:
- "tasks/{{ ansible_distribution }}.yml"
skip: True
- name: Run version specific preparation work.
include: "{{ item }}"
with_first_found:
- files:
- "tasks/{{ ansible_distribution }}{{ ansible_distribution_major_version }}.yml"
skip: True