---
title: Getting Started with Ansible Galaxy
description: This tutorial shows how to configure and how to use Ansible Galaxy
tags: ansible ansible-galaxy
products:
  - kubernetes
  - instances
dates:
  validation: 2025-03-25
  posted: 2018-08-02
  validation_frequency: 12
difficulty: beginner
usecase:
  - deploy-external-software
ecosystem:
  - third-party
---
import Requirements from '@macros/iam/requirements.mdx'


In this tutorial, we show you how to use Ansible Galaxy. Ansible Galaxy is a tool that seeks to give visibility to one of Ansible's most exciting features: reusable roles for server configuration or the installation of applications.
Many users share roles on [Ansible Galaxy](https://galaxy.ansible.com/home).

Ansible roles consist of playbooks that group multiple tasks into one container. They allow the performance of automation tasks with clean directory structures.

<Requirements />

- A Scaleway account logged into the [console](https://console.scaleway.com)
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- An [Instance](/instances/how-to/create-an-instance/) running Ubuntu Linux
- Basic knowledge of [Ansible](/tutorials/ansible-bionic-beaver/) and [Ansible-Apache](/tutorials/install-apache-ansible/)
- [Ansible-Apache](/tutorials/install-apache-ansible/) installed on your local computer

## Creating a LAMP server with Ansible roles

To use roles in Ansible playbooks, you must first download them.

1. Install Apache, MySQL, and PHP.
    ```
    ansible-galaxy install geerlingguy.apache geerlingguy.mysql geerlingguy.php
    ```
    <Message type="note">
      In this example, we use `geerlinguy`'s role, which is a software developer involved in many open-source development communities. The latest version will be downloaded if you do not specify which one you want to download. Add the version after the role name to specify a version. Example: `geerlingguy.apache,1.0.0` or `geerlingguy.mysql,1.0.0`.
      If you want to use other roles, check out [geerlinguy](https://github.com/geerlingguy/ansible-role-ansible)'s Ansible profile.
    </Message>
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 that search websites, databases, and files.

<Message type="note">
  For more information on Solr, refer to the [Solr official documentation](http://lucene.apache.org/solr/news.html).
</Message>

1. Install Java, tomcat6, Solr with an ansible-galaxy command. We will use the role of `geerlinguy` who is a software developer involved in many open-source development communities. Check [geerlinguy](https://galaxy.ansible.com/geerlingguy) for many other roles.
    ```
    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.

## Helpful Galaxy commands

Some other helpful `ansible-galaxy` commands are:

  - `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 are 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](https://docs.ansible.com/ansible/latest/ansible-galaxy.html#actions).