---
title: "Ansible Galaxy and Prebuilt Playbooks"
description: "Rather than create our roles from scratch, we’ll use community submitted roles from Ansible Galaxy for use in our playbook. You can think of Ansible Galaxy as a community repository for Ansible..."
url: https://www.inmotionhosting.com/support/edu/ansible/getting-started-with-ansible-galaxy/
date: 2020-04-01
modified: 2023-08-22
author: "InMotion Hosting Contributor"
categories: ["Ansible Tutorials"]
type: post
lang: en
---

# Ansible Galaxy and Prebuilt Playbooks

Rather than create our roles from scratch, we’ll use community submitted roles from [Ansible Galaxy](https://www.inmotionhosting.com/support/edu/ansible/getting-started-with-ansible-galaxy/) for use in our playbook. You can think of Ansible Galaxy as a community repository for Ansible Roles. As any person or team is able to contribute, it is important to use curated playbooks that are well-tested**.** This ensures that you choose one that is maintained and has a good rating among users.

- [What do I need to get started?](#needs)
- [Installing Roles from Ansible Galaxy](#install)
  - [Ad-hoc](#ad-hoc)
  - [Using a Requirements file](#requirements)
- [Roles from Ansible Galaxy](#roles)

## What do I need to get started with Ansible Galaxy?

Only thing you need to get started using Ansible Galaxy is a machine with [Ansible](https://www.inmotionhosting.com/ansible) installed (referred to as a **Control Node**). You can learn more about [how to install Ansible manually](https://www.inmotionhosting.com/support/edu/ansible/install-ansible/) or simply use InMotion’s [Ansible Control Node](https://www.inmotionhosting.com/support/edu/ansible/getting-started-ansible-control-node/).

Our Ansible Control Node comes free with our [Cloud VPS Hosting](https://www.inmotionhosting.com/cloud-vps).

## Installing Roles from Ansible Galaxy

Using the ansible-galaxy command you can [install roles](https://www.inmotionhosting.com/support/edu/ansible/install-ansible-galaxy-roles-and-collections/) ad-hoc or use a requirements file to install multiple roles at once. Here are some examples of that using InMotion Hosting’s curated modular Ansible roles.

### Ad-hoc:

```
$ ansible-galaxy install \
      inmotionhosting.apache inmotionhosting.mysql inmotionhosting.php_fpm
```

### Using a Requirements file:

In your requirements.yml :

```
---
- src: inmotionhosting.apache
- src: inmotionhosting.mysql
- src: inmotionhosting.php_fpm
```

Then simply run:

```
$ ansible-galaxy install -r requirements.yml
```

## Using Roles from Ansible Galaxy

Using the roles we installed earlier, let’s incorporate them into a playbook:

```
# site.yml
- name: Deploy a LAMP stack
  hosts: lamp
  roles:
    - role: inmotionhosting.apache
    - role: inmotionhosting.mysql
    - role: inmotionhosting.php_fpm
```

Learn more about [how to create an Ansible Playbook](https://www.inmotionhosting.com/support/edu/ansible/getting-started-with-ansible-galaxy/).
