我有几十个复制操作可以根据以下配置文件存储层次结构查找相应的文件(无法更改):
{{role_path}}/file.name.{hostname}
{{role_path}}/file.name
/config/current/file.name.{hostname}
/config/current/file.name
/config/legacy/file.name.{hostname}
/config/legacy/file.name
有没有办法避免为每个配置文件重复整个with_first_found子句,如下所示?
- name: Copy /etc/file.name
copy:
src: "{{item}}"
dest: "/etc/file.name"
owner: root
group: root
mode: 0644
with_first_found:
- files:
- files/etc/file.name.{{inventory_hostname}}
- files/etc/file.name
paths:
- "{{ role_path }}"
- /config/current
- /config/legacy