11. Ansible Galaxy

  • sharing is caring
  • community contributed roles
  • re-useable roles

11.2. Search galaxy roles

  • querying the Galaxy database
  • allowing for searching by tags, platforms, author and multiple keywords
# search elasticsearch
ansible-galaxy search elasticsearch

Found 99 roles matching your search:
Name                      Description
----                      -----------
williamyeh.elasticsearch  Install Elasticsearch
bastly.elasticsearch      Elasticsearch for Linux

11.3. Installation of new role

# install a single role
ansible-galaxy install williamyeh.elasticsearch

# list installed roles
ansible-galaxy list

11.4. Installation via requirements.yml

# install multiple roles
vi requirements.yml
# from galaxy
- src: williamyeh.elasticsearch
  version: 1.1.0
- src: williamyeh.prometheus

# from GitHub
- src: https://github.com/bennojoy/nginx

# 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
- 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

# from GitLab or other git-based scm
- src: git@gitlab.company.com:mygroup/ansible-base.git
  scm: git
  version: "0.1"  # quoted, so YAML doesn't parse this as a floating-point value

# install multiple roles
ansible-galaxy install -r requirements.yml

# list installed roles
ansible-galaxy list
- williamyeh.prometheus, 2.3.1
- williamyeh.elasticsearch, 1.0.0

Hint

Roles can also be installed directly from source control repos or tar files.

Hint

You can use the init option of ansible-galaxy to initialize a role structure for a new role: ansible-galaxy init rolename