Ansible Galaxy是Ansible官方用于用户分享Ansible roles的社区hub。一个role就是用Ansible的方式构建自动化内容并使其可以重复使用。
1.下载各种Roles
可以通过ansible-galaxy在命令行下载各种流行的roles。类似从Zabbix的官方社区下载各种模板一样。
# ansible-galaxy install patrik.uytterhoeven.Zabbix-Agent
install 后面是 username.rolename
可以在一个文件中指定多个需要下载的roles
# ansible-galaxy install -r roles.txt # cat roles.txt patrik.uytterhoeven.Zabbix-Agent patrik.uytterhoeven.Zabbix_Server
从Ansible1.8开始可以不通过Galaxy下载roles
# install_roles.yml
# from galaxy
- src: yatesr.timezone
# from github
- src: https://github.com/bennojoy/nginx
# from github installing to a relative path
- src: https://github.com/bennojoy/nginx
path: vagrant/roles/
# from github, overriding the name and specifying a specific tag
- src: https://github.com/bennojoy/nginx
version: master
name: nginx_role
# from a webserver, where the role is packaged in a tar.gz
- src: https://some.webserver.example.com/files/master.tar.gz
name: http-role
# from bitbucket, if bitbucket happens to be operational right now :)
- src: git+http://bitbucket.org/willthames/git-ansible-galaxy
version: v1.4
# from bitbucket, alternative syntax and caveats
- src: http://bitbucket.org/willthames/hg-ansible-galaxy
scm: hg
# ansible-galaxy install -r install_roles.yml
2.Share Roles
$ git clone https://username@github.com/username/ansible-role-acme.git acme $ ansible-galaxy init acme --force
cme/
.travis.yml
README.md
defaults/
files/
handlers/
meta/
tasks/
templates/
tests/
vars/
详情参加官方文档
参考文档:
https://galaxy.ansible.com/intro#welcome
http://docs.ansible.com/ansible/galaxy.html
https://galaxy.ansible.com/explore#/
https://galaxy.ansible.com/list#/roles?page=1&page_size=10
转载于:https://blog.51cto.com/john88wang/1790099