6.0 Ansible Galaxy Role Warehouse

Overview

Now that Docker technology application is very common, compared to everyone who is familiar with Docker's mirror warehouse, it is an official or third-party upload image place, we can download and use it directly

Similarly, for Ansible, roles are the most convenient basic unit for us to reuse. Ansible Galaxy ( galaxy.ansible.com) is a role warehouse, which stores a large number of high-quality roles that have been written by the community. We can download them directly and use them for reference.

Binary files are generally not placed in characters for management, so the characters we download are basically text files
galaxy, which means galaxy or galaxy, and has no special meaning, just like this name

galaxy role download

ansible-galaxy install role_name
ansible-galaxy install geerlingguy.apache geerlingguy.mysql geerlingguy.php
ansible-galaxy install --roles-path . geerlingguy.apache

#--roles-path . 指定下载目录 . 表示当前目录
#执行输出参考
[root@e5e40c15e020 /data]# ansible-galaxy install --roles-path . geerlingguy.apache
- downloading role 'apache', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-apache/archive/3.1.4.tar.gz
- extracting geerlingguy.apache to /data/geerlingguy.apache
- geerlingguy.apache (3.1.4) was installed successfully

The downloaded directory is in this order ~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/rolesby default and can be modified through the configuration file

We can also register an account and upload a role we wrote. For details, see the official document.
Since a role is essentially a set of files, if there is a real need to share a role internally, we can set up a simple http server download or transfer based on rsync. OK

galaxy role lookup

Let’s talk about one of the easiest and most intuitive methods, go directly to the official website WEB interface galaxy.ansible.comto search

As shown in the figure below, we enter nginx keywords to search for related roles
Insert picture description here

Click the first one to go in and see the details
2021-01-26-10-05-36.png

The key information is clear at a glance, so I won’t repeat it here

Collections download

Collections is a concept introduced in the newer version of Ansible. It is a collection of roles. For example, we can define many related roles as Collections, download Collections from the community, and help learn how to organize multiple roles.

ansible-galaxy collection install my_namespace.my_collection
ansible-galaxy collection install nginxinc.nginx_core -p .


#-p . 指定下载目录
#执行输出参考
[root@e5e40c15e020 data]# ansible-galaxy collection install nginxinc.nginx_core -p .
[WARNING]: The specified collections path '/data' is not part of the configured Ansible collections paths '/root/.ansible/collections:/usr/share/ansible/collections'. The installed collection won't be
picked up in an Ansible run.
Process install dependency map
Starting collection install process
Installing 'nginxinc.nginx_core:0.3.0' to '/data/ansible_collections/nginxinc/nginx_core'
#告警是说这个安装目录没在配置文件里写,引用的时候找不到,不用管,我们就是下载下来参考的,不直接使用

Collections lookup

The same galaxy.ansible.comcan be searched on the WEB interface of the official website

2021-01-26-10-21-43.png
2021-01-26-10-21-59.png

List some common high-quality roles or collections

#集合
ansible-galaxy collection install nginxinc.nginx_core        -p .
ansible-galaxy collection install ericsysmin.system          -p . 
ansible-galaxy collection install pandemonium1986.openstack  -p .


#角色
ansible-galaxy  install  geerlingguy.apache                   --roles-path  .
ansible-galaxy  install  singleplatform-eng.users             --roles-path  .
ansible-galaxy  install  geerlingguy.java                     --roles-path  .
ansible-galaxy  install  geerlingguy.nginx                    --roles-path  .
ansible-galaxy  install  geerlingguy.pip                      --roles-path  .
ansible-galaxy  install  geerlingguy.nfs                      --roles-path  .
ansible-galaxy  install  geerlingguy.ntp                      --roles-path  .
ansible-galaxy  install  geerlingguy.git                      --roles-path  .
ansible-galaxy  install  geerlingguy.docker                   --roles-path  .
ansible-galaxy  install  geerlingguy.memcached                --roles-path  .
ansible-galaxy  install  robertdebock.bootstrap               --roles-path  .
ansible-galaxy  install  geerlingguy.repo-epel                --roles-path  .
ansible-galaxy  install  geerlingguy.filebeat                 --roles-path  .
ansible-galaxy  install  cloudalchemy.node-exporter           --roles-path  .
ansible-galaxy  install  geerlingguy.mysql                    --roles-path  .
ansible-galaxy  install  yatesr.timezone                      --roles-path  .
ansible-galaxy  install  geerlingguy.nodejs                   --roles-path  .
ansible-galaxy  install  0x0i.systemd                         --roles-path  .
ansible-galaxy  install  dj-wasabi.zabbix-agent               --roles-path  .
ansible-galaxy  install  geerlingguy.homebrew                 --roles-path  .
ansible-galaxy  install  geerlingguy.jenkins                  --roles-path  .
ansible-galaxy  install  geerlingguy.postgresql               --roles-path  .
ansible-galaxy  install  nginxinc.nginx                       --roles-path  .
ansible-galaxy  install  geerlingguy.kibana                   --roles-path  .
ansible-galaxy  install  davidwittman.redis                   --roles-path  .
ansible-galaxy  install  geerlingguy.security                 --roles-path  .
ansible-galaxy  install  geerlingguy.redis                    --roles-path  .
ansible-galaxy  install  cloudalchemy.prometheus              --roles-path  .
ansible-galaxy  install  evrardjp.keepalived                  --roles-path  .
ansible-galaxy  install  geerlingguy.elasticsearch            --roles-path  .
ansible-galaxy  install  geerlingguy.firewall                 --roles-path  .
ansible-galaxy  install  cloudalchemy.grafana                 --roles-path  .
ansible-galaxy  install  geerlingguy.apache-php-fpm           --roles-path  .
ansible-galaxy  install  krzysztof-magosa.docker              --roles-path  .
ansible-galaxy  install  arillso.hosts                        --roles-path  .
ansible-galaxy  install  ansible-thoteam.nexus3-oss           --roles-path  .
ansible-galaxy  install  robertdebock.sysctl                  --roles-path  .
ansible-galaxy  install  elliotweiser.osx-command-line-tools  --roles-path  .
ansible-galaxy  install  geerlingguy.glusterfs                --roles-path  .
ansible-galaxy  install  geerlingguy.ruby                     --roles-path  .
ansible-galaxy  install  willshersystems.sshd                 --roles-path  .
ansible-galaxy  install  geerlingguy.varnish                  --roles-path  .

You can also see when you execute the download command. Basically, they are downloaded from github. After all, these roles are just a set of text files and the file size is not large. We can also download and decompress it on github by ourselves, but that is still the case. A little troublesome

I also put these high-quality characters in a domestic warehouse for your reference

https://gitee.com/as4k/ysansible-roles-examples/tree/master

Reference

https://docs.ansible.com/ansible/latest/galaxy/user_guide.html
https://galaxy.ansible.com

Guess you like

Origin blog.csdn.net/xys2015/article/details/113868421