Ansible Galaxy and Prebuilt Playbooks

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 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 with Ansible Galaxy?

Only thing you need to get started using Ansible Galaxy is a machine with Ansible installed (referred to as a Control Node). You can learn more about how to install Ansible manually or simply use InMotion’s Ansible Control Node.

Our Ansible Control Node comes free with our Cloud VPS Hosting.

Installing Roles from Ansible Galaxy

Using the ansible-galaxy command you can install roles 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.


$ 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
    - role: inmotionhosting.apache
    - role: inmotionhosting.mysql
    - role: inmotionhosting.php_fpm

Learn more about how to create an Ansible Playbook.

John-Paul Briones Content Writer II

John-Paul is an Electronics Engineer that spent most of his career in IT. He has been a Technical Writer for InMotion since 2013.

More Articles by John-Paul

Was this article helpful? Let us know!