Introducing Scaleway NextGen NVMe Cloud Servers with Hot-Snapshots. 🚀

Help


Community tutorials and documentations

Getting Started with Ansible Galaxy

Ansible Galaxy Overview

The idea behind Galaxy is to give greater visibility to one of Ansible’s most exciting features: reusable Roles for server configuration or application installation. Many people share roles on Ansible Galaxy.

Ansible roles are consists of many playbooks which are way to group multiple tasks together into one container to do the automation in very effective manner with clean directory structures.

Before following this tutorial, you must be familiar with Ansible and Ansible-Apache first.

Creating LAMP Server with Ansible Roles

To create a Ansible roles, we need to use the ansible-galaxy command which has the templates to create it. Roles must be downloaded before they can be used in playbooks.

This will create it under the default directory /etc/ansible/roles and do the modifications else we need to create each directories and files manually.

1 . Install Apache, MySQL and PHP with a ansible-galaxy command. We will use the role from geerlinguy who is a software developer involved in many open source development communities. Check geerlinguy for many other roles.

ansible-galaxy install geerlingguy.apache geerlingguy.mysql geerlingguy.php

The latest version will be downloaded if no version is specified. To specify a version, add the version after the role name, for instance geerlingguy.apache,1.0.0 or geerlingguy.mysql,1.0.0

2 . Create an Ansible playbook named lamp.yml with the following contents:

---
- hosts: all
  roles:
  - geerlingguy.mysql
  - geerlingguy.apache
  - geerlingguy.php

3 . Run the playbook against a host

ansible-playbook lamp.yml

The LAMP server is now created.

Creating a Solr Server with Ansible Roles

Apache Solr is a fast open-source Java search server. Solr enables you to easily create search engines which searches websites, databases and files. For more information on Solr, refer to the Solr official documentation.

1 . Install Java, tomcat6, Solr with a ansible-galaxy command. We will use the role from geerlinguy who is a software developer involved in many open source development communities. Check geerlinguy for many other roles.

Note: java and tomcat6 roles are optional, since they’ll be automatically picked up during installation of the geerlingguy.solr role

ansible-galaxy install geerlingguy.java geerlingguy.tomcat6 geerlingguy.solr

2 .Create a playbook named solr.yml with the following contents:

---
- hosts: all
  roles:
    - geerlingguy.java
    - geerlingguy.tomcat6
    - geerlingguy.solr

3 . Run the playbook against a host

ansible-playbook solr.yml

The Solr server is now created. The roles’ pages on the Ansible Galaxy website highlight the available variables for setting things like what version of Solr to install, where to install it, etc. (for example: geerlingguy.solr Galaxy page).

Other Helpful Galaxy Commands

Some other helpful ansible-galaxy commands:

  • ansible-galaxy list displays a list of installed roles, with version numbers
  • ansible-galaxy remove [role] removes an installed role
  • ansible-galaxy init can be used to create a role template suitable for submission to Ansible Galaxy

Additionally, you can configure the default path where Ansible roles will be downloaded by editing your ansible.cfg configuration file (normally located in /etc/ansible/ansible.cfg and setting a roles_path in the [defaults] section.

For more information on Galaxy commands, refer to the official documentation.

Discover a New Cloud Experience

Deploy SSD Cloud Servers in seconds.