Ansible Galaxy is essentially a large public repository of Ansible roles. Roles ship with readmes detailing role use and available variables. Galaxy contains a large number of roles that are constantly evolving and increasing. Galaxy can use git allowing for other role sources such as GitHub.
Ansible ships with the ansible-galaxy
command which may be used to install roles from Galaxy among other useful role management features. 'ansible-galaxy'
can also create new empty roles in your working directory like so: 'ansible-galaxy init <role_name>'
Using 'ansible-galaxy install <username.role>'
, you can download roles from galaxy.ansible.com.
Roles installed in the roles_path
may be listed using 'ansible-galaxy list'
1 2 3 |
[miro@controlnode roles]$ ansible-galaxy list - apache, (unknown version) - php-webserver, (unknown version) |
Remove
, search
, and login
are other useful subcommands.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[miro@controlnode roles]$ ansible-galaxy search nginx Found 1338 roles matching your search. Showing first 1000. Name Description ---- ----------- 0x0i.prometheus Prometheus - a multi-dimensional time-series data monitoring and alerting toolkit 0x5a17ed.ansible_role_netbox Installs and configures NetBox, a DCIM suite, in a production setting. 1davidmichael.ansible-role-nginx Nginx installation for Linux, FreeBSD and OpenBSD. 1it.sudo Ansible role for managing sudoers 1nfinitum.php PHP installation role. 2kloc.trellis-monit Install and configure Monit service in Trellis. 4linuxdevops.web-balancer Instalacao e Configuracao do servidor Nginx Load Balancer aadl.docker-nginx-alpine Ansible role to manage and run the alpine nginx docker container. aalaesar.install_nextcloud Add a new Nextcloud instance in your infrastructure. The role manages dependencies and initial configuration. aalaesar.upgrade-nextcloud Upgrade an Nextcloud instance in your infrastructure. The role manages backup and CLI upgrade. AAROC.discourse-sso This is a role to deploy the [Discourse](http://www.discourse.org) discussion forum, **with SAML authentication**. aaronpederson.ansible-autodeploy Simple deployment tool with hooks aaronpederson.fluentd Really simple management of data collection from logs or scripts. Installation from gem. aaronpederson.newrelic Application Performance Monitoring aaronpederson.nginx nginx is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP proxy server. abaez.domain a nginx reverse proxy based on docker abtris.nginx-passenger Ansible: nginx-passenger role acandid.nginx Install Nginx and ssl and Create Vhost in Debian 10 and RHEL/CentOS 7 adamaod.Single-Instance-ELK Single Instance Elk Stack : |
The -p
flag allows specification of local role location (‘ansible-galaxy’ uses /etc/ansible/roles
by default).
We can even write a playbook with ansible-galaxy install
command:
1 2 3 4 5 6 |
--- - hosts: localhost become: yes tasks: - name: install role command: ansible-galaxy install elastic.elasticsearch |
Or use a standard install command:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@controlnode roles]# ansible-galaxy install elastic.elasticsearch -vvv ansible-galaxy 2.4.2.0 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible-galaxy python version = 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] Using /etc/ansible/ansible.cfg as config file Opened /root/.ansible_galaxy Processing role elastic.elasticsearch Opened /root/.ansible_galaxy - downloading role 'elasticsearch', owned by elastic https://galaxy.ansible.com/api/v1/roles/?owner__username=elastic&name=elasticsearch https://galaxy.ansible.com/api/v1/roles/14665/versions/?page_size=50 - downloading role from https://github.com/elastic/ansible-elasticsearch/archive/7.6.0.tar.gz - extracting elastic.elasticsearch to /etc/ansible/roles/elastic.elasticsearch - elastic.elasticsearch (7.6.0) was installed successfully |
We can read README.md file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@controlnode elastic.elasticsearch]# cat /etc/ansible/roles/elastic.elasticsearch/README.md | more # ansible-elasticsearch [![Build Status](https://img.shields.io/jenkins/s/https/devops-ci.elastic.co/job/elastic+ansible-elasticsearch+master.svg)](https://devops-ci.elastic.co/job/elastic+ansible- elasticsearch+master/) [![Ansible Galaxy](https://img.shields.io/badge/ansible--galaxy-elastic.elasticsearch-blue.svg)](https://galaxy.ansible.com/elastic/elasticsearch/) **THIS ROLE IS FOR 7.x & 6.x** Ansible role for 7.x/6.x Elasticsearch. Currently this works on Debian and RedHat based linux systems. Tested platforms are: * Ubuntu 14.04 * Ubuntu 16.04 * Ubuntu 18.04 * Debian 8 * Debian 9 * CentOS 7 |
Finally we can remove elastic role:
1 2 3 4 5 6 7 8 9 10 |
[root@controlnode elastic.elasticsearch]# ansible-galaxy remove elastic.elasticsearch -vvv ansible-galaxy 2.4.2.0 config file = /etc/ansible/roles/elastic.elasticsearch/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible-galaxy python version = 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] Using /etc/ansible/roles/elastic.elasticsearch/ansible.cfg as config file Opened /root/.ansible_galaxy - successfully removed elastic.elasticsearch |