在Ansible中,我可以像子程序一样重用角色吗?



Ansible v2.11

我在Windows目标上安装了很多应用程序,其中大多数都遵循相同的例程-例如下载,解压缩。

- name: Download the zip file
win_url:
url_username: user
url_password: password
url: "{{ some_url }}"
dest: "C:\temp\{{ some_archive }}"
- name: Unzip the archive
win_unzip:
src: "C:\temp\{{ some_archive }}"
dest: "{{ archive_install_dir }}"

是否可以在"其他角色"中重用上述角色?例如,我只传递some_archivearchive_install_dir变量?我设置了我的角色,所以每个角色都有自己的Git存储库。

您可以使用include_role或import_role来拉入。