如何使用ansible安装ansible角色?
手动方式是使用命令行:
ansible-galaxy install user.role但我如何在ansible本身中做到这一点,就像模块一样?我会在攻略中猜到这样的东西:
- tasks:
galaxy:
user: username
role: rolename
state: installed这似乎是一个非常琐碎和基本的任务,但我不知道如何去做。
这里有一个类似的问题,它没有回答这个问题,因为它每次都只是运行How to automatically install Ansible Galaxy roles? .But命令,而且它不是幂等的(这是使用ansible自动化的主要原因)。
发布于 2019-06-18 23:54:48
你的结论"it just runs the manual command every time, and it is not idempotent“太快了。有了参数creates和适当的ansible_roles_list,这样的任务是幂等的。
- name: Install roles from Ansible Galaxy
command: "ansible-galaxy install {{ item.role_name }}"
args:
creates: "{{ item.role_path }}"
loop: "{{ ansible_roles_list }}"发布于 2019-06-19 01:01:51
这个问题的要点对于新手来说不是那么明显,也不容易在介绍性文档中找到,因为galaxy的角色只需要安装在客户端,而不是安装在服务器上。
因此,在服务器的攻略中,您不必在每次设置服务器时都安装galay角色,而只需在客户机上安装一次。
https://stackoverflow.com/questions/56652544
复制相似问题